Skip to content

Commit cb4a2a5

Browse files
committed
Use the same method to return the templating functions.
1 parent cf4944e commit cb4a2a5

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pki/helm.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"io"
55
"text/template"
66

7-
"github.com/Masterminds/sprig/v3"
87
"github.com/pkg/errors"
98
"github.com/smallstep/certificates/authority"
109
authconfig "github.com/smallstep/certificates/authority/config"
1110
"github.com/smallstep/certificates/authority/provisioner"
11+
"github.com/smallstep/certificates/templates"
1212
"go.step.sm/linkedca"
1313
)
1414

@@ -24,11 +24,7 @@ type helmVariables struct {
2424
// WriteHelmTemplate a helm template to configure the
2525
// smallstep/step-certificates helm chart.
2626
func (p *PKI) WriteHelmTemplate(w io.Writer) error {
27-
funcs := sprig.TxtFuncMap()
28-
delete(funcs, "env")
29-
delete(funcs, "expandenv")
30-
31-
tmpl, err := template.New("helm").Funcs(funcs).Parse(helmTemplate)
27+
tmpl, err := template.New("helm").Funcs(templates.StepFuncMap()).Parse(helmTemplate)
3228
if err != nil {
3329
return errors.Wrap(err, "error writing helm template")
3430
}

templates/templates.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (t *Template) Load() error {
183183
// the template fails.
184184
func (t *Template) LoadBytes(b []byte) error {
185185
t.backfill(b)
186-
tmpl, err := template.New(t.Name).Funcs(getFuncMap()).Parse(string(b))
186+
tmpl, err := template.New(t.Name).Funcs(StepFuncMap()).Parse(string(b))
187187
if err != nil {
188188
return errors.Wrapf(err, "error parsing template %s", t.Name)
189189
}
@@ -271,9 +271,9 @@ func mkdir(path string, perm os.FileMode) error {
271271
return nil
272272
}
273273

274-
// getFuncMap returns sprig.TxtFuncMap but removing the "env" and "expandenv"
274+
// StepFuncMap returns sprig.TxtFuncMap but removing the "env" and "expandenv"
275275
// functions to avoid any leak of information.
276-
func getFuncMap() template.FuncMap {
276+
func StepFuncMap() template.FuncMap {
277277
m := sprig.TxtFuncMap()
278278
delete(m, "env")
279279
delete(m, "expandenv")

0 commit comments

Comments
 (0)