template

package
v0.26.3-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplatesNotFound         = errors.New("templates key not found in template source custom")
	ErrTemplateSourceCustomIsNil = errors.New("template source custom is nil")
	ErrDataSourceBaseIsNil       = errors.New("data source base is nil")
)

Functions

func FromYAML

func FromYAML(str string) map[string]any

func HasKeyAny

func HasKeyAny(m map[any]any, key any) bool

func ToYAML

func ToYAML(v any) string

Types

type ActionNode

type ActionNode parse.ActionNode

func (*ActionNode) Set

func (a *ActionNode) Set(n *Node)

type Config

type Config struct {
	Data      map[string]map[any]any `yaml:"data,omitempty"`
	Include   map[string]string      `yaml:"include,omitempty"`
	Templates Templates              `yaml:"templates,omitempty"`
}

func NewConfig

func NewConfig(tplSource, data *merge.Merger, excluded []string) (Config, error)

func NewConfigWithoutData

func NewConfigWithoutData(tplSource *merge.Merger, excluded []string) (Config, error)

type FieldNode

type FieldNode parse.FieldNode

func (*FieldNode) Set

func (f *FieldNode) Set(n *Node)

type FieldsSetter

type FieldsSetter interface {
	Set(n *Node)
}

type FuncMap

type FuncMap struct {
	FuncMap template.FuncMap
}

func NewFuncMap

func NewFuncMap() FuncMap

func (*FuncMap) Add

func (f *FuncMap) Add(name string, fn any)

func (*FuncMap) Delete

func (f *FuncMap) Delete(name string)

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(
	rootSrc,
	source,
	target string,
	context map[string]map[any]any,
	funcMap FuncMap,
	dryRun bool,
) *Generator

func (*Generator) GetMissingKeys

func (g *Generator) GetMissingKeys(tpl *template.Template) []string

func (*Generator) ProcessFile

func (g *Generator) ProcessFile(tpl *template.Template) (bytes.Buffer, error)

func (*Generator) ProcessFilename

func (g *Generator) ProcessFilename(
	tm *Model,
) (string, error)

func (*Generator) ProcessTemplate

func (g *Generator) ProcessTemplate() (*template.Template, error)

func (*Generator) UpdateTarget

func (g *Generator) UpdateTarget(newTarget string)

func (*Generator) WriteMissingKeysToFile

func (*Generator) WriteMissingKeysToFile(
	missingKeys []string,
	tmplPath,
	outputPath string,
) error

type IfNode

type IfNode parse.IfNode

func (*IfNode) Set

func (i *IfNode) Set(n *Node)

type ListNode

type ListNode parse.ListNode

func (*ListNode) Set

func (l *ListNode) Set(n *Node)

type Model

type Model struct {
	SourcePath           string
	TargetPath           string
	ConfigPath           string
	OutputPath           string
	FuryctlConfPath      string
	Config               Config
	Suffix               string
	Context              map[string]map[any]any
	FuncMap              FuncMap
	StopIfTargetNotEmpty bool
	DryRun               bool
}

func NewTemplateModel

func NewTemplateModel(
	source,
	target,
	configPath,
	outPath,
	furyctlConfPath,
	suffix string,
	stopIfNotEmpty,
	dryRun bool,
) (*Model, error)

func (*Model) Generate

func (tm *Model) Generate() error

type Node

type Node struct {
	Fields []string
}

func NewNode

func NewNode() *Node

func (*Node) FromNodeList

func (f *Node) FromNodeList(nodes []parse.Node) []string

func (*Node) Set

func (f *Node) Set(s []string)

type PipeNode

type PipeNode parse.PipeNode

func (*PipeNode) Set

func (p *PipeNode) Set(n *Node)

type RangeNode

type RangeNode parse.RangeNode

func (*RangeNode) Set

func (r *RangeNode) Set(n *Node)

type Templates

type Templates struct {
	Includes        []string `yaml:"includes,omitempty"`
	Excludes        []string `yaml:"excludes,omitempty"`
	Suffix          string   `yaml:"suffix,omitempty"`
	ProcessFilename bool     `yaml:"processFilename,omitempty"`
}

type TplNode

type TplNode parse.TemplateNode

func (*TplNode) Set

func (t *TplNode) Set(n *Node)

type VariableNode

type VariableNode parse.VariableNode

func (*VariableNode) Set

func (*VariableNode) Set(_ *Node)

Set Skips VariableNodes because they are not fields.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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