Skip to content

Commit f38e3b2

Browse files
committed
ibmcloud: fix toList empty-whitespace handling
The toList helper did not correctly handle inputs containing empty elements or values with surrounding whitespace. Comma‑separated lists with such formatting caused parsing issues for all functions that rely on the custom types using this utility. This change adds trimming logic and skips empty items entirely, ensuring that the returned list contains only meaningful, sanitized values. Signed-off-by: Patrik Fodor <[email protected]>
1 parent fadb721 commit f38e3b2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/cloud-providers/ibmcloud/types.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,21 @@ func (i *Images) Set(value string) error {
5353
}
5454

5555
func toList(value, sep string) []string {
56+
result := make([]string, 0)
57+
5658
if len(value) == 0 {
57-
return make([]string, 0)
59+
return result
60+
}
61+
62+
splits := strings.Split(value, sep)
63+
for _, split := range splits {
64+
trimmed := strings.TrimSpace(split)
65+
if trimmed != "" {
66+
result = append(result, trimmed)
67+
}
5868
}
59-
return strings.Split(value, sep)
69+
70+
return result
6071
}
6172

6273
type tags []string

0 commit comments

Comments
 (0)