tmplgen

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT

README

tmplgen

About

tmplgen is a Go tool for generating multiple configuration files from templates. It uses a manifest file to associate each output pattern with a template, define variable combinations, and apply conditional variable assignments, making it easy to manage configuration across multiple environments, regions, or services.

Installation

go install github.com/korylprince/tmplgen/cmd/tmplgen@latest

Usage

tmplgen -manifest manifest.yaml -out ./output

Example

manifest.yaml:

# $schema: ./docs/manifest.schema.yaml

patterns:
  - pattern: "{app}/{env}/values.yaml"
    template: "values_template.yaml"
    generate:
      - app: ["frontend", "backend"]
        env: ["dev", "prod"]

# last value matches take precedence
variables:
  - match: "*/dev/*"
    values:
      replicas: "1"
      debug: "true"

  - match: "*/prod/*"
    values:
      replicas: "3"
      debug: "false"

Each pattern requires its own template. Template paths are resolved relative to the directory containing the manifest, so the command can be run from any working directory.

values_template.yaml:

app: {{ .app }}
environment: {{ .env }}
replicas: {{ .replicas }}
debug: {{ .debug }}

This generates 4 files with appropriate values:

  • frontend/dev/values.yaml
  • frontend/prod/values.yaml
  • backend/dev/values.yaml
  • backend/prod/values.yaml

Example content for frontend/dev/values.yaml:

app: frontend
environment: dev
replicas: 1
debug: true

License

MIT License - Copyright (c) 2025 Kory Prince

Directories

Path Synopsis
cmd
tmplgen command
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL