├── internal
├── datasources
│ ├── datasource.go
│ ├── json.go
│ ├── yaml_test.go
│ ├── toml_test.go
│ ├── yaml.go
│ ├── env_file_test.go
│ ├── toml.go
│ ├── json_test.go
│ ├── env_file.go
│ ├── env.go
│ └── env_test.go
├── engines
│ ├── engine.go
│ ├── mustache.go
│ ├── jinja.go
│ ├── gotemplates.go
│ ├── handlebars.go
│ ├── envsubst.go
│ ├── jet.go
│ ├── mustache_test.go
│ ├── envsubst_test.go
│ ├── handlebars_test.go
│ ├── jinja_test.go
│ ├── jet_test.go
│ └── gotemplates_test.go
└── app
│ ├── validate.go
│ ├── validate_test.go
│ ├── render.go
│ ├── render_test.go
│ ├── app_integration_test.go
│ ├── parse.go
│ ├── app.go
│ └── parse_test.go
├── .gitignore
├── Dockerfile
├── .pre-commit-config.yaml
├── Taskfile.yml
├── main.go
├── .github
└── workflows
│ ├── test.yml
│ └── release.yml
├── .goreleaser.yaml
├── go.mod
├── README.md
├── go.sum
└── LICENSE
/internal/datasources/datasource.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | type Datasource interface {
4 | Load() (map[string]any, error)
5 | }
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .vscode/
3 | dist/
4 | playground/
5 |
6 | *.exe
7 | *.exe~
8 | *.dll
9 | *.so
10 | *.dylib
11 | *.test
12 | *.out
13 | cover.html
14 | go.work
15 |
--------------------------------------------------------------------------------
/internal/engines/engine.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import "io"
4 |
5 | type Engine interface {
6 | RenderFile(file string, w io.Writer, data map[string]any) error
7 | Render(r io.Reader, w io.Writer, data map[string]any) error
8 | }
9 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.24 AS builder
2 | ENV CGO_ENABLED=0
3 | ENV GOOS=linux
4 | ARG VERSION
5 | ENV VERSION=$VERSION
6 | WORKDIR /src
7 | COPY go.mod go.sum ./
8 | RUN go mod download
9 | COPY . .
10 | RUN go build -ldflags="-s -w -X main.version=$VERSION" -o /bin/renderkit .
11 |
12 | FROM alpine:3
13 | COPY --from=builder /bin/renderkit /bin/renderkit
14 | ENTRYPOINT [ "/bin/renderkit" ]
15 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v5.0.0
4 | hooks:
5 | - id: check-yaml
6 | - id: end-of-file-fixer
7 | - id: trailing-whitespace
8 |
9 | - repo: https://github.com/dnephin/pre-commit-golang
10 | rev: v0.5.1
11 | hooks:
12 | - id: go-fmt
13 | - id: golangci-lint
14 | - id: go-unit-tests
15 |
--------------------------------------------------------------------------------
/internal/datasources/json.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "encoding/json"
5 | "io"
6 | )
7 |
8 | type JsonDatasource struct {
9 | r io.Reader
10 | }
11 |
12 | func NewJsonDatasource(r io.Reader) *JsonDatasource {
13 | return &JsonDatasource{r}
14 | }
15 |
16 | func (ds *JsonDatasource) Load() (map[string]any, error) {
17 | data := make(map[string]any)
18 | decoder := json.NewDecoder(ds.r)
19 | if err := decoder.Decode(&data); err != nil {
20 | return nil, err
21 | }
22 | return data, nil
23 | }
24 |
--------------------------------------------------------------------------------
/internal/datasources/yaml_test.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "strings"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 | )
9 |
10 | func TestYamlLoad(t *testing.T) {
11 | yamlData := `
12 | key1: value1
13 | key2: 5`
14 | expectedData := map[string]any{
15 | "key1": "value1",
16 | "key2": 5,
17 | }
18 | r := strings.NewReader(yamlData)
19 | ds := NewYamlDatasource(r)
20 |
21 | data, err := ds.Load()
22 | require.NoError(t, err)
23 | require.Equal(t, expectedData, data)
24 | }
25 |
--------------------------------------------------------------------------------
/internal/datasources/toml_test.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "strings"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 | )
9 |
10 | func TestTomlLoad(t *testing.T) {
11 | tomlData := `
12 | key1 = "value1"
13 | key2 = 5`
14 | expectedData := map[string]any{
15 | "key1": "value1",
16 | "key2": int64(5),
17 | }
18 | r := strings.NewReader(tomlData)
19 | ds := NewTomlDatasource(r)
20 |
21 | data, err := ds.Load()
22 | require.NoError(t, err)
23 | require.Equal(t, expectedData, data)
24 | }
25 |
--------------------------------------------------------------------------------
/internal/datasources/yaml.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "io"
5 |
6 | "gopkg.in/yaml.v3"
7 | )
8 |
9 | type YamlDatasource struct {
10 | r io.Reader
11 | }
12 |
13 | func NewYamlDatasource(r io.Reader) *YamlDatasource {
14 | return &YamlDatasource{r}
15 | }
16 |
17 | func (ds *YamlDatasource) Load() (map[string]any, error) {
18 | data := make(map[string]any)
19 | decoder := yaml.NewDecoder(ds.r)
20 | if err := decoder.Decode(&data); err != nil {
21 | return nil, err
22 | }
23 | return data, nil
24 | }
25 |
--------------------------------------------------------------------------------
/internal/datasources/env_file_test.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "strings"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 | )
9 |
10 | func TestEnvFileLoadFromFile(t *testing.T) {
11 | envFileData := `
12 | key1=value1
13 | key2=5`
14 | expectedData := map[string]any{
15 | "key1": "value1",
16 | "key2": "5",
17 | }
18 | r := strings.NewReader(envFileData)
19 | ds := NewEnvFileDatasource(r)
20 |
21 | data, err := ds.Load()
22 | require.NoError(t, err)
23 | require.Equal(t, expectedData, data)
24 | }
25 |
--------------------------------------------------------------------------------
/internal/datasources/toml.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "io"
5 |
6 | "github.com/pelletier/go-toml/v2"
7 | )
8 |
9 | type TomlDatasource struct {
10 | r io.Reader
11 | }
12 |
13 | func NewTomlDatasource(r io.Reader) *TomlDatasource {
14 | return &TomlDatasource{r}
15 | }
16 |
17 | func (ds *TomlDatasource) Load() (map[string]any, error) {
18 | data := make(map[string]any)
19 | decoder := toml.NewDecoder(ds.r)
20 | if err := decoder.Decode(&data); err != nil {
21 | return nil, err
22 | }
23 | return data, nil
24 | }
25 |
--------------------------------------------------------------------------------
/internal/datasources/json_test.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "strings"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 | )
9 |
10 | func TestJsonLoad(t *testing.T) {
11 | jsonData := `
12 | {
13 | "key1": "value1",
14 | "key2": 5
15 | }`
16 | expectedData := map[string]any{
17 | "key1": "value1",
18 | "key2": float64(5),
19 | }
20 | r := strings.NewReader(jsonData)
21 | ds := NewJsonDatasource(r)
22 |
23 | data, err := ds.Load()
24 | require.NoError(t, err)
25 | require.Equal(t, expectedData, data)
26 | }
27 |
--------------------------------------------------------------------------------
/Taskfile.yml:
--------------------------------------------------------------------------------
1 | version: "3"
2 |
3 | tasks:
4 | default:
5 | cmds:
6 | - task: run
7 |
8 | run:
9 | desc: Run the application with playground data
10 | cmds:
11 | - go run . --config playground/renderkit.yml
12 |
13 | local-release:
14 | desc: Build release locally
15 | cmds:
16 | - goreleaser release --snapshot --clean
17 |
18 | test:
19 | desc: Run tests
20 | cmds:
21 | - go test ./... {{if .SHORT}}"-short"{{end}} -coverprofile cover.out
22 | - go tool cover -html cover.out -o cover.html
23 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "log"
5 | "os"
6 | "runtime/debug"
7 |
8 | "github.com/orellazri/renderkit/internal/app"
9 | )
10 |
11 | // This version variable is set at compile time using ldflags
12 | var version = "dev"
13 |
14 | func main() {
15 | // If the version is not set at compile time, try to get it from the build info
16 | info, ok := debug.ReadBuildInfo()
17 | if ok && info.Main.Version != "(devel)" {
18 | version = info.Main.Version
19 | }
20 |
21 | app := app.NewApp(version)
22 | if err := app.Run(os.Args); err != nil {
23 | log.Fatal(err)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/internal/datasources/env_file.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "fmt"
5 | "io"
6 |
7 | "github.com/hashicorp/go-envparse"
8 | )
9 |
10 | type EnvFileDatasource struct {
11 | r io.Reader
12 | }
13 |
14 | func NewEnvFileDatasource(r io.Reader) *EnvFileDatasource {
15 | return &EnvFileDatasource{r}
16 | }
17 |
18 | func (ds *EnvFileDatasource) Load() (map[string]any, error) {
19 | data := make(map[string]any)
20 |
21 | env, err := envparse.Parse(ds.r)
22 | if err != nil {
23 | return nil, fmt.Errorf("parse environment variables: %s", err)
24 | }
25 |
26 | for k, v := range env {
27 | data[k] = v
28 | }
29 |
30 | return data, nil
31 | }
32 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | push:
5 | branches: ["main"]
6 | pull_request:
7 | branches: ["main"]
8 |
9 | permissions:
10 | contents: read
11 | pull-requests: read
12 |
13 | jobs:
14 | test:
15 | strategy:
16 | matrix:
17 | os: [ubuntu-latest, macos-latest]
18 | runs-on: ${{ matrix.os }}
19 | steps:
20 | - name: Checkout
21 | uses: actions/checkout@v4
22 |
23 | - name: Set up Go
24 | uses: actions/setup-go@v5
25 | with:
26 | go-version: "1.24"
27 |
28 | - name: Lint
29 | uses: golangci/golangci-lint-action@v6
30 | if: matrix.os == 'ubuntu-latest'
31 |
32 | - name: Run tests
33 | run: go test -v ./...
34 |
--------------------------------------------------------------------------------
/internal/engines/mustache.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "io"
5 |
6 | "github.com/cbroglie/mustache"
7 | )
8 |
9 | type MustacheEngine struct{}
10 |
11 | func (e *MustacheEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
12 | result, err := mustache.RenderFile(file, data)
13 | if err != nil {
14 | return err
15 | }
16 |
17 | _, err = io.WriteString(w, result)
18 | if err != nil {
19 | return err
20 | }
21 |
22 | return nil
23 | }
24 |
25 | func (e *MustacheEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
26 | contents, err := io.ReadAll(r)
27 | if err != nil {
28 | return err
29 | }
30 |
31 | result, err := mustache.Render(string(contents), data)
32 | if err != nil {
33 | return err
34 | }
35 |
36 | _, err = io.WriteString(w, result)
37 | if err != nil {
38 | return err
39 | }
40 |
41 | return nil
42 | }
43 |
--------------------------------------------------------------------------------
/internal/engines/jinja.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "io"
5 |
6 | "github.com/nikolalohinski/gonja/v2"
7 | "github.com/nikolalohinski/gonja/v2/exec"
8 | )
9 |
10 | type JinjaEngine struct{}
11 |
12 | func (e *JinjaEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
13 | tpl, err := gonja.FromFile(file)
14 | if err != nil {
15 | return err
16 | }
17 |
18 | dataCtx := exec.NewContext(data)
19 | if err := tpl.Execute(w, dataCtx); err != nil {
20 | return err
21 | }
22 |
23 | return nil
24 | }
25 |
26 | func (e *JinjaEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
27 | contents, err := io.ReadAll(r)
28 | if err != nil {
29 | return err
30 | }
31 |
32 | tpl, err := gonja.FromBytes(contents)
33 | if err != nil {
34 | return err
35 | }
36 |
37 | dataCtx := exec.NewContext(data)
38 | if err := tpl.Execute(w, dataCtx); err != nil {
39 | return err
40 | }
41 |
42 | return nil
43 | }
44 |
--------------------------------------------------------------------------------
/internal/engines/gotemplates.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "io"
5 | "path/filepath"
6 | "text/template"
7 |
8 | "github.com/Masterminds/sprig/v3"
9 | )
10 |
11 | type GoTemplatesEngine struct{}
12 |
13 | func (e *GoTemplatesEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
14 | tpl, err := template.New(filepath.Base(file)).Funcs(sprig.FuncMap()).ParseFiles(file)
15 | if err != nil {
16 | return err
17 | }
18 |
19 | err = tpl.Execute(w, data)
20 | if err != nil {
21 | return err
22 | }
23 |
24 | return nil
25 | }
26 |
27 | func (e *GoTemplatesEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
28 | contents, err := io.ReadAll(r)
29 | if err != nil {
30 | return err
31 | }
32 |
33 | tpl, err := template.New("template").Funcs(sprig.FuncMap()).Parse(string(contents))
34 | if err != nil {
35 | return err
36 | }
37 |
38 | err = tpl.Execute(w, data)
39 | if err != nil {
40 | return err
41 | }
42 |
43 | return nil
44 | }
45 |
--------------------------------------------------------------------------------
/internal/datasources/env.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "os"
7 | "strings"
8 |
9 | "github.com/hashicorp/go-envparse"
10 | )
11 |
12 | type EnvDatasource struct {
13 | variable string
14 | }
15 |
16 | func NewEnvDatasource(variable string) *EnvDatasource {
17 | return &EnvDatasource{variable}
18 | }
19 |
20 | func (ds *EnvDatasource) Load() (map[string]any, error) {
21 | data := make(map[string]any)
22 |
23 | if ds.variable == "" { // If no variable is provided, we use all environment variables
24 | r := bytes.NewReader([]byte(strings.Join(os.Environ(), "\n")))
25 | env, err := envparse.Parse(r)
26 | if err != nil {
27 | return nil, fmt.Errorf("parse environment variables: %s", err)
28 | }
29 | for k, v := range env {
30 | data[k] = v
31 | }
32 | } else {
33 | value := os.Getenv(ds.variable)
34 | if len(value) == 0 {
35 | return nil, fmt.Errorf("environment variable %q not found", ds.variable)
36 | }
37 | data[ds.variable] = value
38 | }
39 |
40 | return data, nil
41 | }
42 |
--------------------------------------------------------------------------------
/internal/engines/handlebars.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "io"
5 |
6 | "github.com/aymerick/raymond"
7 | )
8 |
9 | type HandlebarsEngine struct{}
10 |
11 | func (e *HandlebarsEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
12 | tpl, err := raymond.ParseFile(file)
13 | if err != nil {
14 | return err
15 | }
16 |
17 | result, err := tpl.Exec(data)
18 | if err != nil {
19 | return err
20 | }
21 |
22 | _, err = io.WriteString(w, result)
23 | if err != nil {
24 | return err
25 | }
26 |
27 | return nil
28 | }
29 |
30 | func (e *HandlebarsEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
31 | contents, err := io.ReadAll(r)
32 | if err != nil {
33 | return err
34 | }
35 |
36 | tpl, err := raymond.Parse(string(contents))
37 | if err != nil {
38 | return err
39 | }
40 |
41 | result, err := tpl.Exec(data)
42 | if err != nil {
43 | return err
44 | }
45 |
46 | _, err = io.WriteString(w, result)
47 | if err != nil {
48 | return err
49 | }
50 |
51 | return nil
52 | }
53 |
--------------------------------------------------------------------------------
/internal/engines/envsubst.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "fmt"
5 | "io"
6 | "os"
7 |
8 | "github.com/a8m/envsubst"
9 | )
10 |
11 | type EnvsubstEngine struct{}
12 |
13 | func (e *EnvsubstEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
14 | f, err := os.Open(file)
15 | if err != nil {
16 | return err
17 | }
18 | defer f.Close()
19 |
20 | return e.Render(f, w, data)
21 | }
22 |
23 | func (e *EnvsubstEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
24 | buf, err := io.ReadAll(r)
25 | if err != nil {
26 | return err
27 | }
28 |
29 | // Set environment variables. This is necessary because envsubst does not allow directly passing data as environment variables.
30 | for k, v := range data {
31 | os.Setenv(k, fmt.Sprintf("%v", v))
32 | }
33 |
34 | tpl, err := envsubst.Bytes(buf)
35 | if err != nil {
36 | return err
37 | }
38 |
39 | _, err = w.Write(tpl)
40 | if err != nil {
41 | return err
42 | }
43 |
44 | // Unset environment variables.
45 | for k := range data {
46 | os.Unsetenv(k)
47 | }
48 |
49 | return nil
50 | }
51 |
--------------------------------------------------------------------------------
/internal/engines/jet.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "io"
5 | "os"
6 | "path/filepath"
7 | "reflect"
8 |
9 | "github.com/CloudyKit/jet/v6"
10 | )
11 |
12 | type JetEngine struct{}
13 |
14 | func (e *JetEngine) RenderFile(file string, w io.Writer, data map[string]any) error {
15 | abs, err := filepath.Abs(file)
16 | if err != nil {
17 | return err
18 | }
19 |
20 | renderer := jet.NewSet(jet.NewOSFileSystemLoader("/"))
21 | tpl, err := renderer.GetTemplate(abs)
22 | if err != nil {
23 | return err
24 | }
25 |
26 | dataMap := jet.VarMap{}
27 | for key, value := range data {
28 | dataMap[key] = reflect.ValueOf(value)
29 | }
30 |
31 | if err := tpl.Execute(w, dataMap, nil); err != nil {
32 | return err
33 | }
34 |
35 | return nil
36 | }
37 |
38 | func (e *JetEngine) Render(r io.Reader, w io.Writer, data map[string]any) error {
39 | f, err := os.CreateTemp("", "jet")
40 | if err != nil {
41 | return err
42 | }
43 | defer f.Close()
44 |
45 | if _, err := io.Copy(f, r); err != nil {
46 | return err
47 | }
48 |
49 | if err := e.RenderFile(f.Name(), w, data); err != nil {
50 | return err
51 | }
52 |
53 | return nil
54 | }
55 |
--------------------------------------------------------------------------------
/.goreleaser.yaml:
--------------------------------------------------------------------------------
1 | # yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2 | # vim: set ts=2 sw=2 tw=0 fo=cnqoj
3 |
4 | version: 2
5 |
6 | before:
7 | hooks:
8 | - go mod tidy
9 |
10 | builds:
11 | - env:
12 | - CGO_ENABLED=0
13 | goos:
14 | - linux
15 | - darwin
16 | ldflags:
17 | - -s -w -X main.version={{ .Version }}
18 |
19 | archives:
20 | - formats: [tar.gz]
21 | # this name template makes the OS and Arch compatible with the results of `uname`.
22 | name_template: >-
23 | {{ .ProjectName }}_
24 | {{- .Os }}_
25 | {{- if eq .Arch "amd64" }}x86_64
26 | {{- else if eq .Arch "386" }}i386
27 | {{- else }}{{ .Arch }}{{ end }}
28 | {{- if .Arm }}v{{ .Arm }}{{ end }}
29 | # use zip for windows archives
30 | format_overrides:
31 | - goos: windows
32 | formats: [zip]
33 |
34 | changelog:
35 | sort: asc
36 | filters:
37 | exclude:
38 | - "^docs:"
39 | - "^test:"
40 | groups:
41 | - title: Features
42 | regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
43 | order: 0
44 | - title: "Bug fixes"
45 | regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
46 | order: 1
47 | - title: Others
48 | order: 999
49 |
--------------------------------------------------------------------------------
/internal/datasources/env_test.go:
--------------------------------------------------------------------------------
1 | package datasources
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "strings"
7 | "testing"
8 |
9 | "github.com/hashicorp/go-envparse"
10 | "github.com/stretchr/testify/require"
11 | )
12 |
13 | func TestEnvLoadFromEnvironment(t *testing.T) {
14 | var expectedData = map[string]any{}
15 | r := bytes.NewReader([]byte(strings.Join(os.Environ(), "\n")))
16 | env, err := envparse.Parse(r)
17 | require.NoError(t, err)
18 | for k, v := range env {
19 | expectedData[k] = v
20 | }
21 |
22 | ds := NewEnvDatasource("")
23 | data, err := ds.Load()
24 | require.NoError(t, err)
25 | require.Equal(t, expectedData, data)
26 | }
27 |
28 | func TestEnvDatasourceLoadVariable(t *testing.T) {
29 | expectedData := map[string]any{
30 | "RENDERKIT_VAR2": "value2",
31 | }
32 |
33 | os.Setenv("RENDERKIT_VAR1", "value1")
34 | os.Setenv("RENDERKIT_VAR2", "value2")
35 |
36 | ds := NewEnvDatasource("RENDERKIT_VAR2")
37 | data, err := ds.Load()
38 | require.NoError(t, err)
39 | require.Equal(t, expectedData, data)
40 | }
41 |
42 | func TestEnvDatasourceLoadVariableNotFound(t *testing.T) {
43 | ds := NewEnvDatasource("RENDERKIT_NON_EXISTING_ENV_VAR")
44 | data, err := ds.Load()
45 | require.Error(t, err)
46 | require.Nil(t, data)
47 | }
48 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - "v*.*.*"
7 |
8 | permissions:
9 | contents: write
10 |
11 | jobs:
12 | release:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4
17 | with:
18 | fetch-depth: 0
19 |
20 | - name: Set output
21 | id: vars
22 | run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
23 |
24 | - name: Set up Go
25 | uses: actions/setup-go@v5
26 | with:
27 | go-version: "1.24"
28 |
29 | - name: Run GoReleaser
30 | uses: goreleaser/goreleaser-action@v6
31 | with:
32 | version: latest
33 | args: release --clean
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 | TAG: ${{ steps.vars.outputs.tag }}
37 |
38 | - name: Set up Docker Buildx
39 | uses: docker/setup-buildx-action@v3
40 |
41 | - name: Log in to Docker Hub
42 | uses: docker/login-action@v3
43 | with:
44 | username: ${{ secrets.DOCKERHUB_USERNAME }}
45 | password: ${{ secrets.DOCKERHUB_PASSWORD }}
46 |
47 | - name: Build and push
48 | uses: docker/build-push-action@v5
49 | with:
50 | context: .
51 | platforms: linux/amd64,linux/arm64
52 | push: true
53 | tags: reaperberri/renderkit:latest,reaperberri/renderkit:${{ steps.vars.outputs.tag }}
54 | build-args: |
55 | VERSION=${{ steps.vars.outputs.tag }}
56 |
--------------------------------------------------------------------------------
/internal/engines/mustache_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "testing"
7 |
8 | "github.com/stretchr/testify/require"
9 | )
10 |
11 | func TestMustacheRenderFile(t *testing.T) {
12 | dir := t.TempDir()
13 | file, err := os.CreateTemp(dir, "test.txt")
14 | require.NoError(t, err)
15 |
16 | _, err = file.WriteString("Hello, {{ Name }}! You are {{ Age }} years old.")
17 | require.NoError(t, err)
18 |
19 | engine := &MustacheEngine{}
20 | writer := &bytes.Buffer{}
21 | err = engine.RenderFile(file.Name(), writer, map[string]any{
22 | "Name": "John",
23 | "Age": 20,
24 | })
25 | require.NoError(t, err)
26 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
27 | }
28 |
29 | func TestMustacheRenderFileAdvanced(t *testing.T) {
30 | dir := t.TempDir()
31 | file, err := os.CreateTemp(dir, "test.txt")
32 | require.NoError(t, err)
33 |
34 | _, err = file.WriteString(`
35 | {{#names}}Hi {{.}}
{{/names}}`)
36 | require.NoError(t, err)
37 |
38 | engine := &MustacheEngine{}
39 | writer := &bytes.Buffer{}
40 | err = engine.RenderFile(file.Name(), writer, map[string]any{
41 | "names": []string{"John", "Doe"},
42 | })
43 |
44 | require.NoError(t, err)
45 | require.Equal(t, `
46 | Hi John
Hi Doe
`, writer.String())
47 | }
48 |
49 | func TestMustacheRenderReader(t *testing.T) {
50 | engine := &MustacheEngine{}
51 | writer := &bytes.Buffer{}
52 | err := engine.Render(bytes.NewBufferString("Hello, {{ Name }}! You are {{ Age }} years old."),
53 | writer,
54 | map[string]any{
55 | "Name": "John",
56 | "Age": 20,
57 | })
58 | require.NoError(t, err)
59 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
60 | }
61 |
--------------------------------------------------------------------------------
/internal/engines/envsubst_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "testing"
7 |
8 | "github.com/stretchr/testify/require"
9 | )
10 |
11 | func TestEnvsubstRenderFile(t *testing.T) {
12 | dir := t.TempDir()
13 | file, err := os.CreateTemp(dir, "test.txt")
14 | require.NoError(t, err)
15 |
16 | _, err = file.WriteString("Hello, ${NAME}! You are ${AGE} years old.")
17 | require.NoError(t, err)
18 |
19 | engine := &EnvsubstEngine{}
20 | writer := &bytes.Buffer{}
21 | err = engine.RenderFile(file.Name(), writer, map[string]any{
22 | "NAME": "John",
23 | "AGE": 20,
24 | })
25 | require.NoError(t, err)
26 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
27 | }
28 |
29 | func TestEnvsubstRenderFileAdvanced(t *testing.T) {
30 | dir := t.TempDir()
31 | file, err := os.CreateTemp(dir, "test.txt")
32 | require.NoError(t, err)
33 |
34 | _, err = file.WriteString("${GREETING=Hello}, James! Do you know the ${OTHER}?")
35 | require.NoError(t, err)
36 |
37 | engine := &EnvsubstEngine{}
38 | writer := &bytes.Buffer{}
39 | err = engine.RenderFile(file.Name(), writer, map[string]any{
40 | "OTHER": []string{"a", "b", "c"},
41 | })
42 |
43 | require.NoError(t, err)
44 | require.Equal(t, "Hello, James! Do you know the [a b c]?", writer.String())
45 | }
46 |
47 | func TestEnvsubstRenderReader(t *testing.T) {
48 | engine := &EnvsubstEngine{}
49 | writer := &bytes.Buffer{}
50 | err := engine.Render(bytes.NewBufferString("Hello, ${NAME}! You are ${AGE} years old."),
51 | writer,
52 | map[string]any{
53 | "NAME": "John",
54 | "AGE": 20,
55 | })
56 | require.NoError(t, err)
57 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
58 | }
59 |
--------------------------------------------------------------------------------
/internal/engines/handlebars_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "testing"
7 |
8 | "github.com/stretchr/testify/require"
9 | )
10 |
11 | func TestHandlebarsRenderFile(t *testing.T) {
12 | dir := t.TempDir()
13 | file, err := os.CreateTemp(dir, "test.txt")
14 | require.NoError(t, err)
15 |
16 | _, err = file.WriteString("Hello, {{ Name }}! You are {{ Age }} years old.")
17 | require.NoError(t, err)
18 |
19 | engine := &HandlebarsEngine{}
20 | writer := &bytes.Buffer{}
21 | err = engine.RenderFile(file.Name(), writer, map[string]any{
22 | "Name": "John",
23 | "Age": 20,
24 | })
25 | require.NoError(t, err)
26 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
27 | }
28 |
29 | func TestHandlebarsRenderFileAdvanced(t *testing.T) {
30 | dir := t.TempDir()
31 | file, err := os.CreateTemp(dir, "test.txt")
32 | require.NoError(t, err)
33 |
34 | _, err = file.WriteString(`
35 | {{#names}}Hi {{.}}
{{/names}}`)
36 | require.NoError(t, err)
37 |
38 | engine := &HandlebarsEngine{}
39 | writer := &bytes.Buffer{}
40 | err = engine.RenderFile(file.Name(), writer, map[string]any{
41 | "names": []string{"John", "Doe"},
42 | })
43 |
44 | require.NoError(t, err)
45 | require.Equal(t, `
46 | Hi John
Hi Doe
`, writer.String())
47 | }
48 |
49 | func TestHandlebarsRenderReader(t *testing.T) {
50 | engine := &HandlebarsEngine{}
51 | writer := &bytes.Buffer{}
52 | err := engine.Render(bytes.NewBufferString("Hello, {{ Name }}! You are {{ Age }} years old."),
53 | writer,
54 | map[string]any{
55 | "Name": "John",
56 | "Age": 20,
57 | })
58 | require.NoError(t, err)
59 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
60 | }
61 |
--------------------------------------------------------------------------------
/internal/engines/jinja_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "testing"
7 |
8 | "github.com/stretchr/testify/require"
9 | )
10 |
11 | func TestJinjaRenderFile(t *testing.T) {
12 | dir := t.TempDir()
13 | file, err := os.CreateTemp(dir, "test.txt")
14 | require.NoError(t, err)
15 |
16 | _, err = file.WriteString("Hello, {{ Name }}! You are {{ Age }} years old.")
17 | require.NoError(t, err)
18 |
19 | engine := &JinjaEngine{}
20 | writer := &bytes.Buffer{}
21 | err = engine.RenderFile(file.Name(), writer, map[string]any{
22 | "Name": "John",
23 | "Age": 20,
24 | })
25 | require.NoError(t, err)
26 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
27 | }
28 |
29 | func TestJinjaRenderFileAdvanced(t *testing.T) {
30 | dir := t.TempDir()
31 | file, err := os.CreateTemp(dir, "test.txt")
32 | require.NoError(t, err)
33 |
34 | _, err = file.WriteString(`
35 | {% macro foo(v) -%}
36 | Version is: {{ v }}
37 | {%- endmacro %}
38 |
39 | {{ foo(version) }}`)
40 | require.NoError(t, err)
41 |
42 | engine := &JinjaEngine{}
43 | writer := &bytes.Buffer{}
44 | err = engine.RenderFile(file.Name(), writer, map[string]any{
45 | "version": "1.2.3",
46 | })
47 |
48 | require.NoError(t, err)
49 | require.Equal(t, `
50 |
51 |
52 | Version is: 1.2.3`, writer.String())
53 | }
54 |
55 | func TestJinjaRenderReader(t *testing.T) {
56 | engine := &JinjaEngine{}
57 | writer := &bytes.Buffer{}
58 | err := engine.Render(bytes.NewBufferString("Hello, {{ Name }}! You are {{ Age }} years old."),
59 | writer,
60 | map[string]any{
61 | "Name": "John",
62 | "Age": 20,
63 | })
64 | require.NoError(t, err)
65 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
66 | }
67 |
--------------------------------------------------------------------------------
/internal/app/validate.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "errors"
5 | )
6 |
7 | var (
8 | ErrNoInput = errors.New("input is required")
9 | ErrInputStringAndDirConflict = errors.New("only one of input or input-dir can be set")
10 | ErrInputStringAndFileConflict = errors.New("only one of input or file can be set")
11 | ErrInputFileAndDirConflict = errors.New("only one of input or file can be set")
12 | ErrInputFileAndExcludeConflict = errors.New("exclude cannot be used with file")
13 | ErrInputStringAndExcludeConflict = errors.New("exclude cannot be used with input string")
14 | ErrNoOutput = errors.New("output is required")
15 | ErrDataRequired = errors.New("data is required through the datasource or data flags")
16 | )
17 |
18 | func (a *App) validateFlags(
19 | inputString string,
20 | inputDir string,
21 | inputFile string,
22 | datasource []string,
23 | data []string,
24 | excludePatterns []string,
25 | engine string,
26 | ) error {
27 | if len(inputString) == 0 && len(inputDir) == 0 && len(inputFile) == 0 {
28 | return ErrNoInput
29 | }
30 |
31 | if len(inputString) > 0 && len(inputDir) > 0 {
32 | return ErrInputStringAndDirConflict
33 | }
34 |
35 | if len(inputString) > 0 && len(inputFile) > 0 {
36 | return ErrInputStringAndFileConflict
37 | }
38 |
39 | if len(inputDir) > 0 && len(inputFile) > 0 {
40 | return ErrInputFileAndDirConflict
41 | }
42 |
43 | if len(datasource) == 0 && len(data) == 0 && engine != "envsubst" {
44 | return ErrDataRequired
45 | }
46 |
47 | if len(inputFile) > 0 && len(excludePatterns) > 0 {
48 | return ErrInputFileAndExcludeConflict
49 | }
50 |
51 | if len(inputString) > 0 && len(excludePatterns) > 0 {
52 | return ErrInputStringAndExcludeConflict
53 | }
54 |
55 | return nil
56 | }
57 |
--------------------------------------------------------------------------------
/internal/engines/jet_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "os"
7 | "testing"
8 |
9 | "github.com/stretchr/testify/require"
10 | )
11 |
12 | func TestRenderFile(t *testing.T) {
13 | dir := t.TempDir()
14 | file, err := os.CreateTemp(dir, "test.txt")
15 | require.NoError(t, err)
16 |
17 | _, err = file.WriteString("Hello, {{ Name }}! You are {{ Age }} years old.")
18 | require.NoError(t, err)
19 |
20 | engine := &JetEngine{}
21 | writer := &bytes.Buffer{}
22 | err = engine.RenderFile(file.Name(), writer, map[string]any{
23 | "Name": "John",
24 | "Age": 20,
25 | })
26 | require.NoError(t, err)
27 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
28 | }
29 |
30 | func TestRenderFileWithExtends(t *testing.T) {
31 | dir := t.TempDir()
32 | baseFile, err := os.CreateTemp(dir, "base.txt")
33 | require.NoError(t, err)
34 | _, err = baseFile.WriteString(`
35 | Contents:
36 | {{ block contents() }}{{ end }}`)
37 | require.NoError(t, err)
38 |
39 | childFile, err := os.CreateTemp(dir, "child.txt")
40 | require.NoError(t, err)
41 | _, err = childFile.WriteString(fmt.Sprintf(`
42 | {{ extends %q }}
43 | {{ block contents() }}
44 | File contents are here
45 | {{ end }}`, baseFile.Name()))
46 | require.NoError(t, err)
47 |
48 | engine := &JetEngine{}
49 | writer := &bytes.Buffer{}
50 | err = engine.RenderFile(childFile.Name(), writer, nil)
51 | require.NoError(t, err)
52 | require.Equal(t, `
53 | Contents:
54 |
55 | File contents are here
56 | `, writer.String())
57 | }
58 |
59 | func TestJetRenderReader(t *testing.T) {
60 | engine := &JetEngine{}
61 | writer := &bytes.Buffer{}
62 | err := engine.Render(bytes.NewBufferString("Hello, {{ Name }}! You are {{ Age }} years old."),
63 | writer,
64 | map[string]any{
65 | "Name": "John",
66 | "Age": 20,
67 | })
68 | require.NoError(t, err)
69 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
70 | }
71 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/orellazri/renderkit
2 |
3 | go 1.24.4
4 |
5 | require (
6 | github.com/CloudyKit/jet/v6 v6.3.1
7 | github.com/Masterminds/sprig/v3 v3.3.0
8 | github.com/a8m/envsubst v1.4.3
9 | github.com/aymerick/raymond v2.0.2+incompatible
10 | github.com/cbroglie/mustache v1.4.0
11 | github.com/gobwas/glob v0.2.3
12 | github.com/goreleaser/fileglob v1.3.0
13 | github.com/hashicorp/go-envparse v0.1.0
14 | github.com/nikolalohinski/gonja/v2 v2.4.0
15 | github.com/pelletier/go-toml/v2 v2.2.4
16 | github.com/stretchr/testify v1.9.0
17 | github.com/urfave/cli/v2 v2.27.7
18 | gopkg.in/yaml.v3 v3.0.1
19 | )
20 |
21 | require (
22 | dario.cat/mergo v1.0.2 // indirect
23 | github.com/BurntSushi/toml v1.5.0 // indirect
24 | github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
25 | github.com/Masterminds/goutils v1.1.1 // indirect
26 | github.com/Masterminds/semver/v3 v3.4.0 // indirect
27 | github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
28 | github.com/davecgh/go-spew v1.1.1 // indirect
29 | github.com/dustin/go-humanize v1.0.1 // indirect
30 | github.com/google/uuid v1.6.0 // indirect
31 | github.com/huandu/xstrings v1.5.0 // indirect
32 | github.com/json-iterator/go v1.1.12 // indirect
33 | github.com/mitchellh/copystructure v1.2.0 // indirect
34 | github.com/mitchellh/reflectwalk v1.0.2 // indirect
35 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36 | github.com/modern-go/reflect2 v1.0.2 // indirect
37 | github.com/pkg/errors v0.9.1 // indirect
38 | github.com/pmezard/go-difflib v1.0.0 // indirect
39 | github.com/russross/blackfriday/v2 v2.1.0 // indirect
40 | github.com/shopspring/decimal v1.4.0 // indirect
41 | github.com/sirupsen/logrus v1.9.3 // indirect
42 | github.com/spf13/cast v1.10.0 // indirect
43 | github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
44 | golang.org/x/crypto v0.42.0 // indirect
45 | golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
46 | golang.org/x/sys v0.36.0 // indirect
47 | golang.org/x/text v0.29.0 // indirect
48 | )
49 |
--------------------------------------------------------------------------------
/internal/engines/gotemplates_test.go:
--------------------------------------------------------------------------------
1 | package engines
2 |
3 | import (
4 | "bytes"
5 | "os"
6 | "testing"
7 |
8 | "github.com/stretchr/testify/require"
9 | )
10 |
11 | func TestGoTemplatesRenderFile(t *testing.T) {
12 | dir := t.TempDir()
13 | file, err := os.CreateTemp(dir, "test.txt")
14 | require.NoError(t, err)
15 |
16 | _, err = file.WriteString("Hello, {{ .Name }}! You are {{ .Age }} years old.")
17 | require.NoError(t, err)
18 |
19 | engine := &GoTemplatesEngine{}
20 | writer := &bytes.Buffer{}
21 | err = engine.RenderFile(file.Name(), writer, map[string]any{
22 | "Name": "John",
23 | "Age": 20,
24 | })
25 | require.NoError(t, err)
26 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
27 | }
28 |
29 | func TestGoTemplatesRenderFileAdvanced(t *testing.T) {
30 | dir := t.TempDir()
31 | file, err := os.CreateTemp(dir, "test.txt")
32 | require.NoError(t, err)
33 |
34 | _, err = file.WriteString(`
35 | {{range $name := .names}}Hi {{$name}}
{{end}}`)
36 | require.NoError(t, err)
37 |
38 | engine := &GoTemplatesEngine{}
39 | writer := &bytes.Buffer{}
40 | err = engine.RenderFile(file.Name(), writer, map[string]any{
41 | "names": []string{"John", "Doe"},
42 | })
43 |
44 | require.NoError(t, err)
45 | require.Equal(t, `
46 | Hi John
Hi Doe
`, writer.String())
47 | }
48 |
49 | func TestGoTemplatesRenderFileWithSprigFunctions(t *testing.T) {
50 | dir := t.TempDir()
51 | file, err := os.CreateTemp(dir, "test.txt")
52 | require.NoError(t, err)
53 |
54 | _, err = file.WriteString(`
55 | {{ "hello!" | upper | repeat 5 }}`)
56 | require.NoError(t, err)
57 |
58 | engine := &GoTemplatesEngine{}
59 | writer := &bytes.Buffer{}
60 | err = engine.RenderFile(file.Name(), writer, map[string]any{
61 | "names": []string{"John", "Doe"},
62 | })
63 |
64 | require.NoError(t, err)
65 | require.Equal(t, `
66 | HELLO!HELLO!HELLO!HELLO!HELLO!`, writer.String())
67 | }
68 |
69 | func TestGoTemplatesRenderReader(t *testing.T) {
70 | engine := &GoTemplatesEngine{}
71 | writer := &bytes.Buffer{}
72 | err := engine.Render(bytes.NewBufferString("Hello, {{ .Name }}! You are {{ .Age }} years old."),
73 | writer,
74 | map[string]any{
75 | "Name": "John",
76 | "Age": 20,
77 | })
78 | require.NoError(t, err)
79 | require.Equal(t, "Hello, John! You are 20 years old.", writer.String())
80 | }
81 |
--------------------------------------------------------------------------------
/internal/app/validate_test.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/require"
7 | )
8 |
9 | func TestValidateFlagsNoErrors(t *testing.T) {
10 | app := NewApp("test")
11 | err := app.validateFlags(
12 | "",
13 | "",
14 | "input.txt",
15 | []string{"ds.yaml"},
16 | nil,
17 | nil,
18 | "",
19 | )
20 | require.NoError(t, err)
21 | }
22 |
23 | func TestValidateFlagsNoData(t *testing.T) {
24 | app := NewApp("test")
25 |
26 | err := app.validateFlags(
27 | "",
28 | "",
29 | "input.txt",
30 | nil,
31 | nil,
32 | nil,
33 | "",
34 | )
35 | require.Error(t, err)
36 | require.ErrorIs(t, err, ErrDataRequired)
37 | }
38 |
39 | func TestValidateFlagsNoDataWithEnvsubstEngine(t *testing.T) {
40 | app := NewApp("test")
41 |
42 | err := app.validateFlags(
43 | "",
44 | "",
45 | "input.txt",
46 | nil,
47 | nil,
48 | nil,
49 | "envsubst",
50 | )
51 | require.NoError(t, err)
52 | }
53 |
54 | func TestValidateFlagsNoInput(t *testing.T) {
55 | app := NewApp("test")
56 | err := app.validateFlags(
57 | "",
58 | "",
59 | "",
60 | []string{"ds.yaml"},
61 | nil,
62 | nil,
63 | "",
64 | )
65 | require.Error(t, err)
66 | require.ErrorIs(t, err, ErrNoInput)
67 | }
68 |
69 | func TestValidateFlagsInputFileAndDirConflict(t *testing.T) {
70 | app := NewApp("test")
71 | err := app.validateFlags(
72 | "",
73 | "input/",
74 | "input.txt",
75 | []string{"ds.yaml"},
76 | nil,
77 | nil,
78 | "",
79 | )
80 | require.Error(t, err)
81 | require.ErrorIs(t, err, ErrInputFileAndDirConflict)
82 | }
83 |
84 | func TestValidateFlagsInputStringAndFileConflict(t *testing.T) {
85 | app := NewApp("test")
86 | err := app.validateFlags(
87 | "input-string",
88 | "",
89 | "input",
90 | []string{"ds.yaml"},
91 | nil,
92 | nil,
93 | "",
94 | )
95 | require.Error(t, err)
96 | require.ErrorIs(t, err, ErrInputStringAndFileConflict)
97 | }
98 |
99 | func TestValidateFlagsInputStringAndDirConflict(t *testing.T) {
100 | app := NewApp("test")
101 | err := app.validateFlags(
102 | "input-string",
103 | "input/",
104 | "",
105 | []string{"ds.yaml"},
106 | nil,
107 | nil,
108 | "",
109 | )
110 | require.Error(t, err)
111 | require.ErrorIs(t, err, ErrInputStringAndDirConflict)
112 | }
113 |
114 | func TestValidateFlagsInputFileAndExcludeConflict(t *testing.T) {
115 | app := NewApp("test")
116 | err := app.validateFlags(
117 | "",
118 | "",
119 | "input.txt",
120 | []string{"ds.yaml"},
121 | nil,
122 | []string{"exclude.txt"},
123 | "",
124 | )
125 | require.Error(t, err)
126 | require.ErrorIs(t, err, ErrInputFileAndExcludeConflict)
127 | }
128 |
129 | func TestValidateFlagsInputStringAndExcludeConflict(t *testing.T) {
130 | app := NewApp("test")
131 | err := app.validateFlags(
132 | "input-string",
133 | "",
134 | "",
135 | []string{"ds.yaml"},
136 | nil,
137 | []string{"exclude.txt"},
138 | "",
139 | )
140 | require.Error(t, err)
141 | require.ErrorIs(t, err, ErrInputStringAndExcludeConflict)
142 | }
143 |
--------------------------------------------------------------------------------
/internal/app/render.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "bytes"
5 | "errors"
6 | "fmt"
7 | "io"
8 | "os"
9 | "path/filepath"
10 | "slices"
11 |
12 | "github.com/gobwas/glob"
13 | )
14 |
15 | func (a *App) render(
16 | inputString string,
17 | inputDir string,
18 | inputFile string,
19 | outputDir string,
20 | excludePaths []string,
21 | excludeFileGlobs []string,
22 | data map[string]any,
23 | ) error {
24 | var output io.Writer = os.Stdout
25 | var closer func()
26 | var err error
27 |
28 | if len(inputString) > 0 { // Render input string
29 | if len(outputDir) > 0 {
30 | output, closer, err = createOutputFileWithDir(filepath.Join(outputDir, "renderkit_output"))
31 | if err != nil {
32 | return err
33 | }
34 | defer closer()
35 | }
36 | return a.renderString(inputString, output, data)
37 | } else if len(inputFile) > 0 { // Render input file
38 | if len(outputDir) > 0 {
39 | output, closer, err = createOutputFileWithDir(filepath.Join(outputDir, filepath.Base(inputFile)))
40 | if err != nil {
41 | return err
42 | }
43 | defer closer()
44 | }
45 | return a.renderFile(inputFile, output, data)
46 | } else if len(inputDir) > 0 { // Render input directory
47 | return a.renderDir(inputDir, outputDir, excludePaths, excludeFileGlobs, data)
48 | }
49 |
50 | return errors.New("unsupported mode")
51 | }
52 |
53 | func (a *App) renderDir(inputDirpath string, outputDirpath string, excludePaths, excludeFileGlobs []string, data map[string]any) error {
54 | err := filepath.WalkDir(inputDirpath, func(path string, d os.DirEntry, err error) error {
55 | if err != nil {
56 | return err
57 | }
58 |
59 | if d.IsDir() {
60 | return nil
61 | }
62 |
63 | relPath, err := filepath.Rel(inputDirpath, path)
64 | if err != nil {
65 | return fmt.Errorf("get relative path: %s", err)
66 | }
67 |
68 | var output io.Writer = os.Stdout
69 | var closer func()
70 | if slices.Contains(excludePaths, filepath.Join(inputDirpath, relPath)) {
71 | return nil
72 | }
73 | for _, fg := range excludeFileGlobs {
74 | cg, _ := glob.Compile(fg)
75 | if cg.Match(relPath) || cg.Match(filepath.Base(relPath)) {
76 | return nil
77 | }
78 | }
79 |
80 | if len(outputDirpath) > 0 {
81 | output, closer, err = createOutputFileWithDir(filepath.Join(outputDirpath, relPath))
82 | if err != nil {
83 | return err
84 | }
85 | defer closer()
86 | }
87 | if err := a.renderFile(path, output, data); err != nil {
88 | return fmt.Errorf("render file %q: %s", path, err)
89 | }
90 |
91 | return nil
92 | })
93 | if err != nil {
94 | return fmt.Errorf("walk directory %q: %s", inputDirpath, err)
95 | }
96 |
97 | return nil
98 | }
99 |
100 | func (a *App) renderFile(inputFilepath string, output io.Writer, data map[string]any) error {
101 | if err := a.engine.RenderFile(inputFilepath, output, data); err != nil {
102 | return fmt.Errorf("render template: %s", err)
103 | }
104 |
105 | return nil
106 | }
107 |
108 | func (a *App) renderString(inputString string, output io.Writer, data map[string]any) error {
109 | if err := a.engine.Render(bytes.NewReader([]byte(inputString)), output, data); err != nil {
110 | return fmt.Errorf("render template: %s", err)
111 | }
112 |
113 | return nil
114 | }
115 |
116 | func createOutputFileWithDir(outputFilepath string) (io.Writer, func(), error) {
117 | outputDirpath := filepath.Dir(outputFilepath)
118 | if err := os.MkdirAll(outputDirpath, os.ModePerm); err != nil {
119 | return nil, nil, fmt.Errorf("create output directory %s: %s", outputDirpath, err)
120 | }
121 |
122 | outputFile, err := os.Create(outputFilepath)
123 | if err != nil {
124 | return nil, nil, fmt.Errorf("create output file %s: %s", outputFilepath, err)
125 | }
126 |
127 | return outputFile, func() { outputFile.Close() }, nil
128 | }
129 |
--------------------------------------------------------------------------------
/internal/app/render_test.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "os"
7 | "path/filepath"
8 | "testing"
9 |
10 | "github.com/orellazri/renderkit/internal/engines"
11 | "github.com/stretchr/testify/require"
12 | )
13 |
14 | func TestRenderDir(t *testing.T) {
15 | dir := t.TempDir()
16 | inputDir := filepath.Join(dir, "input")
17 | err := os.Mkdir(inputDir, os.ModePerm)
18 |
19 | require.NoError(t, err)
20 | inputFiles := []string{
21 | filepath.Join(inputDir, "input1.txt"),
22 | filepath.Join(inputDir, "input2.txt"),
23 | }
24 | for _, inputFile := range inputFiles {
25 | err := os.WriteFile(inputFile, []byte("Hello, {{ .Name }}!"), os.ModePerm)
26 | require.NoError(t, err)
27 | }
28 | outputDir := filepath.Join(dir, "output")
29 |
30 | app := &App{
31 | engine: &engines.GoTemplatesEngine{},
32 | }
33 | err = app.render(
34 | "",
35 | inputDir,
36 | "",
37 | outputDir,
38 | nil,
39 | nil,
40 | map[string]any{
41 | "Name": "John",
42 | },
43 | )
44 | require.NoError(t, err)
45 | outputFiles, err := os.ReadDir(outputDir)
46 | require.NoError(t, err)
47 | require.Len(t, outputFiles, 2)
48 | for _, outputFile := range outputFiles {
49 | content, err := os.ReadFile(filepath.Join(outputDir, outputFile.Name()))
50 | require.NoError(t, err)
51 | expectedContent := fmt.Sprintf("Hello, %s!", "John")
52 | require.Equal(t, expectedContent, string(content))
53 | }
54 | }
55 | func TestRenderDirWithSubpaths(t *testing.T) {
56 | dir := t.TempDir()
57 | inputDir := filepath.Join(dir, "input")
58 | err := os.Mkdir(inputDir, os.ModePerm)
59 | require.NoError(t, err)
60 |
61 | inputSubdir1 := filepath.Join(inputDir, "subdir1")
62 | err = os.Mkdir(inputSubdir1, os.ModePerm)
63 | require.NoError(t, err)
64 | inputSubdir2 := filepath.Join(inputDir, "subdir2")
65 | err = os.Mkdir(inputSubdir2, os.ModePerm)
66 | require.NoError(t, err)
67 |
68 | inputFiles := []string{
69 | filepath.Join(inputSubdir1, "file1.txt"),
70 | filepath.Join(inputSubdir2, "file2.txt"),
71 | }
72 | for _, inputFile := range inputFiles {
73 | err := os.WriteFile(inputFile, []byte("Hello!"), os.ModePerm)
74 | require.NoError(t, err)
75 | }
76 |
77 | outputDir := filepath.Join(dir, "output")
78 | app := &App{
79 | engine: &engines.GoTemplatesEngine{},
80 | }
81 |
82 | err = app.renderDir(inputDir, outputDir, nil, nil, nil)
83 | require.NoError(t, err)
84 |
85 | _, err = os.Stat(filepath.Join(outputDir, "subdir1", "file1.txt"))
86 | require.NoError(t, err)
87 | _, err = os.Stat(filepath.Join(outputDir, "subdir2", "file2.txt"))
88 | require.NoError(t, err)
89 | }
90 |
91 | func TestRenderFile(t *testing.T) {
92 | dir := t.TempDir()
93 | inputFile := filepath.Join(dir, "input.txt")
94 | err := os.WriteFile(inputFile, []byte("Hello, {{ .Name }}!"), os.ModePerm)
95 | require.NoError(t, err)
96 | outputDir := filepath.Join(dir, "output")
97 | app := &App{
98 | engine: &engines.GoTemplatesEngine{},
99 | }
100 | err = app.render(
101 | "",
102 | "",
103 | inputFile,
104 | outputDir,
105 | nil,
106 | nil,
107 | map[string]any{
108 | "Name": "John",
109 | },
110 | )
111 | require.NoError(t, err)
112 | outputFile := filepath.Join(outputDir, filepath.Base(inputFile))
113 | content, err := os.ReadFile(outputFile)
114 | require.NoError(t, err)
115 | expectedContent := fmt.Sprintf("Hello, %s!", "John")
116 | require.Equal(t, expectedContent, string(content))
117 | }
118 |
119 | func TestRenderFromString(t *testing.T) {
120 | app := &App{
121 | engine: &engines.GoTemplatesEngine{},
122 | }
123 | input := "Hello, {{ .Name }}!"
124 | buf := &bytes.Buffer{}
125 | err := app.renderString(input, buf, map[string]any{
126 | "Name": "John",
127 | })
128 | require.NoError(t, err)
129 | require.Equal(t, "Hello, John!", buf.String())
130 | }
131 |
132 | func TestRenderFromStringToFile(t *testing.T) {
133 | tmpDir := t.TempDir()
134 | app := &App{
135 | engine: &engines.GoTemplatesEngine{},
136 | }
137 | err := app.render(
138 | "Hello, {{ .Name }}!",
139 | "",
140 | "",
141 | tmpDir,
142 | nil,
143 | nil,
144 | map[string]any{
145 | "Name": "John",
146 | },
147 | )
148 | require.NoError(t, err)
149 | outputFile := filepath.Join(tmpDir, "renderkit_output")
150 | content, err := os.ReadFile(outputFile)
151 | require.NoError(t, err)
152 | require.Equal(t, "Hello, John!", string(content))
153 | }
154 |
--------------------------------------------------------------------------------
/internal/app/app_integration_test.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "fmt"
5 | "net/http"
6 | "net/http/httptest"
7 | "os"
8 | "path/filepath"
9 | "testing"
10 |
11 | "github.com/stretchr/testify/require"
12 | )
13 |
14 | func TestIntegrationAllEngines(t *testing.T) {
15 | if testing.Short() {
16 | t.Skip("skipping integration test")
17 | }
18 |
19 | // Create output directory
20 | outputDir := t.TempDir()
21 |
22 | // Create datasource files
23 | datasourceDir := t.TempDir()
24 | datasource1File, err := os.Create(filepath.Join(datasourceDir, "ds.yaml"))
25 | require.NoError(t, err)
26 | _, err = datasource1File.WriteString("Name: John")
27 | require.NoError(t, err)
28 |
29 | // Define the input syntax for each engine
30 | inputSyntax := map[string]string{
31 | "envsubst": "Hello, my name is ${Name}. I am ${Age} years old.",
32 | "gotemplates": `Hello, my name is {{ .Name }}. I am {{ .Age }} years old.`,
33 | "handlebars": `Hello, my name is {{ Name }}. I am {{ Age }} years old.`,
34 | "jet": `Hello, my name is {{ Name }}. I am {{ Age }} years old.`,
35 | "jinja": `Hello, my name is {{ Name }}. I am {{ Age }} years old.`,
36 | "mustache": `Hello, my name is {{ Name }}. I am {{ Age }} years old.`,
37 | }
38 | require.Equal(t, len(enginesMap), len(inputSyntax), "all engines must be tested")
39 |
40 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
41 | w.Header().Set("Content-Type", "application/json")
42 | _, err = fmt.Fprint(w, `{"Age": 31.5}`)
43 | require.NoError(t, err)
44 | }))
45 | defer ts.Close()
46 |
47 | for engine, syntax := range inputSyntax {
48 | inputDir := t.TempDir()
49 | inputFile, err := os.Create(filepath.Join(inputDir, "file.txt"))
50 | require.NoError(t, err)
51 | _, err = inputFile.WriteString(syntax)
52 | require.NoError(t, err)
53 |
54 | // Run the app for each engine
55 | app := NewApp("test")
56 | err = app.Run([]string{
57 | "",
58 | "--input-dir", inputDir,
59 | "--output", outputDir,
60 | "--datasource", datasource1File.Name(),
61 | "--datasource", ts.URL,
62 | "--engine", engine,
63 | })
64 | require.NoError(t, err)
65 |
66 | // Check the output files
67 | outputFile1 := filepath.Join(outputDir, "file.txt")
68 | outputContent1, err := os.ReadFile(outputFile1)
69 | require.NoError(t, err)
70 | require.Equal(t, "Hello, my name is John. I am 31.5 years old.", string(outputContent1))
71 | }
72 | }
73 |
74 | func TestIntegrationInputOutputSubdirsMirrored(t *testing.T) {
75 | if testing.Short() {
76 | t.Skip("skipping integration test")
77 | }
78 |
79 | // Create input files
80 | inputDir := t.TempDir()
81 | inputSubdir1 := filepath.Join(inputDir, "subdir1")
82 | err := os.Mkdir(inputSubdir1, os.ModePerm)
83 | require.NoError(t, err)
84 | inputSubdir2 := filepath.Join(inputDir, "subdir2")
85 | err = os.Mkdir(inputSubdir2, os.ModePerm)
86 | require.NoError(t, err)
87 | inputSubdir3 := filepath.Join(inputDir, "subdir3")
88 | err = os.Mkdir(inputSubdir3, os.ModePerm)
89 | require.NoError(t, err)
90 |
91 | inputFiles := []string{
92 | filepath.Join(inputSubdir1, "file1.txt"),
93 | filepath.Join(inputSubdir2, "file2.txt"),
94 | filepath.Join(inputSubdir3, "file3.txt"),
95 | }
96 |
97 | err = os.WriteFile(inputFiles[0], []byte("My name is {{ .Name }} and I am {{ .Age }} years old"), os.ModePerm)
98 | require.NoError(t, err)
99 | err = os.WriteFile(inputFiles[1], []byte("I am {{ .Age }} years old. This file will be excluded."), os.ModePerm)
100 | require.NoError(t, err)
101 | err = os.WriteFile(inputFiles[2], []byte("I am {{ .Age }} years old. This file will also be excluded."), os.ModePerm)
102 | require.NoError(t, err)
103 |
104 | // Create output directory
105 | outputDir := t.TempDir()
106 |
107 | // Create datasource files
108 | datasourceDir := t.TempDir()
109 | datasource1File, err := os.Create(filepath.Join(datasourceDir, "ds.yaml"))
110 | require.NoError(t, err)
111 | _, err = datasource1File.WriteString("Name: John")
112 | require.NoError(t, err)
113 | datasource2File, err := os.Create(filepath.Join(datasourceDir, "ds2.json"))
114 | require.NoError(t, err)
115 | _, err = datasource2File.WriteString(`{"Age": 31.5}`)
116 | require.NoError(t, err)
117 |
118 | app := NewApp("test")
119 | err = app.Run([]string{
120 | "",
121 | "--input-dir", inputDir,
122 | "--exclude", fmt.Sprintf("%s/*2.txt", inputSubdir2),
123 | "--exclude", "*3.txt",
124 | "--output", outputDir,
125 | "--datasource", datasource1File.Name(),
126 | "--datasource", datasource2File.Name(),
127 | })
128 | require.NoError(t, err)
129 |
130 | // Check the output files
131 | outputFile1 := filepath.Join(outputDir, "subdir1", "file1.txt")
132 | outputContent1, err := os.ReadFile(outputFile1)
133 | require.NoError(t, err)
134 | require.Equal(t, "My name is John and I am 31.5 years old", string(outputContent1))
135 |
136 | // Check that the excluded files aren't present
137 | outputFile2 := filepath.Join(outputDir, "subdir2", "file2.txt")
138 | _, err = os.Stat(outputFile2)
139 | require.ErrorIs(t, err, os.ErrNotExist)
140 | outputFile3 := filepath.Join(outputDir, "subdir3", "file3.txt")
141 | _, err = os.Stat(outputFile3)
142 | require.ErrorIs(t, err, os.ErrNotExist)
143 | }
144 |
--------------------------------------------------------------------------------
/internal/app/parse.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "fmt"
5 | "io"
6 | "mime"
7 | "net/http"
8 | "net/url"
9 | "os"
10 | "path/filepath"
11 | "slices"
12 | "strings"
13 |
14 | "github.com/goreleaser/fileglob"
15 | "github.com/orellazri/renderkit/internal/datasources"
16 | "github.com/orellazri/renderkit/internal/engines"
17 | )
18 |
19 | var enginesMap = map[string]engines.Engine{
20 | "envsubst": &engines.EnvsubstEngine{},
21 | "gotemplates": &engines.GoTemplatesEngine{},
22 | "handlebars": &engines.HandlebarsEngine{},
23 | "jet": &engines.JetEngine{},
24 | "jinja": &engines.JinjaEngine{},
25 | "mustache": &engines.MustacheEngine{},
26 | }
27 |
28 | func (a *App) parseDatasourceUrls(datasources []string) ([]*url.URL, error) {
29 | datasourceUrls := make([]*url.URL, len(datasources))
30 | for i, ds := range datasources {
31 | url, err := url.Parse(ds)
32 | if err != nil {
33 | return nil, fmt.Errorf("invalid url %s: %s", ds, err)
34 | }
35 | datasourceUrls[i] = url
36 | }
37 |
38 | return datasourceUrls, nil
39 | }
40 |
41 | func (a *App) loadDatasources(datasourceUrls []*url.URL, extraData []string, allowDuplicateKeys bool) (map[string]any, error) {
42 | duplicateKeys := []string{} // We keep track of duplicate keys to return a more informative error message
43 | data := make(map[string]any)
44 |
45 | // Load extra data
46 | for _, d := range extraData {
47 | kv := strings.SplitN(d, "=", 2)
48 | if _, ok := data[kv[0]]; ok && !allowDuplicateKeys {
49 | duplicateKeys = append(duplicateKeys, kv[0])
50 | }
51 | data[kv[0]] = kv[1]
52 | }
53 |
54 | for _, url := range datasourceUrls {
55 | ds, f, err := a.createDatasourceFromURL(url)
56 | if err != nil {
57 | return nil, fmt.Errorf("create datasource %q: %s", url, err)
58 | }
59 | if f != nil {
60 | defer f.Close()
61 | }
62 |
63 | dsData, err := ds.Load()
64 | if err != nil {
65 | return nil, fmt.Errorf("load datasource %q: %s", url, err)
66 | }
67 |
68 | // Merge with data dictionary
69 | for k, v := range dsData {
70 | if _, ok := data[k]; ok && !allowDuplicateKeys {
71 | duplicateKeys = append(duplicateKeys, k)
72 | }
73 | data[k] = v
74 | }
75 | }
76 |
77 | if len(duplicateKeys) > 0 {
78 | return nil, fmt.Errorf("duplicate keys found in datasources: %s", strings.Join(duplicateKeys, ", "))
79 | }
80 |
81 | return data, nil
82 | }
83 |
84 | func (a *App) createDatasourceFromURL(url *url.URL) (datasources.Datasource, io.ReadCloser, error) {
85 | urlWithoutPrefix := strings.TrimPrefix(url.String(), fmt.Sprintf("%s://", url.Scheme))
86 |
87 | switch url.Scheme {
88 | case "":
89 | f, err := os.Open(urlWithoutPrefix)
90 | if err != nil {
91 | return nil, nil, err
92 | }
93 | switch filepath.Ext(urlWithoutPrefix) {
94 | case ".yaml", ".yml":
95 | return datasources.NewYamlDatasource(f), f, nil
96 | case ".json":
97 | return datasources.NewJsonDatasource(f), f, nil
98 | case ".toml":
99 | return datasources.NewTomlDatasource(f), f, nil
100 | case ".env":
101 | return datasources.NewEnvFileDatasource(f), f, nil
102 | default:
103 | return nil, nil, fmt.Errorf("unsupported file extension: %s", filepath.Ext(urlWithoutPrefix))
104 | }
105 | case "env":
106 | variable := ""
107 | if url.Host != "" {
108 | variable = urlWithoutPrefix
109 | }
110 | return datasources.NewEnvDatasource(variable), nil, nil
111 | case "http", "https":
112 | res, err := http.Get(url.String())
113 | if err != nil {
114 | return nil, nil, err
115 | }
116 |
117 | ct := res.Header.Get("Content-Type")
118 | mt, _, _ := mime.ParseMediaType(ct)
119 |
120 | var targetDs datasources.Datasource
121 |
122 | switch mt {
123 | case "application/json":
124 | targetDs = datasources.NewJsonDatasource(res.Body)
125 | case "application/toml":
126 | targetDs = datasources.NewTomlDatasource(res.Body)
127 | case "application/yaml", "text/yaml", "text/x-yaml", "application/x-yaml":
128 | targetDs = datasources.NewYamlDatasource(res.Body)
129 | default:
130 | return nil, nil, fmt.Errorf("unsupported content type: %s", mt)
131 | }
132 |
133 | return targetDs, res.Body, nil
134 | default:
135 | return nil, nil, fmt.Errorf("scheme not supported: %s", url.Scheme)
136 | }
137 | }
138 |
139 | func (a *App) compileGlob(pattern string) ([]string, error) {
140 | if err := fileglob.ValidPattern(pattern); err != nil {
141 | return nil, fmt.Errorf("invalid glob pattern: %q", err)
142 | }
143 | matches, err := fileglob.Glob(pattern, fileglob.MaybeRootFS)
144 | if err != nil {
145 | return nil, fmt.Errorf("glob %q: %s", pattern, err)
146 | }
147 |
148 | return matches, nil
149 | }
150 |
151 | func (a *App) aggregateExcludePatterns(excludePatterns []string) ([]string, []string, error) {
152 | var excludePaths []string
153 | var excludeFileGlobs []string
154 | for _, pattern := range excludePatterns {
155 | if !strings.Contains(pattern, "/") { // verify the glob isn't a path
156 | excludeFileGlobs = append(excludeFileGlobs, pattern)
157 | continue
158 | }
159 | excludeFiles, err := a.compileGlob(pattern)
160 | if err != nil {
161 | return nil, nil, fmt.Errorf("compile exclude glob %q: %s", pattern, err)
162 | }
163 | excludePaths = slices.Concat(excludePaths, excludeFiles)
164 | }
165 | slices.Sort(excludePaths)
166 | excludePaths = slices.Compact(excludePaths)
167 |
168 | return excludePaths, excludeFileGlobs, nil
169 | }
170 |
--------------------------------------------------------------------------------
/internal/app/app.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "log"
7 | "os"
8 | "strings"
9 |
10 | "github.com/orellazri/renderkit/internal/engines"
11 | "github.com/urfave/cli/v2"
12 | "github.com/urfave/cli/v2/altsrc"
13 | )
14 |
15 | type App struct {
16 | cliApp *cli.App
17 | engine engines.Engine
18 | }
19 |
20 | func NewApp(version string) *App {
21 | a := App{}
22 |
23 | // Create a list of engine names to display in the CLI help
24 | engineMapKeys := make([]string, 0, len(enginesMap))
25 | for k := range enginesMap {
26 | engineMapKeys = append(engineMapKeys, k)
27 | }
28 | enginesListStr := strings.Join(engineMapKeys, ", ")
29 |
30 | flags := []cli.Flag{
31 | &cli.StringFlag{
32 | Name: "config",
33 | Aliases: []string{"c"},
34 | Usage: "Load configuration from YAML file",
35 | },
36 | altsrc.NewStringFlag(&cli.StringFlag{
37 | Name: "input",
38 | Aliases: []string{"i"},
39 | Usage: "Template string to render",
40 | }),
41 | altsrc.NewStringFlag(&cli.StringFlag{
42 | Name: "input-file",
43 | Aliases: []string{"f"},
44 | Usage: "Template input file to render",
45 | }),
46 | altsrc.NewStringFlag(&cli.StringFlag{
47 | Name: "input-dir",
48 | Aliases: []string{"d"},
49 | Usage: "Template input directory to render",
50 | }),
51 | altsrc.NewStringSliceFlag(&cli.StringSliceFlag{
52 | Name: "exclude",
53 | Aliases: []string{"x"},
54 | Usage: "Exclude files/directories using path-based glob patterns",
55 | DefaultText: "",
56 | }),
57 | altsrc.NewStringFlag(&cli.StringFlag{
58 | Name: "output",
59 | Aliases: []string{"o"},
60 | Usage: "Output directory to write to",
61 | }),
62 | altsrc.NewStringSliceFlag(&cli.StringSliceFlag{
63 | Name: "datasource",
64 | Aliases: []string{"ds"},
65 | Usage: "Datasource to use for rendering (scheme://path)",
66 | }),
67 | altsrc.NewStringSliceFlag(&cli.StringSliceFlag{
68 | Name: "data",
69 | Usage: "Data to use for rendering. Can be used to provide data directly",
70 | }),
71 | altsrc.NewStringFlag(&cli.StringFlag{
72 | Name: "engine",
73 | Aliases: []string{"e"},
74 | Usage: fmt.Sprintf("Templating engine to use for rendering (%s)", enginesListStr),
75 | Action: func(cCtx *cli.Context, value string) error {
76 | if _, ok := enginesMap[value]; !ok {
77 | return fmt.Errorf("engine %s is not supported. supported engines: %s", value, enginesListStr)
78 | }
79 | return nil
80 | },
81 | }),
82 | altsrc.NewBoolFlag(&cli.BoolFlag{
83 | Name: "allow-duplicate-keys",
84 | Usage: "Allow duplicate keys in datasources. If set, the last value found will be used",
85 | DefaultText: "false",
86 | }),
87 | }
88 |
89 | app := &cli.App{
90 | Name: "renderkit",
91 | Usage: "A swiss army knife CLI tool for rendering templates",
92 | Flags: flags,
93 | Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("config")),
94 | Action: a.run,
95 | Version: version,
96 | }
97 |
98 | a.cliApp = app
99 | return &a
100 | }
101 |
102 | func (a *App) Run(args []string) error {
103 | return a.cliApp.Run(args)
104 | }
105 |
106 | func (a *App) run(cCtx *cli.Context) error {
107 | var inputString string
108 |
109 | // Read from stdin into an input string; and if empty, from input flag
110 | stat, _ := os.Stdin.Stat()
111 | if (stat.Mode() & os.ModeCharDevice) == 0 {
112 | var stdinBytes []byte
113 | scanner := bufio.NewScanner(os.Stdin)
114 | for scanner.Scan() {
115 | stdinBytes = append(stdinBytes, scanner.Bytes()...)
116 | }
117 | if err := scanner.Err(); err != nil {
118 | log.Fatalf("Failed to read from stdin: %s", err)
119 | }
120 | inputString = string(stdinBytes)
121 | } else if len(cCtx.String("input")) > 0 {
122 | inputString = cCtx.String("input")
123 | }
124 |
125 | if err := a.validateFlags(
126 | inputString,
127 | cCtx.String("input-dir"),
128 | cCtx.String("input-file"),
129 | cCtx.StringSlice("datasource"),
130 | cCtx.StringSlice("data"),
131 | cCtx.StringSlice("exclude"),
132 | cCtx.String("engine"),
133 | ); err != nil {
134 | if err := cli.ShowAppHelp(cCtx); err != nil {
135 | return fmt.Errorf("show app help: %s", err)
136 | }
137 | return fmt.Errorf("validate flags: %s", err)
138 | }
139 |
140 | if eng, ok := enginesMap[cCtx.String("engine")]; !ok {
141 | a.engine = enginesMap["gotemplates"]
142 | } else {
143 | a.engine = eng
144 | }
145 |
146 | datasourceUrls, err := a.parseDatasourceUrls(cCtx.StringSlice("datasource"))
147 | if err != nil {
148 | return fmt.Errorf("parse datasource URLs: %s", err)
149 | }
150 |
151 | data, err := a.loadDatasources(datasourceUrls, cCtx.StringSlice("data"), cCtx.Bool("allow-duplicate-keys"))
152 | if err != nil {
153 | return fmt.Errorf("load datasources: %s", err)
154 | }
155 |
156 | excludePaths := []string{}
157 | excludeFileGlobs := []string{}
158 | if len(cCtx.StringSlice("exclude")) > 0 {
159 | excludePaths, excludeFileGlobs, err = a.aggregateExcludePatterns(cCtx.StringSlice("exclude"))
160 | if err != nil {
161 | return fmt.Errorf("aggregate exclude patterns: %s", err)
162 | }
163 | }
164 |
165 | if err := a.render(
166 | inputString,
167 | cCtx.String("input-dir"),
168 | cCtx.String("input-file"),
169 | cCtx.String("output"),
170 | excludePaths,
171 | excludeFileGlobs,
172 | data,
173 | ); err != nil {
174 | return fmt.Errorf("render: %s", err)
175 | }
176 |
177 | return nil
178 | }
179 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | **Render Kit** is a versatile and powerful command-line interface (CLI) tool designed for comprehensive template rendering. It supports multiple template engines and data sources, providing both flexibility and efficiency.
4 |
5 | [](https://github.com/orellazri/renderkit/actions/workflows/github-code-scanning/codeql)
6 | [](https://github.com/orellazri/renderkit/actions/workflows/test.yml)
7 |
8 | ## Features
9 |
10 | - 🛠️ Supports multiple template engines
11 | - 🌐 Integrates with various data sources
12 | - 🎛️ Customizable rendering options
13 | - ⚡ Lightweight and fast
14 | - 🌍 Cross-platform compatibility
15 | - 📦 Single binary
16 |
17 | ### Supported Engines
18 |
19 | - Envsubst
20 | - Go Templates (including [Sprig Functions](http://masterminds.github.io/sprig/))
21 | - Handlebars
22 | - Jet
23 | - Jinja
24 | - Mustache
25 |
26 | ### Supported Datasources
27 |
28 | - Environment variables
29 | - YAML
30 | - JSON
31 | - TOML
32 | - HTTP/S URL (_For web URLs, ensure the response's Content-Type matches the file format's MIME type. Environment variable file types are not supported yet)_
33 |
34 | ## Usage
35 |
36 | To use Render Kit, you have multiple options:
37 |
38 | - **Download the latest release binary**:
39 |
40 | - Visit the [releases page](https://github.com/orellazri/renderkit/releases) and download the latest binary for your operating system. It's recommended to move the binary to a directory in your `PATH` to make it easier to run such as `/usr/local/bin`.
41 |
42 | - **Run the Docker image**:
43 |
44 | - If you prefer using Docker, you can run the `reaperberri/renderkit` Docker image.
45 | - Make sure you have Docker installed on your machine.
46 | - Run the following command:
47 | ```bash
48 | docker run --rm reaperberri/renderkit
49 | ```
50 |
51 | - **Install with go install**:
52 |
53 | - Ensure that you have Go installed on your machine.
54 | - Run the following command:
55 | ```bash
56 | go install github.com/orellazri/renderkit@latest
57 | ```
58 |
59 | _Please note that this method produces a binary that may not be versioned correctly._
60 |
61 | You need to run the `renderkit` command with the following arguments as either command-line flags, or as a YAML configuration file passed via `--config`.
62 |
63 | | Name | Description | Type |
64 | | ---------------------- | ------------------------------------------------------------------------------ | ------ |
65 | | `config` | Load configuration from YAML file | string |
66 | | `input` | Template string to render | string |
67 | | `input-file` | Template input file to render | string |
68 | | `input-dir` | Template input directory to render | string |
69 | | `exclude` | Exclude files/directories using path-based glob or file glob patterns | list |
70 | | `output` | Output directory to write to | string |
71 | | `datasource` | Datasource to use for rendering (scheme://path) **\*\*** | list |
72 | | `data` | Data to use for rendering. Can be used to provide data directly | list |
73 | | `engine` | Templating engine to use for rendering (Go Templates by default) | string |
74 | | `allow-duplicate-keys` | Allow duplicate keys in datasources. If set, the last value found will be used | bool |
75 |
76 | ### \*\*Notes on `datasource`
77 |
78 | - Inputs not utilizing a URL scheme (`://`, etc.) will be interpreted as plain files. Refer to [Supported Datasources](#supported-datasources) for available formats.
79 | - For now, only the `env` scheme is supported for datasources.
80 | - Using just `env://` will load all your environment variables as keys you can use in your templates.
81 | - Using `env://` will load only that specific environment variable.
82 | - Specifying a path like `path/to/myvars.env` will load the variables from an `.env` file (the file must have a `.env` suffix).
83 |
84 | Below are practical examples demonstrating the usage of `renderkit`:
85 |
86 | ```bash
87 |
88 | # Using a specific env var as a datasource
89 | $ cat ds.yml
90 | FN: "Doe"
91 | $ echo 'Hello {{.FN}} {{.LN}}' | renderkit -ds env://LN -ds ds.yml
92 | Hello John Doe
93 |
94 | # Using a template string and envsubst engine
95 | $ export LN="Doe"
96 | $ echo 'Hello $FN $LN' | renderkit -i 'Hello $FN $LN' -e envsubst --data "FN=John"
97 | Hello John Doe
98 |
99 | # Using a template file with data from a JSON file
100 | $ cat data.json
101 | {
102 | "names": {
103 | "FN": "John",
104 | "LN": "Doe"
105 | }
106 | }
107 | $ cat file.tpl
108 | Hello {{ lower .names.FN }} {{ upper .names.LN }}
109 | $ renderkit -f file.tpl -ds data.json
110 | Hello john DOE
111 |
112 | # Render input directory [1.tpl, 2.tpl, 3.tpl] to output directory
113 | $ renderkit --input-dir in/ --exclude 'in/[1-2].tpl' --output out/ --datasource data.yml --data myKey=myValue --engine jinja
114 | # Output directory will contain [3.tpl] rendered files
115 |
116 | # Use the two supported exclude patterns (path-based Render input directory [1.tpl, 2.tpl, 3.tpl, 1.txt] to output directory
117 | $ renderkit --input-dir in/ --exclude 'in/[1-2].tpl' --exclude '*.txt' --datasource data.yml
118 | # Output directory will contain [3.tpl] rendered files
119 |
120 | ```
121 |
122 | ### Example YAML Configuration File
123 |
124 | ```yaml
125 | input-dir: input/
126 | output: output/
127 | exclude:
128 | - input/exclude[1-2].tpl
129 | - input/other_*.tpl
130 | datasource:
131 | - data.yaml
132 | - data2.json
133 | engine: gotemplates
134 | allow-duplicate-keys: true
135 | ```
136 |
137 | ## Development
138 |
139 | ### Prerequisites
140 |
141 | - [Task](https://taskfile.dev/)
142 | - [pre-commit](https://pre-commit.com/)
143 | - [golangci-lint](https://github.com/golangci/golangci-lint)
144 |
145 | ### Running locally
146 |
147 | 1. Fork and clone the repository
148 | 1. Install pre-commit hooks:
149 |
150 | ```bash
151 | pre-commit install
152 | ```
153 |
154 | 1. Run with:
155 |
156 | ```bash
157 | go run .
158 | ```
159 |
160 | ### Running tests
161 |
162 | ```bash
163 | task test # Run all tests (including integration)
164 | task test SHORT=true # Run only unit tests
165 | ```
166 |
--------------------------------------------------------------------------------
/internal/app/parse_test.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import (
4 | "fmt"
5 | "net/http"
6 | "net/http/httptest"
7 | "net/url"
8 | "os"
9 | "path/filepath"
10 | "reflect"
11 | "testing"
12 |
13 | "github.com/orellazri/renderkit/internal/datasources"
14 | "github.com/stretchr/testify/require"
15 | )
16 |
17 | func TestCreateYamlDatasourceFromURL(t *testing.T) {
18 | a := &App{}
19 | tmpDir := t.TempDir()
20 | file, err := os.Create(filepath.Join(tmpDir, "ds.yaml"))
21 | require.NoError(t, err)
22 | url, err := url.Parse(file.Name())
23 | require.NoError(t, err)
24 | ds, _, err := a.createDatasourceFromURL(url)
25 | require.NoError(t, err)
26 | require.IsType(t, &datasources.YamlDatasource{}, ds)
27 | }
28 |
29 | func TestCreateJsonDatasourceFromURL(t *testing.T) {
30 | a := &App{}
31 | tmpDir := t.TempDir()
32 | file, err := os.Create(filepath.Join(tmpDir, "ds.json"))
33 | require.NoError(t, err)
34 | url, err := url.Parse(file.Name())
35 | require.NoError(t, err)
36 | ds, _, err := a.createDatasourceFromURL(url)
37 | require.NoError(t, err)
38 | require.IsType(t, &datasources.JsonDatasource{}, ds)
39 | }
40 |
41 | func TestCreateTomlDatasourceFromURL(t *testing.T) {
42 | a := &App{}
43 | tmpDir := t.TempDir()
44 | file, err := os.Create(filepath.Join(tmpDir, "ds.toml"))
45 | require.NoError(t, err)
46 | url, err := url.Parse(file.Name())
47 | require.NoError(t, err)
48 | ds, _, err := a.createDatasourceFromURL(url)
49 | require.NoError(t, err)
50 | require.IsType(t, &datasources.TomlDatasource{}, ds)
51 | }
52 |
53 | func TestWebFileLoad(t *testing.T) {
54 | var err error
55 | dsFiles := []string{"ds.json", "ds.toml", "ds.yaml"}
56 | dsTypes := map[string]datasources.Datasource{
57 | dsFiles[0]: &datasources.JsonDatasource{},
58 | dsFiles[1]: &datasources.TomlDatasource{},
59 | dsFiles[2]: &datasources.YamlDatasource{},
60 | }
61 |
62 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
63 | switch r.URL.Path {
64 | case "/" + dsFiles[0]:
65 | w.Header().Set("Content-Type", "application/json")
66 | _, err = fmt.Fprint(w, `{"key1": "value1", "key2": "value2"}`)
67 | require.NoError(t, err)
68 | case "/" + dsFiles[1]:
69 | w.Header().Set("Content-Type", "application/toml")
70 | _, err = fmt.Fprint(w, "key1 = \"value1\"\n key2 = \"value2\"")
71 | require.NoError(t, err)
72 | case "/" + dsFiles[2]:
73 | w.Header().Set("Content-Type", "application/yaml")
74 | _, err = fmt.Fprint(w, "key1: value1\nkey2: value2")
75 | require.NoError(t, err)
76 | default:
77 | http.NotFound(w, r)
78 | }
79 | }))
80 | defer ts.Close()
81 |
82 | a := &App{}
83 |
84 | expectedData := map[string]any{
85 | "key1": "value1",
86 | "key2": "value2",
87 | }
88 |
89 | for _, dsFile := range dsFiles {
90 | url, err := url.Parse(ts.URL + "/" + dsFile)
91 | require.NoError(t, err)
92 |
93 | ds, rc, err := a.createDatasourceFromURL(url)
94 | defer rc.Close()
95 | require.NoError(t, err)
96 |
97 | require.Equal(t, reflect.TypeOf(ds), reflect.TypeOf(dsTypes[dsFile]))
98 |
99 | data, err := ds.Load()
100 | require.NoError(t, err)
101 | require.Equal(t, data, expectedData)
102 | }
103 | }
104 |
105 | func TestCreateInvalidDatasourceFromURL(t *testing.T) {
106 | a := &App{}
107 |
108 | // Invalid extension
109 | url, err := url.Parse("/tmp/ds.nothing")
110 | require.NoError(t, err)
111 | _, _, err = a.createDatasourceFromURL(url)
112 | require.Error(t, err)
113 |
114 | // Invalid scheme
115 | url, err = url.Parse("nothing:///tmp/ds.yaml")
116 | require.NoError(t, err)
117 | _, _, err = a.createDatasourceFromURL(url)
118 | require.Error(t, err)
119 | }
120 |
121 | func TestParseDatasourceUrls(t *testing.T) {
122 | a := &App{}
123 | datasources := []string{"/tmp/ds.yaml", "/tmp/ds.json", "/tmp/ds.toml"}
124 | expectedUrls := []*url.URL{
125 | {Path: "/tmp/ds.yaml"},
126 | {Path: "/tmp/ds.json"},
127 | {Path: "/tmp/ds.toml"},
128 | }
129 |
130 | urls, err := a.parseDatasourceUrls(datasources)
131 | require.NoError(t, err)
132 | require.Equal(t, expectedUrls, urls)
133 | }
134 |
135 | func TestLoadDatasources(t *testing.T) {
136 | tmpDir := t.TempDir()
137 | ds1File, err := os.Create(filepath.Join(tmpDir, "ds1.yaml"))
138 | require.NoError(t, err)
139 | ds2File, err := os.Create(filepath.Join(tmpDir, "ds2.json"))
140 | require.NoError(t, err)
141 | ds3File, err := os.Create(filepath.Join(tmpDir, "ds3.toml"))
142 | require.NoError(t, err)
143 |
144 | _, err = ds1File.WriteString("key1: value1")
145 | require.NoError(t, err)
146 | _, err = ds2File.WriteString(`{"key2": "value2"}`)
147 | require.NoError(t, err)
148 | _, err = ds3File.WriteString(`key3 = "value3"`)
149 | require.NoError(t, err)
150 | extraData := []string{"key4=value4"}
151 |
152 | a := &App{}
153 | datasourceUrls := []*url.URL{
154 | {Path: ds1File.Name()},
155 | {Path: ds2File.Name()},
156 | {Path: ds3File.Name()},
157 | }
158 | expectedData := map[string]any{
159 | "key1": "value1",
160 | "key2": "value2",
161 | "key3": "value3",
162 | "key4": "value4",
163 | }
164 | data, err := a.loadDatasources(datasourceUrls, extraData, false)
165 | require.NoError(t, err)
166 | require.Equal(t, expectedData, data)
167 | }
168 |
169 | func TestCompileGlob(t *testing.T) {
170 | app := &App{}
171 |
172 | tmpDir := t.TempDir()
173 | _, err := os.Create(filepath.Join(tmpDir, "input.txt"))
174 | require.NoError(t, err)
175 |
176 | files, err := app.compileGlob(fmt.Sprintf("%s/*.txt", tmpDir))
177 | require.NoError(t, err)
178 | require.Equal(t, []string{filepath.Join(tmpDir, "input.txt")}, files)
179 |
180 | files, err = app.compileGlob(fmt.Sprintf("%s/*", tmpDir))
181 | require.NoError(t, err)
182 | require.Equal(t, []string{filepath.Join(tmpDir, "input.txt")}, files)
183 |
184 | files, err = app.compileGlob(fmt.Sprintf("%s/**", tmpDir))
185 | require.NoError(t, err)
186 | require.Equal(t, []string{filepath.Join(tmpDir, "input.txt")}, files)
187 |
188 | tmpSubdir := filepath.Join(tmpDir, "subdir")
189 | err = os.Mkdir(tmpSubdir, 0755)
190 | require.NoError(t, err)
191 | _, err = os.Create(filepath.Join(tmpSubdir, "input2.txt"))
192 | require.NoError(t, err)
193 |
194 | files, err = app.compileGlob(fmt.Sprintf("%s/**", tmpDir))
195 | require.NoError(t, err)
196 | require.ElementsMatch(t, []string{
197 | filepath.Join(tmpDir, "input.txt"),
198 | filepath.Join(tmpSubdir, "input2.txt"),
199 | }, files)
200 | }
201 |
202 | func TestCompileInvalidGlob(t *testing.T) {
203 | app := &App{}
204 | _, err := app.compileGlob("[a-z")
205 | require.Error(t, err)
206 | }
207 |
208 | func TestAggregateExcludeFiles(t *testing.T) {
209 | app := &App{}
210 |
211 | tmpDir := t.TempDir()
212 | for _, file := range []string{"1.txt", "2.txt", "3.txt", "4.txt"} {
213 | _, err := os.Create(filepath.Join(tmpDir, file))
214 | require.NoError(t, err)
215 | }
216 |
217 | excludeFilesGlobs := []string{filepath.Join(tmpDir, "[1-2].txt"), filepath.Join(tmpDir, "3*.txt")}
218 |
219 | aggregatedExcludeFiles, _, err := app.aggregateExcludePatterns(excludeFilesGlobs)
220 | require.NoError(t, err)
221 |
222 | require.ElementsMatch(t, []string{
223 | filepath.Join(tmpDir, "1.txt"),
224 | filepath.Join(tmpDir, "2.txt"),
225 | filepath.Join(tmpDir, "3.txt"),
226 | }, aggregatedExcludeFiles)
227 | }
228 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
2 | dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
3 | dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8=
4 | dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
5 | github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
6 | github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
7 | github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
8 | github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
9 | github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
10 | github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
11 | github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oME=
12 | github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4=
13 | github.com/CloudyKit/jet/v6 v6.3.1 h1:6IAo5Cx21xrHVaR8zzXN5gJatKV/wO7Nf6bfCnCSbUw=
14 | github.com/CloudyKit/jet/v6 v6.3.1/go.mod h1:lf8ksdNsxZt7/yH/3n4vJQWA9RUq4wpaHtArHhGVMOw=
15 | github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
16 | github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
17 | github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
18 | github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
19 | github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
20 | github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
21 | github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
22 | github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
23 | github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
24 | github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
25 | github.com/a8m/envsubst v1.4.2 h1:4yWIHXOLEJHQEFd4UjrWDrYeYlV7ncFWJOCBRLOZHQg=
26 | github.com/a8m/envsubst v1.4.2/go.mod h1:MVUTQNGQ3tsjOOtKCNd+fl8RzhsXcDvvAEzkhGtlsbY=
27 | github.com/a8m/envsubst v1.4.3 h1:kDF7paGK8QACWYaQo6KtyYBozY2jhQrTuNNuUxQkhJY=
28 | github.com/a8m/envsubst v1.4.3/go.mod h1:4jjHWQlZoaXPoLQUb7H2qT4iLkZDdmEQiOUogdUmqVU=
29 | github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
30 | github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
31 | github.com/caarlos0/testfs v0.4.4 h1:3PHvzHi5Lt+g332CiShwS8ogTgS3HjrmzZxCm6JCDr8=
32 | github.com/caarlos0/testfs v0.4.4/go.mod h1:bRN55zgG4XCUVVHZCeU+/Tz1Q6AxEJOEJTliBy+1DMk=
33 | github.com/cbroglie/mustache v1.4.0 h1:Azg0dVhxTml5me+7PsZ7WPrQq1Gkf3WApcHMjMprYoU=
34 | github.com/cbroglie/mustache v1.4.0/go.mod h1:SS1FTIghy0sjse4DUVGV1k/40B1qE1XkD9DtDsHo9iM=
35 | github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
36 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
37 | github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
38 | github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
39 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
40 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
41 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
42 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
43 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
44 | github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
45 | github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
46 | github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
47 | github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
48 | github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
49 | github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
50 | github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
51 | github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
52 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
53 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
54 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
55 | github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA=
56 | github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
57 | github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
58 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
59 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
60 | github.com/goreleaser/fileglob v1.3.0 h1:/X6J7U8lbDpQtBvGcwwPS6OpzkNVlVEsFUVRx9+k+7I=
61 | github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU=
62 | github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdmPSDFPY=
63 | github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc=
64 | github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
65 | github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
66 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
67 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
68 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
69 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
70 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
71 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
72 | github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
73 | github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
74 | github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
75 | github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
76 | github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
77 | github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
78 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
79 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
80 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
81 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
82 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
83 | github.com/nikolalohinski/gonja/v2 v2.3.3 h1:5cTcmz0i/DwJl67US8Rvnb4OkBXB5V5OWd5IIAPPkXw=
84 | github.com/nikolalohinski/gonja/v2 v2.3.3/go.mod h1:8KC3RlefxnOaY5P4rH5erdwV0/owS83U615cSnDLYFs=
85 | github.com/nikolalohinski/gonja/v2 v2.4.0 h1:96XmXf/Jj9gFoeQ+dIyaIpah399X/MIMsA/oieNMLhk=
86 | github.com/nikolalohinski/gonja/v2 v2.4.0/go.mod h1:UIzXPVuOsr5h7dZ5DUbqk3/Z7oFA/NLGQGMjqT4L2aU=
87 | github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
88 | github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
89 | github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
90 | github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
91 | github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
92 | github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
93 | github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
94 | github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
95 | github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
96 | github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
97 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
98 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
99 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
100 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
101 | github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
102 | github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
103 | github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
104 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
105 | github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
106 | github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
107 | github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
108 | github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
109 | github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
110 | github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
111 | github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
112 | github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
113 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
114 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
115 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
116 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
117 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
118 | github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
119 | github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
120 | github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
121 | github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
122 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
123 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
124 | github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
125 | github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
126 | golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
127 | golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
128 | golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
129 | golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
130 | golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo=
131 | golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
132 | golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0=
133 | golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4=
134 | golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
135 | golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
136 | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
137 | golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
138 | golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
139 | golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
140 | golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
141 | golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
142 | golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
143 | golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
144 | golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
145 | golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
146 | golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
147 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
148 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
149 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
150 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
151 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
152 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
153 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
154 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
155 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
--------------------------------------------------------------------------------