Skip to content

Commit

Permalink
Merge pull request #8318 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…8272-to-release-4.14

[release-4.14] OCPBUGS-33010: escape '%' in proxy settings
  • Loading branch information
openshift-merge-bot[bot] committed Apr 30, 2024
2 parents 87a1a77 + 20b3a69 commit b6dcee1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{if .Proxy -}}
[Manager]
{{if .Proxy.HTTPProxy -}}
DefaultEnvironment=HTTP_PROXY="{{.Proxy.HTTPProxy}}"
DefaultEnvironment=HTTP_PROXY="{{replace .Proxy.HTTPProxy "%" "%%"}}"
{{end -}}
{{if .Proxy.HTTPSProxy -}}
DefaultEnvironment=HTTPS_PROXY="{{.Proxy.HTTPSProxy}}"
DefaultEnvironment=HTTPS_PROXY="{{replace .Proxy.HTTPSProxy "%" "%%"}}"
{{end -}}
{{if .Proxy.NoProxy -}}
DefaultEnvironment=NO_PROXY="{{.Proxy.NoProxy}}"
{{end -}}
{{end -}}
{{end -}}
7 changes: 6 additions & 1 deletion pkg/asset/ignition/bootstrap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ func AddSystemdUnits(config *igntypes.Config, uri string, templateData interface
return nil
}

// replace is an utilitary function to do string replacement in templates.
func replace(input, from, to string) string {
return strings.ReplaceAll(input, from, to)
}

// Read data from the string reader, and, if the name ends with
// '.template', strip that extension from the name and render the
// template.
Expand All @@ -518,7 +523,7 @@ func readFile(name string, reader io.Reader, templateData interface{}) (finalNam

if filepath.Ext(name) == ".template" {
name = strings.TrimSuffix(name, ".template")
tmpl := template.New(name)
tmpl := template.New(name).Funcs(template.FuncMap{"replace": replace})
tmpl, err := tmpl.Parse(string(data))
if err != nil {
return name, data, err
Expand Down

0 comments on commit b6dcee1

Please sign in to comment.