|
@@ -9,6 +9,7 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/docker/api/types/versions"
|
|
"github.com/docker/docker/api/types/versions"
|
|
|
|
+ "github.com/pkg/errors"
|
|
)
|
|
)
|
|
|
|
|
|
// Args stores a mapping of keys to a set of multiple values.
|
|
// Args stores a mapping of keys to a set of multiple values.
|
|
@@ -97,7 +98,7 @@ func FromJSON(p string) (Args, error) {
|
|
// Fallback to parsing arguments in the legacy slice format
|
|
// Fallback to parsing arguments in the legacy slice format
|
|
deprecated := map[string][]string{}
|
|
deprecated := map[string][]string{}
|
|
if legacyErr := json.Unmarshal(raw, &deprecated); legacyErr != nil {
|
|
if legacyErr := json.Unmarshal(raw, &deprecated); legacyErr != nil {
|
|
- return args, err
|
|
|
|
|
|
+ return args, invalidFilter{errors.Wrap(err, "invalid filter")}
|
|
}
|
|
}
|
|
|
|
|
|
args.fields = deprecatedArgs(deprecated)
|
|
args.fields = deprecatedArgs(deprecated)
|
|
@@ -247,10 +248,10 @@ func (args Args) Contains(field string) bool {
|
|
return ok
|
|
return ok
|
|
}
|
|
}
|
|
|
|
|
|
-type invalidFilter string
|
|
|
|
|
|
+type invalidFilter struct{ error }
|
|
|
|
|
|
func (e invalidFilter) Error() string {
|
|
func (e invalidFilter) Error() string {
|
|
- return "Invalid filter '" + string(e) + "'"
|
|
|
|
|
|
+ return e.error.Error()
|
|
}
|
|
}
|
|
|
|
|
|
func (invalidFilter) InvalidParameter() {}
|
|
func (invalidFilter) InvalidParameter() {}
|
|
@@ -260,7 +261,7 @@ func (invalidFilter) InvalidParameter() {}
|
|
func (args Args) Validate(accepted map[string]bool) error {
|
|
func (args Args) Validate(accepted map[string]bool) error {
|
|
for name := range args.fields {
|
|
for name := range args.fields {
|
|
if !accepted[name] {
|
|
if !accepted[name] {
|
|
- return invalidFilter(name)
|
|
|
|
|
|
+ return invalidFilter{errors.New("invalid filter '" + name + "'")}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|