validate extended args in config
@@ -4,6 +4,8 @@ import (
"fmt"
"github.com/spf13/pflag"
+
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
// Apply stores the provided arguments onto a flag set, reporting any errors
@@ -13,12 +15,12 @@ func Apply(args map[string][]string, flags *pflag.FlagSet) []error {
for key, value := range args {
flag := flags.Lookup(key)
if flag == nil {
- errs = append(errs, fmt.Errorf("%q is not a valid flag", key))
+ errs = append(errs, fielderrors.NewFieldInvalid("flag", key, "is not a valid flag"))
continue
}
for _, s := range value {
if err := flag.Value.Set(s); err != nil {
- errs = append(errs, fmt.Errorf("%q could not be set: %v", err))
+ errs = append(errs, fielderrors.NewFieldInvalid(key, s, fmt.Sprintf("could not be set: %v", err)))
break
}
}
