merge

package
v0.0.0-...-9da1c94 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoader

func NewLoader(env *Envar) loader

Types

type Context

type Context struct {
	Env    *Envar
	Loader loader

	// a list of variable sets
	Items []Set
	// contains filtered or unexported fields
}

Context the merge context for artisan templates .art

func (*Context) Exists

func (c *Context) Exists(variableName reflect.Value) reflect.Value

func (*Context) FuncMap

func (c *Context) FuncMap() template.FuncMap

func (*Context) GroupExists

func (c *Context) GroupExists(group reflect.Value) bool

func (*Context) Item

func (c *Context) Item(name reflect.Value, set reflect.Value) reflect.Value

Item return a grouped variable value using its name and the current iteration set

func (*Context) ItemEq

func (c *Context) ItemEq(name reflect.Value, set reflect.Value, value reflect.Value) reflect.Value

ItemEq return a boolean indicating whether the value of a variable identified by key is equals to the passed-in value

func (*Context) ItemNeq

func (c *Context) ItemNeq(name reflect.Value, set reflect.Value, value reflect.Value) reflect.Value

ItemNeq return a boolean indicating whether the value of a variable identified by key is not equal to the passed-in value

func (*Context) Select

func (c *Context) Select(group reflect.Value) reflect.Value

Select a specific variable group and populate all variable sets within the group

func (*Context) Var

func (c *Context) Var(name reflect.Value) reflect.Value

Var return the value of a variable

type Envar

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

func NewEnVarEmpty

func NewEnVarEmpty() *Envar

func NewEnVarFromFile

func NewEnVarFromFile(envFile string) (*Envar, error)

func NewEnVarFromMap

func NewEnVarFromMap(v map[string]string) *Envar

func NewEnVarFromSlice

func NewEnVarFromSlice(v []string) *Envar

func NewEnvVarOS

func NewEnvVarOS() *Envar

func (*Envar) Add

func (e *Envar) Add(key, value string)

func (*Envar) Append

func (e *Envar) Append(v map[string]string) conf.Configuration

func (*Envar) Get

func (e *Envar) Get(key string) string

func (*Envar) Group

func (e *Envar) Group(groupName reflect.Value) reflect.Value

Group used by golang text.Template to return a map of key / values for vars that whose base name is the same but have been suffixed with an incremental index number

func (*Envar) Merge

func (e *Envar) Merge(env conf.Configuration)

func (*Envar) MergeMap

func (e *Envar) MergeMap(env map[string]string)

func (*Envar) Replace

func (e *Envar) Replace()

Replace any env variable in the internal map with the value

func (*Envar) Set

func (e *Envar) Set(key, value string)

func (*Envar) Slice

func (e *Envar) Slice() []string

func (*Envar) String

func (e *Envar) String() string

func (*Envar) Vars

func (e *Envar) Vars() map[string]string

type Set

type Set struct {
	Context *Context
	// a list of values associated with a set name
	// eg: [ "NAME" ] [ "port a" ]
	//     [ "DESC" ] [ "this is port a" ]
	//     [ "VALUE" ] [ "80" ]
	Value map[string]string
}

Set a group of values for a variable group identified by a group name for a specific index

func (*Set) Get

func (s *Set) Get(name string) string

type TemplMerger

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

TemplMerger merge artisan templates using artisan inputs

func NewTemplMerger

func NewTemplMerger() (*TemplMerger, error)

NewTemplMerger create a new instance of the template merger to merge files

func (*TemplMerger) Files

func (t *TemplMerger) Files() map[string][]byte

func (*TemplMerger) GetFile

func (t *TemplMerger) GetFile(name string) []byte

func (*TemplMerger) LoadStringTemplates

func (t *TemplMerger) LoadStringTemplates(templs map[string]string) error

func (*TemplMerger) LoadTemplates

func (t *TemplMerger) LoadTemplates(files []string) error

LoadTemplates load the template files to use

func (*TemplMerger) LoadTemplatesBytes

func (t *TemplMerger) LoadTemplatesBytes(files map[string][]byte) error

func (*TemplMerger) Merge

func (t *TemplMerger) Merge(env *Envar) error

Merge templates with the passed in environment

func (*TemplMerger) MergeWithCtx

func (t *TemplMerger) MergeWithCtx(ctx TemplateContext) (err error)

MergeWithCtx templates with the passed in merge context

func (*TemplMerger) Save

func (t *TemplMerger) Save() error

type TemplateContext

type TemplateContext interface {
	FuncMap() template.FuncMap
}

func NewContext

func NewContext(env *Envar) (TemplateContext, error)

Jump to

Keyboard shortcuts

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