Documentation
¶
Index ¶
- func GenericMapToNode(mapValue reflect.Value) (*yaml.Node, error)
- func GenericSliceToNode(slice reflect.Value) (*yaml.Node, error)
- func NodeToBool(node *yaml.Node) (bool, bool)
- func NodeToFloat(node *yaml.Node) (float64, bool)
- func NodeToInt(node *yaml.Node) (int, bool)
- func NodeToInterface(node *yaml.Node) (interface{}, bool)
- func NodeToMap(node *yaml.Node) (map[string]interface{}, bool)
- func NodeToScalarInterface(node *yaml.Node) (interface{}, bool)
- func NodeToSlice(node *yaml.Node) ([]interface{}, bool)
- func NodeToString(node *yaml.Node) (string, bool)
- func ValueToNode(value interface{}) (*yaml.Node, error)
- type Interpreter
- func (ei *Interpreter) CreateDecoder(target interface{}) *interpretHelper
- func (ei *Interpreter) CreateRawDecoder(target *yaml.Node) *rawInterpretHelper
- func (ei *Interpreter) LookupAll(jsonPath string) (*yaml.Node, error)
- func (ei *Interpreter) LookupFirst(jsonPath string) (*yaml.Node, error)
- func (ei *Interpreter) ParseArgs(node *yaml.Node, variables []ParsedVariable) (map[string]*yaml.Node, error)
- func (ei *Interpreter) Process(node *yaml.Node) (*yaml.Node, error)
- func (ei *Interpreter) RegisterTag(tag string, f func(node *yaml.Node) (*yaml.Node, error)) error
- type InterpreterOption
- type ParsedVariable
- type TagFunc
- type TagFuncMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeToBool ¶
NodeToBool parses a YAML node to bool.
func NodeToFloat ¶
NodeToFloat parses a YAML node to float.
func NodeToInterface ¶
NodeToInterface parses a YAML node into an interface{}.
func NodeToScalarInterface ¶
func NodeToSlice ¶
func NodeToString ¶
NodeToString parses a YAML node to string.
func ValueToNode ¶
Types ¶
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter(options ...InterpreterOption) (*Interpreter, error)
func (*Interpreter) CreateDecoder ¶
func (ei *Interpreter) CreateDecoder(target interface{}) *interpretHelper
func (*Interpreter) CreateRawDecoder ¶
func (ei *Interpreter) CreateRawDecoder(target *yaml.Node) *rawInterpretHelper
func (*Interpreter) LookupAll ¶
func (ei *Interpreter) LookupAll(jsonPath string) (*yaml.Node, error)
func (*Interpreter) LookupFirst ¶
func (ei *Interpreter) LookupFirst(jsonPath string) (*yaml.Node, error)
func (*Interpreter) ParseArgs ¶ added in v0.0.4
func (ei *Interpreter) ParseArgs( node *yaml.Node, variables []ParsedVariable, ) (map[string]*yaml.Node, error)
ParseArgs processes a YAML mapping node according to a list of variable specifications. It's a core utility function used by various Emrichen tags to parse their arguments in a consistent way.
Parameters: - node: A pointer to a yaml.Node that must be a mapping node containing key-value pairs - variables: A slice of parsedVariable structs that specify:
- Name: The expected argument name
- Required: Whether the argument must be present
- Expand: Whether to process the value through the Emrichen interpreter
Returns: - map[string]*yaml.Node: A map of processed arguments where:
- Keys are the argument names
- Values are the processed YAML nodes (expanded if specified)
- error: Returns an error if:
- The input node is not a mapping node
- An unknown argument key is encountered
- A required argument is missing
- A key is not a scalar value
- Value expansion fails
Example usage:
args, err := ei.ParseArgs(node, []parsedVariable{
{Name: "test", Required: true, Expand: true},
{Name: "then", Required: true, Expand: false},
{Name: "else", Required: false, Expand: false},
})
func (*Interpreter) RegisterTag ¶
type InterpreterOption ¶
type InterpreterOption func(*Interpreter) error
func WithAdditionalTags ¶
func WithAdditionalTags(tags TagFuncMap) InterpreterOption
func WithFuncMap ¶
func WithFuncMap(funcmap ...template.FuncMap) InterpreterOption
func WithVars ¶
func WithVars(vars map[string]interface{}) InterpreterOption
type ParsedVariable ¶ added in v0.0.4
type TagFuncMap ¶ added in v0.0.4
Click to show internal directories.
Click to hide internal directories.