From 4e28292abf613c44fa23d309fe5326eab2e8f5e6 Mon Sep 17 00:00:00 2001 From: Conor Murray Date: Fri, 12 May 2023 15:28:38 +0100 Subject: [PATCH] (FFM-7832) Cleanup goreport issues (#149) * (MAINT) Fix goreport typos * (FFM-7832) Fix goreport issues --- cache/wrapper.go | 11 +++++++---- cmd/ff-proxy/main.go | 2 +- cmd/offline-data-gen/README.md | 2 +- cmd/offline-data-gen/main.go | 2 +- file_decoder.go | 2 +- repository/target_repo_test.go | 2 +- services/admin_service.go | 6 +++--- tests/e2e/metrics_test.go | 4 ++++ tests/e2e/segments_test.go | 6 ++++-- tests/e2e/setup_test.go | 2 +- tests/e2e/testhelpers/environment.go | 4 ++++ tests/e2e/testhelpers/project.go | 4 ++++ transport/endpoints.go | 4 ++-- transport/http_server_test.go | 2 +- 14 files changed, 35 insertions(+), 18 deletions(-) diff --git a/cache/wrapper.go b/cache/wrapper.go index 5c342b7c..53311d75 100644 --- a/cache/wrapper.go +++ b/cache/wrapper.go @@ -21,10 +21,13 @@ import ( // e.g. // // some-key-1 -// field-1: foobar -// field-2: fizzbuzz +// +// field-1: foobar +// field-2: fizzbuzz +// // some-key-2 -// field-1: hello-world +// +// field-1: hello-world type Cache interface { // Set sets a value in the cache for a given key and field Set(ctx context.Context, key string, field string, value encoding.BinaryMarshaler) error @@ -34,7 +37,7 @@ type Cache interface { Get(ctx context.Context, key string, field string, v encoding.BinaryUnmarshaler) error // GetByte gets the value of a field for a given key GetByte(ctx context.Context, key string, field string) ([]byte, error) - // GetAll gets all of the fiels and their values for a given key + // GetAll gets all the fields and their values for a given key GetAll(ctx context.Context, key string) (map[string][]byte, error) // RemoveAll removes all the fields and their values for a given key RemoveAll(ctx context.Context, key string) diff --git a/cmd/ff-proxy/main.go b/cmd/ff-proxy/main.go index 6ccd8487..7edb770e 100644 --- a/cmd/ff-proxy/main.go +++ b/cmd/ff-proxy/main.go @@ -70,7 +70,7 @@ func (s *sdkClientMap) copy() map[string]*harness.CfClient { return s.m } -// keys implements the flag.Value interface and allows us to pass a comma seperated +// keys implements the flag.Value interface and allows us to pass a comma separated // list of api keys e.g. -api-keys 123,456,789 type keys []string diff --git a/cmd/offline-data-gen/README.md b/cmd/offline-data-gen/README.md index a3e9cf3e..f31fad15 100644 --- a/cmd/offline-data-gen/README.md +++ b/cmd/offline-data-gen/README.md @@ -7,7 +7,7 @@ Usage of ./offline-data-gen: -environments int the number of environments to generate (default 2) -factor int - the factor to apply to the number of features, segments and targets for each environmnet that's created (default 2) + the factor to apply to the number of features, segments and targets for each environment that's created (default 2) -features int baseline number of features to generate (default 1) -segments int diff --git a/cmd/offline-data-gen/main.go b/cmd/offline-data-gen/main.go index b9c7c766..673f82a1 100644 --- a/cmd/offline-data-gen/main.go +++ b/cmd/offline-data-gen/main.go @@ -23,7 +23,7 @@ var ( func init() { flag.IntVar(&numEnvironments, "environments", 2, "the number of environments to generate") - flag.IntVar(&factor, "factor", 2, "the factor to apply to the number of features, segments and targets for each environmnet that's created") + flag.IntVar(&factor, "factor", 2, "the factor to apply to the number of features, segments and targets for each environment that's created") flag.IntVar(&features, "features", 1, "baseline number of features to generate") flag.IntVar(&segments, "segments", 1, "baseline number of segments to generate") flag.IntVar(&targets, "targets", 1, "baseline number of targets to generate") diff --git a/file_decoder.go b/file_decoder.go index 06e4467b..15976bfa 100644 --- a/file_decoder.go +++ b/file_decoder.go @@ -17,7 +17,7 @@ const ( extensionYAML = ".yaml" ) -// DecodeFile is a convienence function that creates a FileDecoder and calls Decode +// DecodeFile is a convenience function that creates a FileDecoder and calls Decode func DecodeFile(fileSystem fs.FS, path string, v interface{}) error { dec, err := NewFileDecoder(fileSystem, path) if err != nil { diff --git a/repository/target_repo_test.go b/repository/target_repo_test.go index c6494107..de8f812f 100644 --- a/repository/target_repo_test.go +++ b/repository/target_repo_test.go @@ -46,7 +46,7 @@ func (m *mockCache) GetByte(ctx context.Context, key string, field string) ([]by return m.getByte() } -// GetAll gets all of the fiels and their values for a given key +// GetAll gets all the fields and their values for a given key func (m *mockCache) GetAll(ctx context.Context, key string) (map[string][]byte, error) { return m.getAll() } diff --git a/services/admin_service.go b/services/admin_service.go index 84d50106..df139f3e 100644 --- a/services/admin_service.go +++ b/services/admin_service.go @@ -43,7 +43,7 @@ func NewAdminService(l log.Logger, addr string, serviceToken string) (AdminServi return AdminService{log: l, client: c}, nil } -// PageAPIKeysInput contains the paramters required to make a GetEnvironments +// PageAPIKeysInput contains the parameters required to make a GetEnvironments // request type PageAPIKeysInput struct { AccountIdentifier string @@ -97,7 +97,7 @@ func (r AdminService) PageAPIKeys(ctx context.Context, input PageAPIKeysInput) ( }, nil } -// PageTargetsInput contains the paramters required to make a PageTargets +// PageTargetsInput contains the parameters required to make a PageTargets // request type PageTargetsInput struct { AccountIdentifier string @@ -108,7 +108,7 @@ type PageTargetsInput struct { PageSize int } -// PageTargetsResult contains the paramters required to make a PageTargets +// PageTargetsResult contains the parameters required to make a PageTargets // request type PageTargetsResult struct { Targets []admingen.Target diff --git a/tests/e2e/metrics_test.go b/tests/e2e/metrics_test.go index 025b0889..ff135321 100644 --- a/tests/e2e/metrics_test.go +++ b/tests/e2e/metrics_test.go @@ -167,6 +167,10 @@ func getFeatureFlag(identifier string, environment string) (*admin.Feature, erro req.Header.Set("x-api-key", GetUserAccessToken()) return nil }) + if err != nil { + log.Error(err) + return nil, err + } flagResponse, err := admin.ParseGetFeatureFlagResponse(response) if err != nil { diff --git a/tests/e2e/segments_test.go b/tests/e2e/segments_test.go index 2f55c79d..0283fdd7 100644 --- a/tests/e2e/segments_test.go +++ b/tests/e2e/segments_test.go @@ -6,9 +6,8 @@ import ( "net/http" "testing" - "github.com/harness/ff-proxy/tests/e2e/testhelpers" - "github.com/harness/ff-proxy/gen/client" + "github.com/harness/ff-proxy/tests/e2e/testhelpers" "github.com/stretchr/testify/assert" ) @@ -90,6 +89,9 @@ func TestTargetSegments(t *testing.T) { } got, err := GetAllSegments(t, envID, token) + if err != nil { + t.Error(err) + } // Assert the response assert.NotNil(t, got) assert.Equal(t, tt.want.StatusCode, got.StatusCode(), "expected http status code %d but got %d", tt.want.StatusCode, got.StatusCode()) diff --git a/tests/e2e/setup_test.go b/tests/e2e/setup_test.go index 1936b415..8fbb0f04 100644 --- a/tests/e2e/setup_test.go +++ b/tests/e2e/setup_test.go @@ -18,7 +18,7 @@ func TestMain(m *testing.M) { os.Exit(exitVal) } -// TestSetup performs setup before a test. This includes initalizing logging, and working +// TestSetup performs setup before a test. This includes initializing logging, and working // out how to authenticate with the platform func Setup() { log.Infof("Global Test Setup") diff --git a/tests/e2e/testhelpers/environment.go b/tests/e2e/testhelpers/environment.go index e9c4e090..710e0b7d 100644 --- a/tests/e2e/testhelpers/environment.go +++ b/tests/e2e/testhelpers/environment.go @@ -52,6 +52,10 @@ func CreateEnvironmentRemote(projectIdentifier string, environment, environmentN req.Header.Set("content-type", "application/json") AddAuthToken(context.Background(), req) res, err := client.Client.Do(req) + if err != nil { + log.Error(err) + return nil, err + } // ensure environment is created within cf err = retry.Do( diff --git a/tests/e2e/testhelpers/project.go b/tests/e2e/testhelpers/project.go index c199621b..5f757446 100644 --- a/tests/e2e/testhelpers/project.go +++ b/tests/e2e/testhelpers/project.go @@ -256,6 +256,10 @@ func CreateProjectRemote(identifier string) (*http.Response, error) { req.Header.Set("content-type", "application/json") AddAuthToken(context.Background(), req) res, err := client.Client.Do(req) + if err != nil { + log.Error(err) + return nil, err + } // ensure project is created within cf err = retry.Do( diff --git a/transport/endpoints.go b/transport/endpoints.go index 5440baff..25fb5e99 100644 --- a/transport/endpoints.go +++ b/transport/endpoints.go @@ -22,7 +22,7 @@ type Endpoints struct { Health endpoint.Endpoint } -// NewEndpoints returns an initalised Endpoints where each endpoint invokes the +// NewEndpoints returns an initialised Endpoints where each endpoint invokes the // corresponding method on the passed ProxyService func NewEndpoints(p proxyservice.ProxyService) *Endpoints { return &Endpoints{ @@ -55,7 +55,7 @@ func makePostAuthenticateEndpoint(s proxyservice.ProxyService) endpoint.Endpoint // makeGetFeatureConfigsEndpoint is a function to convert a services GetFeatureConfig // method to an endpoint func makeGetFeatureConfigsEndpoint(s proxyservice.ProxyService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (repsonse interface{}, err error) { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { req := request.(domain.FeatureConfigRequest) featureConfigs, err := s.FeatureConfig(ctx, req) if err != nil { diff --git a/transport/http_server_test.go b/transport/http_server_test.go index b79727ee..7fe5ac68 100644 --- a/transport/http_server_test.go +++ b/transport/http_server_test.go @@ -1497,7 +1497,7 @@ func TestHTTPServer_StreamIntegration(t *testing.T) { } cancel() - t.Logf("Then %s will recieve the event(s)", key) + t.Logf("Then %s will receive the event(s)", key) assert.ElementsMatch(t, tc.expectedEvents, actualEvents) }