diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-02-02 09:57:21 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-02-02 09:59:27 +0100 |
commit | d3647f904bb21cc268a2492463d2eafa735ccea5 (patch) | |
tree | c8876e3e0f3a9eb68423e2c31cdd5b19c3599054 /client/go | |
parent | 02298d5f65e53a36ce94fd0febcf5e6e16996756 (diff) |
Strip spaces from resources spec
Diffstat (limited to 'client/go')
-rw-r--r-- | client/go/vespa/xml/config.go | 4 | ||||
-rw-r--r-- | client/go/vespa/xml/config_test.go | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/client/go/vespa/xml/config.go b/client/go/vespa/xml/config.go index 5c74bb797d3..a7ff37875ae 100644 --- a/client/go/vespa/xml/config.go +++ b/client/go/vespa/xml/config.go @@ -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 4cee1af435f..385653ab83f 100644 --- a/client/go/vespa/xml/config_test.go +++ b/client/go/vespa/xml/config_test.go @@ -247,6 +247,7 @@ 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) { |