diff --git a/.golangci.yaml b/.golangci.yaml index f1c85496b..8110f7dd8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -210,3 +210,4 @@ linters: - unused # Checks Go code for unused constants, variables, functions and types - varcheck # Finds unused global variables and constants - whitespace # Tool for detection of leading and trailing whitespace NOTE(howell): This linter does _not_ check for trailing whitespace in multiline strings + - golint # Finds all coding style mistakes diff --git a/cmd/config/get_context_test.go b/cmd/config/get_context_test.go index 17208dd8f..d5b50adbd 100644 --- a/cmd/config/get_context_test.go +++ b/cmd/config/get_context_test.go @@ -69,8 +69,8 @@ func TestGetContextCmd(t *testing.T) { Name: "missing", CmdLine: fmt.Sprintf("%s", missingContext), Cmd: cmd.NewGetContextCommand(settings), - Error: fmt.Errorf(`Context %s information was not -found in the configuration.`, missingContext), + Error: fmt.Errorf("context %s information was not found in the configuration", + missingContext), }, { Name: "get-current-context", diff --git a/pkg/document/plugin/replacement/v1alpha1/errors.go b/pkg/document/plugin/replacement/v1alpha1/errors.go index fda854a2d..5e433d4fe 100644 --- a/pkg/document/plugin/replacement/v1alpha1/errors.go +++ b/pkg/document/plugin/replacement/v1alpha1/errors.go @@ -56,7 +56,7 @@ func (e ErrMultipleResources) Error() string { return fmt.Sprintf("found more than one resources matching from %v", e.ResList) } -// ErrResourceNotFound returned if a replacement source resource does not exist in resource map +// ErrSourceNotFound returned if a replacement source resource does not exist in resource map type ErrSourceNotFound struct { ObjRef *types.Target } @@ -74,7 +74,7 @@ func (e ErrSourceNotFound) Error() string { return fmt.Sprintf("failed to find any source resources identified by %s", strings.TrimSpace(resFilter)) } -// ErrSelectorNotFound returned if a replacement target resource does not exist in the resource map +// ErrTargetNotFound returned if a replacement target resource does not exist in the resource map type ErrTargetNotFound struct { ObjRef *types.Selector } diff --git a/pkg/environment/settings.go b/pkg/environment/settings.go index f9e1fa894..b50bc94ac 100644 --- a/pkg/environment/settings.go +++ b/pkg/environment/settings.go @@ -138,6 +138,7 @@ func initPluginPath() { pluginPath = filepath.Join(homeDir, config.AirshipConfigDir, config.AirshipPluginPath) } +// PluginPath returns the kustomize plugin path func PluginPath() string { pluginPathLock.Lock() defer pluginPathLock.Unlock() diff --git a/pkg/k8s/kubectl/apply_options_test.go b/pkg/k8s/kubectl/apply_options_test.go index ab92ed7aa..59302e212 100644 --- a/pkg/k8s/kubectl/apply_options_test.go +++ b/pkg/k8s/kubectl/apply_options_test.go @@ -30,12 +30,12 @@ import ( var ( filenameRC = "testdata/replicationcontroller.yaml" - testStreams = genericclioptions.NewTestIOStreamsDiscard() - ToDiscoveryError = errors.New("ToDiscoveryError") - DynamicClientError = errors.New("DynamicClientError") - ValidateError = errors.New("ValidateError") - ToRESTMapperError = errors.New("ToRESTMapperError") - NamespaceError = errors.New("NamespaceError") + testStreams = genericclioptions.NewTestIOStreamsDiscard() + ErrToDiscoveryError = errors.New("ErrToDiscoveryError") + ErrDynamicClientError = errors.New("ErrDynamicClientError") + ErrValidateError = errors.New("ErrValidateError") + ErrToRESTMapperError = errors.New("ErrToRESTMapperError") + ErrNamespaceError = errors.New("ErrNamespaceError") ) func TestApplyOptionsRun(t *testing.T) { @@ -57,27 +57,27 @@ func TestNewApplyOptionsFactoryFailures(t *testing.T) { expectedError error }{ { - f: k8stest.NewMockKubectlFactory().WithToDiscoveryClientByError(nil, ToDiscoveryError), - expectedError: ToDiscoveryError, + f: k8stest.NewMockKubectlFactory().WithToDiscoveryClientByError(nil, ErrToDiscoveryError), + expectedError: ErrToDiscoveryError, }, { - f: k8stest.NewMockKubectlFactory().WithDynamicClientByError(nil, DynamicClientError), - expectedError: DynamicClientError, + f: k8stest.NewMockKubectlFactory().WithDynamicClientByError(nil, ErrDynamicClientError), + expectedError: ErrDynamicClientError, }, { - f: k8stest.NewMockKubectlFactory().WithValidatorByError(nil, ValidateError), - expectedError: ValidateError, + f: k8stest.NewMockKubectlFactory().WithValidatorByError(nil, ErrValidateError), + expectedError: ErrValidateError, }, { - f: k8stest.NewMockKubectlFactory().WithToRESTMapperByError(nil, ToRESTMapperError), - expectedError: ToRESTMapperError, + f: k8stest.NewMockKubectlFactory().WithToRESTMapperByError(nil, ErrToRESTMapperError), + expectedError: ErrToRESTMapperError, }, { f: k8stest.NewMockKubectlFactory(). WithToRawKubeConfigLoaderByError(k8stest. NewMockClientConfig(). - WithNamespace("", false, NamespaceError)), - expectedError: NamespaceError, + WithNamespace("", false, ErrNamespaceError)), + expectedError: ErrNamespaceError, }, } for _, test := range tests { diff --git a/pkg/k8s/kubectl/kubectl_test.go b/pkg/k8s/kubectl/kubectl_test.go index b5fb3f353..cfed67595 100644 --- a/pkg/k8s/kubectl/kubectl_test.go +++ b/pkg/k8s/kubectl/kubectl_test.go @@ -32,8 +32,8 @@ var ( kubeconfigPath = "testdata/kubeconfig.yaml" fixtureDir = "testdata/" - writeOutError = errors.New("writeOutError") - TempFileError = errors.New("TempFileError") + ErrWriteOutError = errors.New("ErrWriteOutError") + ErrTempFileError = errors.New("ErrTempFileError") ) type MockFileSystem struct { @@ -99,17 +99,17 @@ func TestApply(t *testing.T) { }, }, { - expectedErr: writeOutError, + expectedErr: ErrWriteOutError, fs: MockFileSystem{ - MockTempFile: func() (document.File, error) { return nil, writeOutError }}, + MockTempFile: func() (document.File, error) { return nil, ErrWriteOutError }}, }, { - expectedErr: TempFileError, + expectedErr: ErrTempFileError, fs: MockFileSystem{ MockRemoveAll: func() error { return nil }, MockTempFile: func() (document.File, error) { return TestFile{ - MockWrite: func() (int, error) { return 0, TempFileError }, + MockWrite: func() (int, error) { return 0, ErrTempFileError }, MockName: func() string { return filenameRC }, MockClose: func() error { return nil }, }, nil diff --git a/pkg/phase/apply/apply_test.go b/pkg/phase/apply/apply_test.go index e07d802cd..ce92082c2 100644 --- a/pkg/phase/apply/apply_test.go +++ b/pkg/phase/apply/apply_test.go @@ -37,7 +37,7 @@ const ( ) var ( - DynamicClientError = errors.New("DynamicClientError") + ErrDynamicClientError = errors.New("ErrDynamicClientError") ) func TestDeploy(t *testing.T) { @@ -62,8 +62,8 @@ func TestDeploy(t *testing.T) { client: fake.NewClient(fake.WithKubectl( kubectl.NewKubectl(k8sutils. NewMockKubectlFactory(). - WithDynamicClientByError(nil, DynamicClientError)))), - expectedError: DynamicClientError, + WithDynamicClientByError(nil, ErrDynamicClientError)))), + expectedError: ErrDynamicClientError, }, { expectedError: nil,