Skip to content

Commit

Permalink
fix(serviceaccount): fix invalid i18n message (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enda authored Mar 29, 2021
1 parent 44738ee commit bb1d9b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (e *Error) Unwrap() error {
return e.Err
}

// InvalidValueError returns an error when an invalid flag value is provided
func InvalidValueError(flag string, val interface{}, validOptions ...string) *Error {
var chooseFromStr string
if len(validOptions) > 0 {
Expand Down
9 changes: 2 additions & 7 deletions pkg/cmd/serviceaccount/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/bf2fc6cc711aee1a0c2a/cli/internal/config"
"github.com/bf2fc6cc711aee1a0c2a/cli/internal/localizer"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/cmd/factory"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/cmd/flag"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/logging"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -73,13 +74,7 @@ func NewCreateCommand(f *factory.Factory) *cobra.Command {
// check that a valid --file-format flag value is used
validOutput := flagutil.IsValidInput(opts.fileFormat, flagutil.CredentialsOutputFormats...)
if !validOutput && opts.fileFormat != "" {
return fmt.Errorf(localizer.MustLocalize(&localizer.Config{
MessageID: "flag.error.invalidValue",
TemplateData: map[string]interface{}{
"Flag": "file-format",
"Value": opts.fileFormat,
},
}))
return flag.InvalidValueError("file-format", opts.fileFormat, flagutil.CredentialsOutputFormats...)
}

return runCreate(opts)
Expand Down
9 changes: 2 additions & 7 deletions pkg/cmd/serviceaccount/resetcredentials/reset_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/bf2fc6cc711aee1a0c2a/cli/internal/config"
"github.com/bf2fc6cc711aee1a0c2a/cli/internal/localizer"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/cmd/factory"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/cmd/flag"
"github.com/bf2fc6cc711aee1a0c2a/cli/pkg/logging"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -72,13 +73,7 @@ func NewResetCredentialsCommand(f *factory.Factory) *cobra.Command {

validOutput := flagutil.IsValidInput(opts.fileFormat, flagutil.CredentialsOutputFormats...)
if !validOutput && opts.fileFormat != "" {
return fmt.Errorf(localizer.MustLocalize(&localizer.Config{
MessageID: "flag.error.invalidValue",
TemplateData: map[string]interface{}{
"Flag": "file-format",
"Value": opts.fileFormat,
},
}))
return flag.InvalidValueError("file-format", opts.fileFormat, flagutil.CredentialsOutputFormats...)
}

return runResetCredentials(opts)
Expand Down

0 comments on commit bb1d9b4

Please sign in to comment.