Merge pull request #1528 from jessvalarezo/labels-validate

Labels are consistently validated across services.
This commit is contained in:
Stephen Day
2017-09-22 10:33:17 -07:00
committed by GitHub
19 changed files with 189 additions and 8 deletions

View File

@@ -108,10 +108,16 @@ var imagesSetLabelsCommand = cli.Command{
Usage: "set and clear labels for an image.",
ArgsUsage: "[flags] <name> [<key>=<value>, ...]",
Description: "Set and clear labels for an image.",
Flags: []cli.Flag{},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "replace-all, r",
Usage: "replace all labels",
},
},
Action: func(clicontext *cli.Context) error {
var (
ctx, cancel = appContext(clicontext)
replaceAll = clicontext.Bool("replace-all")
name, labels = objectWithLabelArgs(clicontext)
)
defer cancel()
@@ -131,7 +137,11 @@ var imagesSetLabelsCommand = cli.Command{
)
for k := range labels {
fieldpaths = append(fieldpaths, strings.Join([]string{"labels", k}, "."))
if replaceAll {
fieldpaths = append(fieldpaths, "labels")
} else {
fieldpaths = append(fieldpaths, strings.Join([]string{"labels", k}, "."))
}
}
image := images.Image{