marshal

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindPotentialVariables

func FindPotentialVariables(text []byte) []string

FindPotentialVariables returns a list of potential interpolation target names.

func Interpolate

func Interpolate(i interface{}, values map[string]string) error

Interpolate an arbitrary YAML-marshallable interface.

func ParseOrderedMap

func ParseOrderedMap(
	ms yaml.MapSlice,
	assign func(string, []byte) error,
) ([]string, error)

ParseOrderedMap returns a list of keys in order and performs map assignment. The assign function passed allows a closure to handle the map assignment in a type-safe manner using the keyname and raw text ready to be unmarshaled.

func UnmarshalOneOf

func UnmarshalOneOf(candidates ...UnmarshalCandidate) error

UnmarshalOneOf unmarshals candidates of different types until successful. If any error other than a yaml.TypeError is thrown, that error is returned immediately. If no candidates are valid, the error from the last candidate passed will be returned.

Types

type NullableStringList

type NullableStringList []*string

NullableStringList is a list of nullable strings optionally represented in yaml as a string. A single string in yaml will be unmarshaled as the first entry in a list, so the internal representation is always a list. Due to a quirk of the yaml-parsing library, a single null item will be interpretted as a null list rather than a list containing a single null item.

func (*NullableStringList) UnmarshalYAML

func (sl *NullableStringList) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a nullable string or list of nullable strings always into a list.

type StringList

type StringList []string

StringList is a list of strings optionally represented in yaml as a string. A single string in yaml will be unmarshaled as the first entry in a list, so the internal representation is always a list.

func (*StringList) UnmarshalYAML

func (sl *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a string or list of strings always into a list.

type UnmarshalCandidate

type UnmarshalCandidate struct {
	// Unmarshal should return the result of UnmarshalYAML's unmarshal function.
	// This simply provides a closure so that different data types can be
	// safely passed into the unmarshaling function without reflection.
	Unmarshal func() error

	// Assign assigns the newly unmarshaled item using a closure.
	// This allows the resulting value from an unmarshaling to be assigned
	// to the receiver of the custom UnmarshalYAML function.
	Assign func()

	// Validate is an optional function that can validate after unmarshaling.
	// Assignment will not occur if validation fails.
	Validate func() error
}

UnmarshalCandidate is a candidate for unmarshaling. Candidates should only be defined inside of an UnmarshalYAML function.

Jump to

Keyboard shortcuts

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