Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Add sprig templating functions #559

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions core/controlplane/config/templates/stack-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}
}
},
"DependsOn": ["{{$.Etcd.LogicalName}}{{minus $.Etcd.Count 1}}"]
"DependsOn": ["{{$.Etcd.LogicalName}}{{sub $.Etcd.Count 1}}"]
},
"IAMInstanceProfileController": {
"Properties": {
Expand Down Expand Up @@ -631,7 +631,7 @@
},
"DependsOn": [
{{if $etcdInstance.DependencyExists}}{{$etcdInstance.DependencyRef}},{{end}}
{{if $etcdIndex}}"{{$.Etcd.LogicalName}}{{minus $etcdIndex 1}}",{{end}}
{{if $etcdIndex}}"{{$.Etcd.LogicalName}}{{sub $etcdIndex 1}}",{{end}}
{{if $etcdInstance.EIPManaged}}
"{{$etcdInstance.EIPLogicalName}}",
{{end}}
Expand Down
9 changes: 2 additions & 7 deletions filereader/texttemplate/texttemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package texttemplate

import (
"bytes"
"crypto/sha1"
"fmt"
"github.com/Masterminds/sprig"
"io/ioutil"
"text/template"
)
Expand All @@ -13,12 +12,8 @@ func GetBytesBuffer(filename string, data interface{}) (*bytes.Buffer, error) {
if err != nil {
return nil, err
}
funcMap := template.FuncMap{
"sha1": func(v string) string { return fmt.Sprintf("%x", sha1.Sum([]byte(v))) },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we used the sha1 func nowhere in templates. Good catch 👍

"minus": func(a, b int) int { return a - b },
}

tmpl, err := template.New(filename).Funcs(funcMap).Parse(string(raw))
tmpl, err := template.New(filename).Funcs(sprig.HermeticTxtFuncMap()).Parse(string(raw))
if err != nil {
return nil, err
}
Expand Down
30 changes: 21 additions & 9 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ import:
- semver
- package: github.com/spf13/cobra
- package: gopkg.in/yaml.v2
- package: github.com/Masterminds/sprig
version: ^2.10.0
25 changes: 25 additions & 0 deletions vendor/github.com/Masterminds/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions vendor/github.com/Masterminds/semver/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/github.com/Masterminds/semver/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions vendor/github.com/Masterminds/semver/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading