Change validation to use field.Path and field.ErrorList
@@ -5,7 +5,7 @@ import (
"github.com/spf13/pflag"
- "k8s.io/kubernetes/pkg/util/fielderrors"
+ "k8s.io/kubernetes/pkg/util/validation/field"
)
// Apply stores the provided arguments onto a flag set, reporting any errors
@@ -15,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, fielderrors.NewFieldInvalid("flag", key, "is not a valid flag"))
+ errs = append(errs, field.Invalid(field.NewPath("flag"), key, "is not a valid flag"))
continue
}
for _, s := range value {
if err := flag.Value.Set(s); err != nil {
- errs = append(errs, fielderrors.NewFieldInvalid(key, s, fmt.Sprintf("could not be set: %v", err)))
+ errs = append(errs, field.Invalid(field.NewPath(key), s, fmt.Sprintf("could not be set: %v", err)))
break
}
}
