This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit dad0c472164eb27074661154f600ed5c496d1f9f Author: Antonin Stefanutti <[email protected]> AuthorDate: Thu Apr 8 16:38:53 2021 +0200 chore: pass configuration variable with empty value --- pkg/trait/util.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pkg/trait/util.go b/pkg/trait/util.go index 591f90b..695b7ee 100644 --- a/pkg/trait/util.go +++ b/pkg/trait/util.go @@ -94,24 +94,28 @@ func collectConfigurationPairs(configurationType string, configurable ...v1.Conf for _, entry := range entries { if entry.Type == configurationType { pair := strings.SplitN(entry.Value, "=", 2) + var k, v string + if len(pair) >= 1 { + k = strings.TrimSpace(pair[0]) + } if len(pair) == 2 { - k := strings.TrimSpace(pair[0]) - v := strings.TrimSpace(pair[1]) - - if len(k) > 0 && len(v) > 0 { - ok := false - for i, variable := range result { - if variable.Name == k { - result[i].Value = v - ok = true - break - } - } - if !ok { - result = append(result, variable{Name: k, Value: v}) - } + v = strings.TrimSpace(pair[1]) + } + if k == "" { + continue + } + + ok := false + for i, variable := range result { + if variable.Name == k { + result[i].Value = v + ok = true + break } } + if !ok { + result = append(result, variable{Name: k, Value: v}) + } } } }
