Skip to content

Commit 8cfc6ff

Browse files
committed
fix(targets): make tag subcommand deny empty tags
Signed-off-by: Eric Bode <[email protected]>
1 parent 1d2d763 commit 8cfc6ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subcommands/targets/tag.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
)
2121

2222
func init() {
23-
var tagCmd = &cobra.Command{
23+
tagCmd := &cobra.Command{
2424
Use: "tag <target> [<target>...]",
2525
Short: "Apply a comma separated list of tags to one or more Targets.",
2626
Example: `
@@ -78,6 +78,8 @@ func doTag(cmd *cobra.Command, args []string) {
7878
targetTags := tags
7979
if tagAppend {
8080
targetTags = Set(custom.Tags, tags)
81+
} else if len(targetTags) == 0 {
82+
subcommands.DieNotNil(fmt.Errorf("Cannot change tags from %s -> %s. Empty values are not allowed.", custom.Tags, targetTags))
8183
}
8284
updates[name] = client.UpdateTarget{
8385
Custom: client.TufCustom{Tags: targetTags},
@@ -98,6 +100,8 @@ func doTag(cmd *cobra.Command, args []string) {
98100
targetTags := tags
99101
if tagAppend {
100102
targetTags = Set(custom.Tags, tags)
103+
} else if len(targetTags) == 0 {
104+
subcommands.DieNotNil(fmt.Errorf("Cannot change tags from %s -> %s. Empty values are not allowed.", custom.Tags, targetTags))
101105
}
102106
updates[name] = client.UpdateTarget{
103107
Custom: client.TufCustom{Tags: targetTags},

0 commit comments

Comments
 (0)