diff --git a/cmd/config/get_context_test.go b/cmd/config/get_context_test.go index 28ce64918..25573c508 100644 --- a/cmd/config/get_context_test.go +++ b/cmd/config/get_context_test.go @@ -64,7 +64,7 @@ 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", + Error: fmt.Errorf("missing configuration: context with name '%s'", missingContext), }, { diff --git a/cmd/config/get_encryption_config_test.go b/cmd/config/get_encryption_config_test.go index 36ca81b59..a10ba745c 100644 --- a/cmd/config/get_encryption_config_test.go +++ b/cmd/config/get_encryption_config_test.go @@ -45,7 +45,7 @@ func TestGetEncryptionConfigCmd(t *testing.T) { Name: "get-encryption-config-not-found", CmdLine: "foo", Cmd: cmd.NewGetEncryptionConfigCommand(emptySettings), - Error: config.ErrEncryptionConfigurationNotFound{Name: "foo"}, + Error: config.ErrEncryptionConfigurationNotFound{Name: "Encryption Config with name 'foo'"}, }, { Name: "get-encryption-config-all", diff --git a/cmd/config/get_manifest.go b/cmd/config/get_manifest.go index 5b278b202..5b823ca14 100644 --- a/cmd/config/get_manifest.go +++ b/cmd/config/get_manifest.go @@ -57,7 +57,7 @@ func NewGetManifestCommand(cfgFactory config.Factory) *cobra.Command { manifest, exists := airconfig.Manifests[o.Name] if !exists { return config.ErrMissingConfig{ - What: fmt.Sprintf("Manifest with name '%s'", o.Name), + What: fmt.Sprintf("manifest with name '%s'", o.Name), } } fmt.Fprintln(cmd.OutOrStdout(), manifest) diff --git a/cmd/config/get_manifest_test.go b/cmd/config/get_manifest_test.go index 7f78e7aff..898122c98 100644 --- a/cmd/config/get_manifest_test.go +++ b/cmd/config/get_manifest_test.go @@ -53,7 +53,7 @@ func TestGetManifestConfigCmd(t *testing.T) { Name: "missing", CmdLine: "manifestMissing", Cmd: cmd.NewGetManifestCommand(settings), - Error: fmt.Errorf("missing configuration: Manifest with name 'manifestMissing'"), + Error: fmt.Errorf("missing configuration: manifest with name 'manifestMissing'"), }, { Name: "no-manifests", diff --git a/cmd/config/set_encryption_configuration_test.go b/cmd/config/set_encryption_configuration_test.go index 49c86253b..fa48eb649 100644 --- a/cmd/config/set_encryption_configuration_test.go +++ b/cmd/config/set_encryption_configuration_test.go @@ -83,7 +83,7 @@ func TestSetEncryptionConfig(t *testing.T) { flags: []string{ "--decryption-key-path " + decryptionKeyFilePath, }, - error: fmt.Errorf("you must specify both encryption " + + error: fmt.Errorf("specify both encryption " + "and decryption keys when setting encryption config"), inputConfig: given, }, diff --git a/cmd/config/testdata/TestConfigUseContextGoldenOutput/config-use-context-does-not-exist.golden b/cmd/config/testdata/TestConfigUseContextGoldenOutput/config-use-context-does-not-exist.golden index d13b9f777..76c16fec2 100644 --- a/cmd/config/testdata/TestConfigUseContextGoldenOutput/config-use-context-does-not-exist.golden +++ b/cmd/config/testdata/TestConfigUseContextGoldenOutput/config-use-context-does-not-exist.golden @@ -1,4 +1,4 @@ -Error: Missing configuration: Context with name 'foo' +Error: missing configuration: context with name 'foo' Usage: use-context NAME [flags] diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/missing.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/missing.golden index 4c563cf06..a6e73ec04 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/missing.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/missing.golden @@ -1,4 +1,4 @@ -Error: Missing configuration: Context with name 'contextMissing' +Error: missing configuration: context with name 'contextMissing' Usage: get-context [NAME] [flags] diff --git a/cmd/config/testdata/TestGetManifestConfigCmdGoldenOutput/missing.golden b/cmd/config/testdata/TestGetManifestConfigCmdGoldenOutput/missing.golden index e549db67e..417f1b1bf 100644 --- a/cmd/config/testdata/TestGetManifestConfigCmdGoldenOutput/missing.golden +++ b/cmd/config/testdata/TestGetManifestConfigCmdGoldenOutput/missing.golden @@ -1,4 +1,4 @@ -Error: Missing configuration: Manifest with name 'manifestMissing' +Error: missing configuration: manifest with name 'manifestMissing' Usage: get-manifest NAME [flags] diff --git a/cmd/config/testdata/TestSetEncryptionConfigGoldenOutput/set-encryption-config-error-no-encryption.golden b/cmd/config/testdata/TestSetEncryptionConfigGoldenOutput/set-encryption-config-error-no-encryption.golden index 15935ad33..22e45018f 100644 --- a/cmd/config/testdata/TestSetEncryptionConfigGoldenOutput/set-encryption-config-error-no-encryption.golden +++ b/cmd/config/testdata/TestSetEncryptionConfigGoldenOutput/set-encryption-config-error-no-encryption.golden @@ -1,4 +1,4 @@ -Error: Specify both encryption and decryption keys when setting encryption config +Error: specify both encryption and decryption keys when setting encryption config Usage: set-encryption-config NAME [flags] diff --git a/pkg/config/config.go b/pkg/config/config.go index 0f998eb10..dd1da132c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -249,7 +249,7 @@ func (c *Config) SetLoadedConfigPath(lcp string) { func (c *Config) GetContext(cName string) (*Context, error) { context, exists := c.Contexts[cName] if !exists { - return nil, ErrMissingConfig{What: fmt.Sprintf("Context with name '%s'", cName)} + return nil, ErrMissingConfig{What: fmt.Sprintf("context with name '%s'", cName)} } return context, nil } @@ -539,7 +539,7 @@ func (c *Config) CurrentContextManagementConfig() (*ManagementConfiguration, err if currentContext.ManagementConfiguration == "" { return nil, ErrMissingConfig{ - What: fmt.Sprintf("No management config listed for cluster %s", currentContext.NameInKubeconf), + What: fmt.Sprintf("no management config listed for cluster %s", currentContext.NameInKubeconf), } } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 21018d457..211334357 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -402,7 +402,7 @@ func TestCurrentContextManifestMetadata(t *testing.T) { }, { name: "no such file or directory", - metaPath: "does not exist", + metaPath: "doesn't exist", currentContext: "testContext", expectErr: true, errorChecker: os.IsNotExist, @@ -412,7 +412,7 @@ func TestCurrentContextManifestMetadata(t *testing.T) { currentContext: "doesn't exist", expectErr: true, errorChecker: func(err error) bool { - return strings.Contains(err.Error(), "Missing configuration") + return strings.Contains(err.Error(), "missing configuration") }, }, } diff --git a/pkg/config/errors.go b/pkg/config/errors.go index 90cf9098c..979a7ea21 100644 --- a/pkg/config/errors.go +++ b/pkg/config/errors.go @@ -123,7 +123,7 @@ type ErrMissingConfig struct { } func (e ErrMissingConfig) Error() string { - return "Missing configuration: " + e.What + return "missing configuration: " + e.What } // ErrConfigFailed returned in case of failure during configuration @@ -195,7 +195,7 @@ type ErrConflictingAuthOptions struct { } func (e ErrConflictingAuthOptions) Error() string { - return "Specifying token and username/password is not allowed at the same time." + return "specifying token and username/password is not allowed at the same time." } // ErrConflictingClusterOptions returned when both certificate-authority and @@ -204,7 +204,7 @@ type ErrConflictingClusterOptions struct { } func (e ErrConflictingClusterOptions) Error() string { - return "Specifying certificate-authority and insecure-skip-tls-verify mode is not allowed at the same time." + return "specifying certificate-authority and insecure-skip-tls-verify mode is not allowed at the same time." } // ErrConflictingContextOptions returned when both context and --current is set at same time @@ -212,7 +212,7 @@ type ErrConflictingContextOptions struct { } func (e ErrConflictingContextOptions) Error() string { - return "Specifying context and --current Flag is not allowed at the same time." + return "specifying context and --current Flag is not allowed at the same time." } // ErrEmptyContextName returned when empty context name is set @@ -220,7 +220,7 @@ type ErrEmptyContextName struct { } func (e ErrEmptyContextName) Error() string { - return "Context name must not be empty." + return "context name must not be empty." } // ErrDecodingCredentials returned when the given string cannot be decoded @@ -265,7 +265,7 @@ type ErrMutuallyExclusiveEncryptionConfigType struct { } func (e ErrMutuallyExclusiveEncryptionConfigType) Error() string { - return "Specify mutually exclusive encryption config sources, use either: " + + return "specify mutually exclusive encryption config sources, use either: " + "--decryption-key-path/--decryption-key-path or --secret-name/--secret-namespace." } @@ -275,7 +275,7 @@ type ErrInvalidEncryptionKeyPath struct { } func (e ErrInvalidEncryptionKeyPath) Error() string { - return "Specify both encryption and decryption keys when setting encryption config" + return "specify both encryption and decryption keys when setting encryption config" } // ErrInvalidEncryptionKey is returned when encryption config specifies only one of @@ -284,7 +284,7 @@ type ErrInvalidEncryptionKey struct { } func (e ErrInvalidEncryptionKey) Error() string { - return "Specify both secret name and namespace when setting encryption config" + return "specify both secret name and namespace when setting encryption config" } // ErrMissingFlag is returned when flag is not provided diff --git a/pkg/inventory/inventory_test.go b/pkg/inventory/inventory_test.go index 2914dea0e..e192f1b46 100644 --- a/pkg/inventory/inventory_test.go +++ b/pkg/inventory/inventory_test.go @@ -51,7 +51,7 @@ func TestBaremetalInventory(t *testing.T) { }, { name: "error no manifest defined", - errString: "Missing configuration: manifest named", + errString: "missing configuration: manifest named", factory: func() (*config.Config, error) { cfg := config.NewConfig() diff --git a/pkg/phase/command_test.go b/pkg/phase/command_test.go index dfbcd84b6..39b93e93a 100644 --- a/pkg/phase/command_test.go +++ b/pkg/phase/command_test.go @@ -29,7 +29,7 @@ import ( const ( testFactoryErr = "test config error" - testNewHelperErr = "Missing configuration" + testNewHelperErr = "missing configuration" testNoBundlePath = "no such file or directory" defaultCurrentContext = "context" ) @@ -317,7 +317,7 @@ func TestPlanRunCommand(t *testing.T) { Contexts: make(map[string]*config.Context), }, nil }, - expectedErr: "Missing configuration: Context with name 'does not exist'", + expectedErr: "missing configuration: context with name 'does not exist'", }, { name: "Error phase by id", @@ -391,7 +391,7 @@ func TestClusterListCommand_RunE(t *testing.T) { Contexts: make(map[string]*config.Context), }, nil }, - expectedErr: "Missing configuration: Context with name 'does not exist'", + expectedErr: "missing configuration: context with name 'does not exist'", }, { name: "No error", diff --git a/testutil/utilities.go b/testutil/utilities.go index 5b4ab8a42..4618d0491 100644 --- a/testutil/utilities.go +++ b/testutil/utilities.go @@ -104,6 +104,7 @@ func checkError(t *testing.T, actual, expected error) { require.NoError(t, actual) } else { require.Error(t, actual) + require.Equal(t, expected.Error(), actual.Error()) } }