Skip to content

Commit

Permalink
(#159) Move to Sprout library from Sprig
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Apr 17, 2024
1 parent ba0ccaa commit d4c42f5
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 85 deletions.
2 changes: 1 addition & 1 deletion builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func (b *AppBuilder) createCommand(def json.RawMessage) (Command, error) {
return cmd, nil
}

// TemplateFuncs returns standard template funcs, set all to also include sprig functions
// TemplateFuncs returns standard template funcs, set all to also include Sprout functions
func (b *AppBuilder) TemplateFuncs(all bool) template.FuncMap {
funcs := TemplateFuncs(all)

Expand Down
4 changes: 2 additions & 2 deletions builder/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package builder
import (
"bytes"
"errors"
"github.com/42atomys/sprout"
"os"
"reflect"
"text/template"

"github.com/Masterminds/sprig/v3"
"gopkg.in/alessio/shellescape.v1"
)

Expand All @@ -34,7 +34,7 @@ func dereferenceArgsOrFlags(input map[string]any) map[string]any {
func TemplateFuncs(all bool) template.FuncMap {
funcs := map[string]any{}
if all {
funcs = sprig.TxtFuncMap()
funcs = sprout.TxtFuncMap()
}

funcs["require"] = func(v any, reason string) (any, error) {
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/scaffold.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toc = true

Use the `scaffold` command to create directories of files based on templates.

The [Sprig](https://github.com/Masterminds/sprig) functions library is available to use in templates.
The [Sprout](https://github.com/42atomys/sprout) functions library is available to use in templates.

{{% notice secondary "Version Hint" code-branch %}}
This was added in version 0.7.0
Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ The transform supports a few options, all are optional:

## Templates

The `template` transform uses Golang templates and the [sprig](http://masterminds.github.io/sprig/) functions
The `template` transform uses Golang templates and the [Sprout](https://github.com/42atomys/sprout) functions
to facilitate creation of text output using a template language.

```yaml
Expand Down
2 changes: 1 addition & 1 deletion example/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ var _ = Describe("Example Application", func() {
})

Describe("Templates", func() {
It("Should parse and render the template and should include sprig functions", func() {
It("Should parse and render the template and should include sprout functions", func() {
cmd.MustParseWithUsage(strings.Fields("transforms template"))
Expect(usageBuf.String()).To(ContainSubstring("Hello James bOND"))
})
Expand Down
2 changes: 1 addition & 1 deletion example/sample-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ commands:
command: |
curl -s https://api.github.com/repos/choria-io/appbuilder/releases/latest
# This uses a template transform with sprig functions to transform
# This uses a template transform with Sprout functions to transform
# JSON input into a textual format
- name: template
type: exec
Expand Down
41 changes: 21 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
module github.com/choria-io/appbuilder

go 1.20
go 1.21

toolchain go1.22.0

require (
github.com/42atomys/sprout v0.0.0-20240403003052-d64a48ef7bae
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Masterminds/sprig/v3 v3.2.3
github.com/adrg/xdg v0.4.0
github.com/choria-io/fisk v0.6.1
github.com/choria-io/fisk v0.6.2
github.com/choria-io/goform v0.0.3
github.com/dustin/go-humanize v1.0.1
github.com/expr-lang/expr v1.15.6
github.com/expr-lang/expr v1.16.5
github.com/ghodss/yaml v1.0.0
github.com/guptarohit/asciigraph v0.5.6
github.com/itchyny/gojq v0.12.14
github.com/guptarohit/asciigraph v0.7.1
github.com/itchyny/gojq v0.12.15
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/onsi/ginkgo/v2 v2.13.2
github.com/onsi/gomega v1.30.0
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.32.0
github.com/sirupsen/logrus v1.9.3
github.com/tidwall/gjson v1.17.0
github.com/tidwall/gjson v1.17.1
github.com/xlab/tablewriter v0.0.0-20160610135559-80b567a11ad5
golang.org/x/term v0.15.0
golang.org/x/term v0.19.0
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20231205033806-a5a03c77bf08 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/itchyny/timefmt-go v0.1.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/tools v0.20.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit d4c42f5

Please sign in to comment.