Skip to content

Commit 3a6a99a

Browse files
Merge pull request #8265 from r4f4/proxy-replace-percent
OCPBUGS-27965: escape '%' in proxy settings
2 parents ea38c1b + bbc5c68 commit 3a6a99a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{{if .Proxy -}}
22
[Manager]
33
{{if .Proxy.HTTPProxy -}}
4-
DefaultEnvironment=HTTP_PROXY="{{.Proxy.HTTPProxy}}"
4+
DefaultEnvironment=HTTP_PROXY="{{replace .Proxy.HTTPProxy "%" "%%"}}"
55
{{end -}}
66
{{if .Proxy.HTTPSProxy -}}
7-
DefaultEnvironment=HTTPS_PROXY="{{.Proxy.HTTPSProxy}}"
7+
DefaultEnvironment=HTTPS_PROXY="{{replace .Proxy.HTTPSProxy "%" "%%"}}"
88
{{end -}}
99
{{if .Proxy.NoProxy -}}
1010
DefaultEnvironment=NO_PROXY="{{.Proxy.NoProxy}}"
1111
{{end -}}
12-
{{end -}}
12+
{{end -}}

pkg/asset/ignition/bootstrap/common.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ func AddSystemdUnits(config *igntypes.Config, uri string, templateData interface
518518
return nil
519519
}
520520

521+
// replace is an utilitary function to do string replacement in templates.
522+
func replace(input, from, to string) string {
523+
return strings.ReplaceAll(input, from, to)
524+
}
525+
521526
// Read data from the string reader, and, if the name ends with
522527
// '.template', strip that extension from the name and render the
523528
// template.
@@ -529,7 +534,7 @@ func readFile(name string, reader io.Reader, templateData interface{}) (finalNam
529534

530535
if filepath.Ext(name) == ".template" {
531536
name = strings.TrimSuffix(name, ".template")
532-
tmpl := template.New(name)
537+
tmpl := template.New(name).Funcs(template.FuncMap{"replace": replace})
533538
tmpl, err := tmpl.Parse(string(data))
534539
if err != nil {
535540
return name, data, err

0 commit comments

Comments
 (0)