aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-02-02 10:15:19 +0100
committerGitHub <noreply@github.com>2022-02-02 10:15:19 +0100
commit14fd08d0a0615d2b64e5432e0105e225832e2085 (patch)
treeaf818653417afc762a6a89bb41cb19696eb1d287 /client
parent1685d933bf093dbdb93b7079cfb319cbf3a032b1 (diff)
parentd3647f904bb21cc268a2492463d2eafa735ccea5 (diff)
Merge pull request #21017 from vespa-engine/mpolden/fix-parsing
Strip spaces from node count range
Diffstat (limited to 'client')
-rw-r--r--client/go/vespa/xml/config.go8
-rw-r--r--client/go/vespa/xml/config_test.go2
2 files changed, 6 insertions, 4 deletions
diff --git a/client/go/vespa/xml/config.go b/client/go/vespa/xml/config.go
index e900b50cbb0..a7ff37875ae 100644
--- a/client/go/vespa/xml/config.go
+++ b/client/go/vespa/xml/config.go
@@ -180,11 +180,11 @@ func ParseNodeCount(s string) (int, int, error) {
if len(parts) != 2 {
return 0, 0, parseErr
}
- min, err := strconv.Atoi(parts[0])
+ min, err := strconv.Atoi(strings.TrimSpace(parts[0]))
if err != nil {
return 0, 0, parseErr
}
- max, err := strconv.Atoi(parts[1])
+ max, err := strconv.Atoi(strings.TrimSpace(parts[1]))
if err != nil {
return 0, 0, parseErr
}
@@ -208,10 +208,10 @@ func IsProdRegion(s string, system string) bool {
func parseResource(field, s string) (string, error) {
parts := strings.SplitN(s, "=", 2)
- if len(parts) != 2 || parts[0] != field {
+ if len(parts) != 2 || strings.TrimSpace(parts[0]) != field {
return "", fmt.Errorf("invalid value for %s field: %q", field, s)
}
- return parts[1], nil
+ return strings.TrimSpace(parts[1]), nil
}
// ReplaceRaw finds all elements of name in rawXML and replaces their contents with value.
diff --git a/client/go/vespa/xml/config_test.go b/client/go/vespa/xml/config_test.go
index 9d18636473b..385653ab83f 100644
--- a/client/go/vespa/xml/config_test.go
+++ b/client/go/vespa/xml/config_test.go
@@ -247,11 +247,13 @@ func TestParseResources(t *testing.T) {
assertResources(t, "vcpu=2,memory=4Gb", Resources{}, true)
assertResources(t, "memory=4Gb,vcpu=2,disk=100Gb", Resources{}, true)
assertResources(t, "vcpu=2,memory=4Gb,disk=100Gb", Resources{Vcpu: "2", Memory: "4Gb", Disk: "100Gb"}, false)
+ assertResources(t, " vcpu = 4, memory =8Gb, disk=500Gb ", Resources{Vcpu: "4", Memory: "8Gb", Disk: "500Gb"}, false)
}
func TestParseNodeCount(t *testing.T) {
assertNodeCount(t, "2", 2, 2, false)
assertNodeCount(t, "[4,8]", 4, 8, false)
+ assertNodeCount(t, "[ 4, 8 ]", 4, 8, false)
assertNodeCount(t, "foo", 0, 0, true)
assertNodeCount(t, "[foo,bar]", 0, 0, true)