Skip to content

Commit

Permalink
Run gofmt on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
efiacor committed Jul 29, 2024
1 parent 2769b7d commit 561f84b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 63 deletions.
2 changes: 1 addition & 1 deletion controllers/pkg/porch/condition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package porchcondition
import (
"strings"

kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
porchv1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
)

// GetPorchConditions converts kpt conditions to porch conditions
Expand Down
2 changes: 1 addition & 1 deletion controllers/pkg/porch/condition/condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package porchcondition
import (
"testing"

kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
"github.com/google/go-cmp/cmp"
porchv1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
)

func TestGetPorchConditions(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"time"

"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
infrav1alpha1 "github.com/nephio-project/api/infra/v1alpha1"
porchcondition "github.com/nephio-project/nephio/controllers/pkg/porch/condition"
porchutil "github.com/nephio-project/nephio/controllers/pkg/porch/util"
Expand All @@ -38,6 +37,7 @@ import (
"github.com/nephio-project/nephio/krm-functions/lib/kubeobject"
vlanfn "github.com/nephio-project/nephio/krm-functions/vlan-fn/fn"
porchv1alpha1 "github.com/nephio-project/porch/api/porch/v1alpha1"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
ipamv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/ipam/v1alpha1"
vlanv1alpha1 "github.com/nokia/k8s-ipam/apis/resource/vlan/v1alpha1"
"github.com/nokia/k8s-ipam/pkg/proxy/clientproxy"
Expand Down
1 change: 0 additions & 1 deletion controllers/pkg/reconcilers/repository/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type repoTest struct {
wantErr bool
}


func TestUpsertRepo(t *testing.T) {
dummyString := "Dummy String"
dummyBool := true
Expand Down
108 changes: 53 additions & 55 deletions controllers/pkg/reconcilers/token/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

infrav1alpha1 "github.com/nephio-project/api/infra/v1alpha1"
"github.com/nephio-project/nephio/controllers/pkg/giteaclient"
"github.com/nephio-project/nephio/controllers/pkg/mocks/external/client"
"github.com/nephio-project/nephio/controllers/pkg/resource"
"github.com/nephio-project/nephio/testing/mockeryutils"
"github.com/stretchr/testify/mock"
"github.com/nephio-project/nephio/controllers/pkg/mocks/external/client"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type fields struct {
Expand All @@ -50,15 +50,15 @@ type tokenTests struct {
}

func TestDeleteToken(t *testing.T) {
tests := []tokenTests {
tests := []tokenTests{
{
name: "Delete Access token reports error",
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{}},
mocks: []mockeryutils.MockHelper{
{MethodName: "DeleteAccessToken",
ArgType: []string{"string"},
RetArgList: []interface{}{nil, fmt.Errorf("\"username\" not set: only BasicAuth allowed")}},
{MethodName: "DeleteAccessToken",
ArgType: []string{"string"},
RetArgList: []interface{}{nil, fmt.Errorf("\"username\" not set: only BasicAuth allowed")}},
},
wantErr: true,
},
Expand All @@ -67,9 +67,9 @@ func TestDeleteToken(t *testing.T) {
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{}},
mocks: []mockeryutils.MockHelper{
{MethodName: "DeleteAccessToken",
ArgType: []string{"string"},
RetArgList: []interface{}{nil, nil}},
{MethodName: "DeleteAccessToken",
ArgType: []string{"string"},
RetArgList: []interface{}{nil, nil}},
},
wantErr: false,
},
Expand All @@ -81,7 +81,7 @@ func TestDeleteToken(t *testing.T) {
giteaClient: tt.fields.giteaClient,
finalizer: tt.fields.finalizer,
}

initMockeryMocks(&tt)

if err := r.deleteToken(tt.args.ctx, tt.args.giteaClient, tt.args.cr); (err != nil) != tt.wantErr {
Expand All @@ -96,38 +96,37 @@ func TestCreateToken(t *testing.T) {
clientMock := new(mocks.MockClient)
clientMock.On("Get", nil, mock.AnythingOfType("types.NamespacedName"), mock.AnythingOfType("*v1.Secret")).Return(nil).Run(func(args mock.Arguments) {})
clientMock.On("Patch", nil, mock.AnythingOfType("*v1.Secret"), mock.AnythingOfType("*resource.patch")).Return(nil).Run(func(args mock.Arguments) {})
tests := []tokenTests {

tests := []tokenTests{
{
name: "Create Access token reports user auth error",
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{}},
mocks: []mockeryutils.MockHelper{
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{nil, nil, fmt.Errorf("\"username\" not set: only BasicAuth allowed")}},
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{nil, nil, fmt.Errorf("\"username\" not set: only BasicAuth allowed")}},
},
wantErr: true,
},
{
name: "Create Access token already exists",
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{
args: args{nil, nil, &infrav1alpha1.Token{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.Identifier(),
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
Name: "test-token",

}}},
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
Name: "test-token",
}}},
mocks: []mockeryutils.MockHelper{
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns",},
}, nil, nil}},
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns"},
}, nil, nil}},
},
wantErr: false,
},
Expand All @@ -136,12 +135,12 @@ func TestCreateToken(t *testing.T) {
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{}},
mocks: []mockeryutils.MockHelper{
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns",},
}, nil, nil}},
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns"},
}, nil, nil}},
{MethodName: "GetMyUserInfo", ArgType: []string{}, RetArgList: []interface{}{nil, nil, fmt.Errorf("error getting User Information")}},
},
wantErr: true,
Expand All @@ -151,38 +150,37 @@ func TestCreateToken(t *testing.T) {
fields: fields{resource.NewAPIPatchingApplicator(nil), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{}},
mocks: []mockeryutils.MockHelper{
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns",},
}, nil, nil}},
{MethodName: "ListAccessTokens",
ArgType: []string{"gitea.ListAccessTokensOptions"},
RetArgList: []interface{}{[]*gitea.AccessToken{
{ID: 123,
Name: "test-token-test-ns"},
}, nil, nil}},
{MethodName: "GetMyUserInfo", ArgType: []string{}, RetArgList: []interface{}{&gitea.User{UserName: "gitea"}, nil, nil}},
{MethodName: "CreateAccessToken",
ArgType: []string{"gitea.CreateAccessTokenOption"},
RetArgList: []interface{}{&gitea.AccessToken{}, nil, fmt.Errorf("failed to create token")}},
{MethodName: "CreateAccessToken",
ArgType: []string{"gitea.CreateAccessTokenOption"},
RetArgList: []interface{}{&gitea.AccessToken{}, nil, fmt.Errorf("failed to create token")}},
},
wantErr: true,
},
{
name: "Create Access token reports success",
fields: fields{resource.NewAPIPatchingApplicator(clientMock), nil, nil},
args: args{nil, nil, &infrav1alpha1.Token{
args: args{nil, nil, &infrav1alpha1.Token{
TypeMeta: metav1.TypeMeta{
APIVersion: corev1.SchemeGroupVersion.Identifier(),
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
Name: "test-token",

}}},
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
Name: "test-token",
}}},
mocks: []mockeryutils.MockHelper{
{MethodName: "ListAccessTokens", ArgType: []string{"gitea.ListAccessTokensOptions"}, RetArgList: []interface{}{[]*gitea.AccessToken{}, nil, nil}},
{MethodName: "GetMyUserInfo", ArgType: []string{}, RetArgList: []interface{}{&gitea.User{UserName: "gitea"}, nil, nil}},
{MethodName: "CreateAccessToken",
ArgType: []string{"gitea.CreateAccessTokenOption"},
RetArgList: []interface{}{&gitea.AccessToken{ID: 123,
Name: "test-token-test-ns"}, nil, nil}},
{MethodName: "CreateAccessToken",
ArgType: []string{"gitea.CreateAccessTokenOption"},
RetArgList: []interface{}{&gitea.AccessToken{ID: 123,
Name: "test-token-test-ns"}, nil, nil}},
},
wantErr: false,
},
Expand All @@ -209,4 +207,4 @@ func initMockeryMocks(tt *tokenTests) {
tt.args.giteaClient = mockGiteaClient
tt.fields.giteaClient = mockGiteaClient
mockeryutils.InitMocks(&mockGiteaClient.Mock, tt.mocks)
}
}
2 changes: 1 addition & 1 deletion krm-functions/lib/kptfile/v1/kptfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"strings"

"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
ko "github.com/nephio-project/nephio/krm-functions/lib/kubeobject"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
corev1 "k8s.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion krm-functions/lib/kptfile/v1/kptfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"

"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
"github.com/google/go-cmp/cmp"
kptv1 "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions operators/nephio-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func main() {
}

managerOptions := ctrl.Options{
Scheme: scheme,
Scheme: scheme,
Metrics: server.Options{
BindAddress: fmt.Sprintf("%s%d", metricsAddr, 9443),
BindAddress: fmt.Sprintf("%s%d", metricsAddr, 9443),
},
HealthProbeBindAddress: probeAddr,
LeaderElection: false,
Expand Down

0 comments on commit 561f84b

Please sign in to comment.