[#455] Fix non-informative message when parse node attributes
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
All checks were successful
ci/woodpecker/push/pre-commit Pipeline was successful
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
d0ab552a90
commit
d01c064674
1 changed files with 3 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
||||||
package attributes
|
package attributes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ func ReadNodeAttributes(dst *netmap.NodeInfo, attrs []string) error {
|
||||||
|
|
||||||
k, v, found := strings.Cut(line, keyValueSeparator)
|
k, v, found := strings.Cut(line, keyValueSeparator)
|
||||||
if !found {
|
if !found {
|
||||||
return errors.New("missing attribute key and/or value")
|
return fmt.Errorf("wrong format for node attribute: '%s'", attrs[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok := cache[k]
|
_, ok := cache[k]
|
||||||
|
@ -36,9 +35,9 @@ func ReadNodeAttributes(dst *netmap.NodeInfo, attrs []string) error {
|
||||||
v = replaceEscaping(v, true)
|
v = replaceEscaping(v, true)
|
||||||
|
|
||||||
if k == "" {
|
if k == "" {
|
||||||
return errors.New("empty key")
|
return fmt.Errorf("empty key in node attribute: '%s'", attrs[i])
|
||||||
} else if v == "" {
|
} else if v == "" {
|
||||||
return errors.New("empty value")
|
return fmt.Errorf("empty value in node attribute: '%s'", attrs[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.SetAttribute(k, v)
|
dst.SetAttribute(k, v)
|
||||||
|
|
Loading…
Reference in a new issue