Define NoOptDefVal for validate flag
validate flag does not have default value defined when there is no parameter passed, therefore it tries to use next irrelevant flag. This PR defines NoOptDefVal for validate flag which is set "strict". Kubernetes-commit: 0245e74590a658ea911f1e5cacd270960883af2d
This commit is contained in:
parent
426a252525
commit
aa46caeecd
|
@ -407,6 +407,8 @@ func AddValidateFlags(cmd *cobra.Command) {
|
|||
"warn" will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as "ignore" otherwise.
|
||||
"false" or "ignore" will not perform any schema validation, silently dropping any unknown or duplicate fields.`,
|
||||
)
|
||||
|
||||
cmd.Flags().Lookup("validate").NoOptDefVal = "strict"
|
||||
}
|
||||
|
||||
func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string) {
|
||||
|
@ -584,6 +586,8 @@ func GetValidationDirective(cmd *cobra.Command) (string, error) {
|
|||
b, err := strconv.ParseBool(validateFlag)
|
||||
if err != nil {
|
||||
switch validateFlag {
|
||||
case "":
|
||||
return metav1.FieldValidationStrict, nil
|
||||
case cmd.Flag("validate").NoOptDefVal:
|
||||
return metav1.FieldValidationStrict, nil
|
||||
case "strict":
|
||||
|
|
Loading…
Reference in New Issue