-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(serviceaccount): add service account input validation #512
Conversation
36d5a92
to
d2a5171
Compare
f4a3e21
to
5d41de5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put exact args to be zero for this command, it can be bit confusing
@@ -199,7 +210,7 @@ func runInteractivePrompt(opts *Options) (err error) { | |||
Help: localizer.MustLocalizeFromID("serviceAccount.create.input.name.help"), | |||
} | |||
|
|||
err = survey.AskOne(promptName, &opts.name, survey.WithValidator(survey.Required)) | |||
err = survey.AskOne(promptName, &opts.name, survey.WithValidator(survey.Required), survey.WithValidator(validation.ValidateDescription)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err = survey.AskOne(promptName, &opts.name, survey.WithValidator(survey.Required), survey.WithValidator(validation.ValidateDescription)) | |
err = survey.AskOne(promptName, &opts.name, survey.WithValidator(survey.Required), survey.WithValidator(validation.ValidateName)) |
Sure, what was confusing about it? Was it something related to this code change? |
Nothing related to these changes. I tried doing something like |
Hmm, since it is so small, I will apply it now. |
b1856d8
to
13a3080
Compare
36dc67b
to
ec76591
Compare
@craicoverflow would this PR also solve this: #515 or this is separate? |
Separate. |
@@ -50,7 +52,8 @@ func NewCreateCommand(f *factory.Factory) *cobra.Command { | |||
Short: localizer.MustLocalizeFromID("serviceAccount.create.cmd.shortDescription"), | |||
Long: localizer.MustLocalizeFromID("serviceAccount.create.cmd.longDescription"), | |||
Example: localizer.MustLocalizeFromID("serviceAccount.create.cmd.example"), | |||
RunE: func(cmd *cobra.Command, _ []string) error { | |||
Args: cobra.NoArgs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change cobra.ExactArgs(0)
to cobra.NoArgs
throughout the app in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. thanks!
Description
fixes #505
Verification Steps
Run
rhoas serviceaccount create
commands and enter various values from the rules below to test validation on name and description fields. Do this in both flags and interactive prompt.Name
Description
Type of change
Checklist