File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 99 "time"
1010
1111 "github.com/litmuschaos/litmus-go/pkg/cerrors"
12+ "github.com/litmuschaos/litmus-go/pkg/log"
1213 "github.com/litmuschaos/litmus-go/pkg/utils/stringutils"
1314
1415 "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
@@ -170,20 +171,27 @@ func GetTargets(targets string) []AppDetails {
170171 }
171172 t := strings .Split (targets , ";" )
172173 for _ , k := range t {
173- val := strings .Split (strings .TrimSpace (k ), ":" )
174+ trimmed := strings .TrimSpace (k )
175+ if trimmed == "" {
176+ continue
177+ }
178+ val := strings .Split (trimmed , ":" )
179+ if len (val ) < 3 {
180+ log .Fatalf ("invalid TARGETS entry %q: expected format kind:namespace:[labels|names][:mode]" , trimmed )
181+ }
174182 data := AppDetails {
175183 Kind : val [0 ],
176184 Namespace : val [1 ],
177185 LabelMatchMode : "union" ,
178186 }
179-
187+
180188 if len (val ) > 3 {
181189 mode := strings .TrimSpace (val [3 ])
182190 if mode == "intersection" || mode == "union" {
183191 data .LabelMatchMode = mode
184192 }
185193 }
186-
194+
187195 if strings .Contains (val [2 ], "=" ) {
188196 data .Labels = parse (val [2 ])
189197 } else {
You can’t perform that action at this time.
0 commit comments