Documentation ¶
Overview ¶
Package compiler provides support functions to generated compiler code.
Index ¶
- func BoolForScalarNode(node *yaml.Node) (bool, bool)
- func CallExtension(context *Context, in *yaml.Node, extensionName string) (handled bool, response *any.Any, err error)
- func ClearCaches()
- func ClearFileCache()
- func ClearInfoCache()
- func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string
- func Description(item interface{}) string
- func DisableFileCache()
- func DisableInfoCache()
- func Display(node *yaml.Node) string
- func EnableFileCache()
- func EnableInfoCache()
- func FetchFile(fileurl string) ([]byte, error)
- func FloatForScalarNode(node *yaml.Node) (float64, bool)
- func GetInfoCache() map[string]*yaml.Node
- func IntForScalarNode(node *yaml.Node) (int64, bool)
- func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string
- func MapHasKey(m *yaml.Node, key string) bool
- func MapValueForKey(m *yaml.Node, key string) *yaml.Node
- func Marshal(in *yaml.Node) []byte
- func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string
- func NewErrorGroupOrNil(errors []error) error
- func NewMappingNode() *yaml.Node
- func NewNullNode() *yaml.Node
- func NewScalarNodeForBool(b bool) *yaml.Node
- func NewScalarNodeForFloat(f float64) *yaml.Node
- func NewScalarNodeForInt(i int64) *yaml.Node
- func NewScalarNodeForString(s string) *yaml.Node
- func NewSequenceNode() *yaml.Node
- func NewSequenceNodeForStringArray(strings []string) *yaml.Node
- func PluralProperties(count int) string
- func ReadBytesForFile(filename string) ([]byte, error)
- func ReadInfoForRef(basefile string, ref string) (*yaml.Node, error)
- func ReadInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error)
- func RemoveFromFileCache(fileurl string)
- func RemoveFromInfoCache(filename string)
- func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool)
- func SortedKeysForMap(m *yaml.Node) []string
- func StringArrayContainsValue(array []string, value string) bool
- func StringArrayContainsValues(array []string, values []string) bool
- func StringArrayForSequenceNode(node *yaml.Node) []string
- func StringForScalarNode(node *yaml.Node) (string, bool)
- func StringValue(item interface{}) (value string, ok bool)
- func UnpackMap(in *yaml.Node) (*yaml.Node, bool)
- type Context
- type Error
- type ErrorGroup
- type ExtensionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolForScalarNode ¶
BoolForScalarNode returns the bool value of a node.
func CallExtension ¶
func CallExtension(context *Context, in *yaml.Node, extensionName string) (handled bool, response *any.Any, err error)
CallExtension calls a binary extension handler.
func ConvertInterfaceArrayToStringArray ¶
func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string
ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible.
func Description ¶
func Description(item interface{}) string
Description returns a human-readable represention of an item.
func Display ¶
func Display(node *yaml.Node) string
Display returns a description of a node for use in error messages.
func FloatForScalarNode ¶
FloatForScalarNode returns the float value of a node.
func GetInfoCache ¶
GetInfoCache returns the info cache map.
func IntForScalarNode ¶
IntForScalarNode returns the integer value of a node.
func InvalidKeysInMap ¶
func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string
InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns.
func MapValueForKey ¶
func MapValueForKey(m *yaml.Node, key string) *yaml.Node
MapValueForKey gets the value of a map value for a specified key.
func Marshal ¶
func Marshal(in *yaml.Node) []byte
Marshal creates a yaml version of a structure in our preferred style
func MissingKeysInMap ¶
MissingKeysInMap identifies which keys from a list of required keys are not in a map.
func NewErrorGroupOrNil ¶
NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty.
func NewScalarNodeForBool ¶
func NewScalarNodeForBool(b bool) *yaml.Node
NewScalarNodeForBool creates a new node to hold a bool.
func NewScalarNodeForFloat ¶
func NewScalarNodeForFloat(f float64) *yaml.Node
NewScalarNodeForFloat creates a new node to hold a float.
func NewScalarNodeForInt ¶
func NewScalarNodeForInt(i int64) *yaml.Node
NewScalarNodeForInt creates a new node to hold an integer.
func NewScalarNodeForString ¶
func NewScalarNodeForString(s string) *yaml.Node
NewScalarNodeForString creates a new node to hold a string.
func NewSequenceNode ¶
func NewSequenceNode() *yaml.Node
NewSequenceNode creates a new Sequence node.
func NewSequenceNodeForStringArray ¶
func NewSequenceNodeForStringArray(strings []string) *yaml.Node
NewSequenceNodeForStringArray creates a new node to hold an array of strings.
func PluralProperties ¶
PluralProperties returns the string "properties" pluralized.
func ReadBytesForFile ¶
ReadBytesForFile reads the bytes of a file.
func ReadInfoForRef ¶
ReadInfoForRef reads a file and return the fragment needed to resolve a $ref.
func ReadInfoFromBytes ¶
ReadInfoFromBytes unmarshals a file as a *yaml.Node.
func RemoveFromFileCache ¶
func RemoveFromFileCache(fileurl string)
RemoveFromFileCache removes an entry from the file cache.
func RemoveFromInfoCache ¶
func RemoveFromInfoCache(filename string)
RemoveFromInfoCache removes an entry from the info cache.
func SequenceNodeForNode ¶
func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool)
SequenceNodeForNode returns a node if it is a SequenceNode.
func SortedKeysForMap ¶
func SortedKeysForMap(m *yaml.Node) []string
SortedKeysForMap returns the sorted keys of a yamlv2.MapSlice.
func StringArrayContainsValue ¶
StringArrayContainsValue returns true if a string array contains a specified value.
func StringArrayContainsValues ¶
StringArrayContainsValues returns true if a string array contains all of a list of specified values.
func StringArrayForSequenceNode ¶
func StringArrayForSequenceNode(node *yaml.Node) []string
StringArrayForSequenceNode converts a sequence node to an array of strings, if possible.
func StringForScalarNode ¶
StringForScalarNode returns the string value of a node.
func StringValue ¶
StringValue returns the string value of an item.
Types ¶
type Context ¶
type Context struct { Parent *Context Name string Node *yaml.Node ExtensionHandlers *[]ExtensionHandler }
Context contains state of the compiler as it traverses a document.
func NewContext ¶
NewContext returns a new object representing the compiler state
func NewContextWithExtensions ¶
func NewContextWithExtensions(name string, node *yaml.Node, parent *Context, extensionHandlers *[]ExtensionHandler) *Context
NewContextWithExtensions returns a new object representing the compiler state
func (*Context) Description ¶
Description returns a text description of the compiler state
type ErrorGroup ¶
type ErrorGroup struct {
Errors []error
}
ErrorGroup is a container for groups of Error values.
func (*ErrorGroup) Error ¶
func (group *ErrorGroup) Error() string
type ExtensionHandler ¶
type ExtensionHandler struct {
Name string
}
ExtensionHandler describes a binary that is called by the compiler to handle specification extensions.