Documentation ¶
Index ¶
- type TemplateFunc
- type Viper
- type YamlPack
- type YamlSection
- func (section *YamlSection) AllSettings() (ret map[string]interface{}, err error)
- func (section *YamlSection) GetBool(identifier string) bool
- func (section *YamlSection) GetString(identifier string) string
- func (section *YamlSection) GetStringSlice(identifier string) []string
- func (section *YamlSection) Render(vals interface{}) error
- func (section *YamlSection) RenderWithTemplateFunc(tmplFunc TemplateFunc, vals interface{}) error
- func (ys *YamlSection) String() string
- func (section *YamlSection) Sub(identifier string) (*YamlSection, error)
- func (section *YamlSection) Unmarshal(entry interface{}) (err error)
- func (section *YamlSection) UnmarshalStrict(entry interface{}) (err error)
- func (ys *YamlSection) Yaml() (string, error)
- type Yp
- func (yp *Yp) AllSections() []*YamlSection
- func (yp *Yp) ApplyDefaultTemplate(name string, vals interface{}) error
- func (yp *Yp) ApplyDefaultTemplateStrict(name string, vals interface{}) error
- func (yp *Yp) ApplyFilters(s string, filters []string) error
- func (yp *Yp) ApplyTemplate(name string, tmplFunc TemplateFunc, vals interface{}) error
- func (yp *Yp) DeregisterHandler(name string)
- func (yp *Yp) Import(s string, r io.Reader) error
- func (yp *Yp) ImportFile(s string) error
- func (yp *Yp) ImportWithTemplateFuncAndFilters(identifier string, r io.Reader, tf TemplateFunc, filters []string) error
- func (yp *Yp) ListYamls() []string
- func (yp *Yp) RegisterHandler(name string, f func(string) error) error
- func (yp *Yp) YamlParse(name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TemplateFunc ¶
TemplateFunc is processed with RenderWithTemplateFunc
type YamlPack ¶
type YamlPack interface { AllSections() []*YamlSection ListYamls() []string GetString(string) string GetStringSlice(string) []string GetBool(string) bool Sub(string) *viper.Viper }
YamlPack provides a set of functionality to process composite yaml documents
type YamlSection ¶
type YamlSection struct { Bytes []byte OriginalBytes []byte // Pre-template functions Viper *viper.Viper TemplateFunc TemplateFunc }
YamlFile stores raw file bytes and Viper struct
func Filter ¶
func Filter(in []*YamlSection, filters []string) ([]*YamlSection, error)
Filter removes *YamlSections from a list based on text filters
func (*YamlSection) AllSettings ¶
func (section *YamlSection) AllSettings() (ret map[string]interface{}, err error)
AllSettings returns a value map derived from the *YamlSection data
func (*YamlSection) GetBool ¶
func (section *YamlSection) GetBool(identifier string) bool
GetBool returns a boolean value from a doted notation key
func (*YamlSection) GetString ¶
func (section *YamlSection) GetString(identifier string) string
GetString returns a string value from a doted notation key
func (*YamlSection) GetStringSlice ¶
func (section *YamlSection) GetStringSlice(identifier string) []string
GetStringSlice returns a string slice from a doted notation key
func (*YamlSection) Render ¶
func (section *YamlSection) Render(vals interface{}) error
Render applies the sections configured template with the provided values
func (*YamlSection) RenderWithTemplateFunc ¶
func (section *YamlSection) RenderWithTemplateFunc(tmplFunc TemplateFunc, vals interface{}) error
Render applies the provided template function to the *YamlSection with the provided values
func (*YamlSection) String ¶
func (ys *YamlSection) String() string
String returns the sections processed data as a string
func (*YamlSection) Sub ¶
func (section *YamlSection) Sub(identifier string) (*YamlSection, error)
Sub returns a *YamlSection instance from a yaml key identified by doted notation
func (*YamlSection) Unmarshal ¶
func (section *YamlSection) Unmarshal(entry interface{}) (err error)
Unmarshal processes *YamlSection data into the provided data structure Missing values or destination structure elements are ignored
func (*YamlSection) UnmarshalStrict ¶
func (section *YamlSection) UnmarshalStrict(entry interface{}) (err error)
UnmarshalStrict processes *YamlSection data into the provided data structure This is the strict version which has DisallowUnknownFields enabled
func (*YamlSection) Yaml ¶
func (ys *YamlSection) Yaml() (string, error)
Yaml returns the "data" value as a string DEPRECATED: this is used only in yaml2vars and will be removed in the future
type Yp ¶
type Yp struct { sync.RWMutex Files map[string][]*YamlSection Handlers map[string]func(string) error DefaultTemplateFunc TemplateFunc }
Yp is a yamlpack instance
func (*Yp) AllSections ¶
func (yp *Yp) AllSections() []*YamlSection
AllSections returns an array containing all yaml sections
func (*Yp) ApplyDefaultTemplate ¶
ApplyDefaultTemplate runs the default template function but only errors on parse failures
func (*Yp) ApplyDefaultTemplateStrict ¶
ApplyDefaultTemplateStrict runs the default template function and errors on any failure such as missing data
func (*Yp) ApplyFilters ¶
ApplyFilters removes *YamlSections from a yamlpack instance based on text filter data
func (*Yp) ApplyTemplate ¶
func (yp *Yp) ApplyTemplate(name string, tmplFunc TemplateFunc, vals interface{}) error
ApplyTemplate executes RenderWithTemplateFunc on every section in a yamlpack instance
func (*Yp) DeregisterHandler ¶
DeregisterHandler removed a previously registered handler if it exists
func (*Yp) Import ¶
Import takes a location identifier (URI, file path, etc..) and an io.Reader imported data is added to the yamlPack instance
func (*Yp) ImportFile ¶
Import reads data from a single YAML file and adds its data to this *Yp instance
func (*Yp) ImportWithTemplateFuncAndFilters ¶
func (yp *Yp) ImportWithTemplateFuncAndFilters(identifier string, r io.Reader, tf TemplateFunc, filters []string) error
ImportWithTemplateFuncAndFilters offers a way to import yaml from an io.Reader, applies a template, and filters sections based on a string array
func (*Yp) RegisterHandler ¶
RegisterHandler adds a handler to this instance