Skip to content

Commit 992c231

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

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

subcommands/targets/tag.go

+4-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: `
@@ -57,6 +57,9 @@ func Set(a, b []string) []string {
5757
func doTag(cmd *cobra.Command, args []string) {
5858
factory := viper.GetString("factory")
5959
tags := strings.Split(tagTags, ",")
60+
if !tagAppend && len(tags) == 0 {
61+
subcommands.DieNotNil(fmt.Errorf("Tags list cannot be empty when setting tags"))
62+
}
6063

6164
// Make sure all tags are unique, no accidental repeats/typos
6265
if len(tags) != len(Set(tags, nil)) {

0 commit comments

Comments
 (0)