mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-13 05:15:58 +02:00
[enhancement] cscli explain --labels (#2461)
* Add label support for explain and allow user to provide multiple labels
* Change my mind about empty string
* Add debug and im an idiot 😄
This commit is contained in:
parent
f02f34d64c
commit
702da0f59a
2 changed files with 16 additions and 4 deletions
|
@ -138,11 +138,13 @@ func (l *labelsMap) String() string {
|
|||
}
|
||||
|
||||
func (l labelsMap) Set(label string) error {
|
||||
split := strings.Split(label, ":")
|
||||
if len(split) != 2 {
|
||||
return errors.Wrapf(errors.New("Bad Format"), "for Label '%s'", label)
|
||||
for _, pair := range strings.Split(label, ",") {
|
||||
split := strings.Split(pair, ":")
|
||||
if len(split) != 2 {
|
||||
return fmt.Errorf("invalid format for label '%s', must be key:value", pair)
|
||||
}
|
||||
l[split[0]] = split[1]
|
||||
}
|
||||
l[split[0]] = split[1]
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue