Use a regex to match --state-values-set-string arguments (#1902)

Signed-off-by: Guillaume Le Blanc <gleblanc@proton.me>
This commit is contained in:
Guillaume Le Blanc
2025-02-04 07:59:31 +08:00
committed by GitHub
parent 8e188960eb
commit 09c9ceb075
4 changed files with 15 additions and 9 deletions
+6 -4
View File
@@ -1,21 +1,23 @@
package config
import (
"regexp"
"strings"
"github.com/helmfile/helmfile/pkg/maputil"
)
func NewCLIConfigImpl(g *GlobalImpl) error {
re := regexp.MustCompile(`(?:,|^)([^\s=]+)=(['"][^'"]*['"]|[^,]+)`)
optsSet := g.RawStateValuesSetString()
if len(optsSet) > 0 {
set := map[string]any{}
for i := range optsSet {
ops := strings.Split(optsSet[i], ",")
ops := re.FindAllStringSubmatch(optsSet[i], -1)
for j := range ops {
op := strings.SplitN(ops[j], "=", 2)
k := maputil.ParseKey(op[0])
v := op[1]
op := ops[j]
k := maputil.ParseKey(op[1])
v := op[2]
maputil.Set(set, k, v, true)
}