From 561f84bb0c3597d2dd1b15786e98c6e33d830a8f Mon Sep 17 00:00:00 2001 From: Fiachra Corcoran Date: Mon, 29 Jul 2024 09:35:24 +0100 Subject: [PATCH] Run gofmt on all files --- controllers/pkg/porch/condition/condition.go | 2 +- .../pkg/porch/condition/condition_test.go | 2 +- .../generic-specializer/reconciler.go | 2 +- .../reconcilers/repository/reconciler_test.go | 1 - .../pkg/reconcilers/token/reconciler_test.go | 108 +++++++++--------- krm-functions/lib/kptfile/v1/kptfile.go | 2 +- krm-functions/lib/kptfile/v1/kptfile_test.go | 2 +- operators/nephio-controller-manager/main.go | 4 +- 8 files changed, 60 insertions(+), 63 deletions(-) diff --git a/controllers/pkg/porch/condition/condition.go b/controllers/pkg/porch/condition/condition.go index 05abb26a..49ef3dbf 100644 --- a/controllers/pkg/porch/condition/condition.go +++ b/controllers/pkg/porch/condition/condition.go @@ -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 diff --git a/controllers/pkg/porch/condition/condition_test.go b/controllers/pkg/porch/condition/condition_test.go index e02ffc16..bf09006e 100644 --- a/controllers/pkg/porch/condition/condition_test.go +++ b/controllers/pkg/porch/condition/condition_test.go @@ -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) { diff --git a/controllers/pkg/reconcilers/generic-specializer/reconciler.go b/controllers/pkg/reconcilers/generic-specializer/reconciler.go index 3f6a32a0..6fce8e6c 100644 --- a/controllers/pkg/reconcilers/generic-specializer/reconciler.go +++ b/controllers/pkg/reconcilers/generic-specializer/reconciler.go @@ -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" @@ -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" diff --git a/controllers/pkg/reconcilers/repository/reconciler_test.go b/controllers/pkg/reconcilers/repository/reconciler_test.go index 770b6a60..366ce613 100644 --- a/controllers/pkg/reconcilers/repository/reconciler_test.go +++ b/controllers/pkg/reconcilers/repository/reconciler_test.go @@ -49,7 +49,6 @@ type repoTest struct { wantErr bool } - func TestUpsertRepo(t *testing.T) { dummyString := "Dummy String" dummyBool := true diff --git a/controllers/pkg/reconcilers/token/reconciler_test.go b/controllers/pkg/reconcilers/token/reconciler_test.go index 08b426e0..d5784307 100644 --- a/controllers/pkg/reconcilers/token/reconciler_test.go +++ b/controllers/pkg/reconcilers/token/reconciler_test.go @@ -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 { @@ -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, }, @@ -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, }, @@ -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 { @@ -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, }, @@ -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, @@ -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, }, @@ -209,4 +207,4 @@ func initMockeryMocks(tt *tokenTests) { tt.args.giteaClient = mockGiteaClient tt.fields.giteaClient = mockGiteaClient mockeryutils.InitMocks(&mockGiteaClient.Mock, tt.mocks) -} \ No newline at end of file +} diff --git a/krm-functions/lib/kptfile/v1/kptfile.go b/krm-functions/lib/kptfile/v1/kptfile.go index de3a295d..cfca309c 100644 --- a/krm-functions/lib/kptfile/v1/kptfile.go +++ b/krm-functions/lib/kptfile/v1/kptfile.go @@ -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" ) diff --git a/krm-functions/lib/kptfile/v1/kptfile_test.go b/krm-functions/lib/kptfile/v1/kptfile_test.go index f3f0c95b..307804be 100644 --- a/krm-functions/lib/kptfile/v1/kptfile_test.go +++ b/krm-functions/lib/kptfile/v1/kptfile_test.go @@ -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" ) diff --git a/operators/nephio-controller-manager/main.go b/operators/nephio-controller-manager/main.go index 8f31b4da..379d04bb 100644 --- a/operators/nephio-controller-manager/main.go +++ b/operators/nephio-controller-manager/main.go @@ -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,