Documentation
¶
Overview ¶
Package varfile provides a generator for Terraform variable files (.tfvars.json).
Index ¶
- Constants
- func ConstructFilename(genCtx *generator.GeneratorContext) string
- type Generator
- func (g *Generator) DefaultFilename() string
- func (g *Generator) Generate(ctx context.Context, genCtx *generator.GeneratorContext) (map[string]any, error)
- func (g *Generator) Name() string
- func (g *Generator) ShouldGenerate(genCtx *generator.GeneratorContext) bool
- func (g *Generator) Validate(genCtx *generator.GeneratorContext) error
Constants ¶
const (
// Name is the unique identifier for this generator.
Name = "varfile"
)
Variables ¶
This section is empty.
Functions ¶
func ConstructFilename ¶
func ConstructFilename(genCtx *generator.GeneratorContext) string
ConstructFilename constructs the dynamic varfile name based on the context. This follows the pattern: {context}-{component}.terraform.tfvars.json or: {context}-{folder}-{component}.terraform.tfvars.json if folder prefix exists.
Types ¶
type Generator ¶
type Generator struct{}
Generator generates Terraform variable files (.tfvars.json).
func (*Generator) DefaultFilename ¶
DefaultFilename returns the default output filename. Note: For varfiles, the actual filename is dynamically constructed based on component and stack context. This returns a placeholder that should be overridden by the calling code.
func (*Generator) Generate ¶
func (g *Generator) Generate(ctx context.Context, genCtx *generator.GeneratorContext) (map[string]any, error)
Generate produces the varfile content. For varfiles, the content is simply the VarsSection map.
func (*Generator) ShouldGenerate ¶
func (g *Generator) ShouldGenerate(genCtx *generator.GeneratorContext) bool
ShouldGenerate returns true if the VarsSection has data.