-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] - Adding Custom Labels #1093
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,29 @@ | |
package utils | ||
|
||
import ( | ||
"errors" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
// ToMap converts a list of strings to a map | ||
func ToMap(slice []string) (map[string]string, error) { | ||
m := make(map[string]string) | ||
|
||
for _, item := range slice { | ||
if item == "" { | ||
return nil, errors.New("empty string found in slice") | ||
} | ||
items := strings.Split(item, "=") | ||
if len(items) != 2 { | ||
return nil, errors.New("invalid key=value pair found in slice") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where would these errors come out, would they be surfaced to a user? Could it be better to log and silently ignore invalid values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eekk .. too late :-D .. |
||
m[items[0]] = items[1] | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
// MaxChars returns the maximum character length of a list of strings | ||
func MaxChars(slice string, max int) string { | ||
switch { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what you mean about CLI parameter now 👍