Skip to content

Commit

Permalink
feat: Changing from using regular expressions to direct navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
eogns47 committed Sep 22, 2024
1 parent 953cf53 commit 59f7a21
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions util/helm/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ type TemplateOpts struct {
}

var (
re = regexp.MustCompile(`([^\\]),`)
apiVersionsRemover = regexp.MustCompile(`(--api-versions [^ ]+ )+`)
)

Expand All @@ -352,8 +351,21 @@ func cleanSetParameters(val string) string {
if strings.HasPrefix(val, `{`) && strings.HasSuffix(val, `}`) {
return val
}
re := regexp.MustCompile(`,`)
return re.ReplaceAllString(val, `$1\,`)

var result strings.Builder
for i := 0; i < len(val); i++ {
if val[i] == ',' {
if i == 0 || val[i-1] != '\\' {
result.WriteString(`\,`)
} else {
result.WriteByte(',')
}
} else {
result.WriteByte(val[i])
}
}

return result.String()
}

func (c *Cmd) template(chartPath string, opts *TemplateOpts) (string, string, error) {
Expand Down

0 comments on commit 59f7a21

Please sign in to comment.