Documentation
¶
Index ¶
- Constants
- Variables
- func GetCache[T any](reader *NodeReader, key CacheKey[T]) (T, bool)
- func GetMock[T any](reader *NodeReader) (T, bool)
- func ParseFieldPath(s string) []string
- func ReadReflect[T any](r *NodeReader, path FieldPath, target T) error
- func ReadReflectK8sRuntimeObject[T runtime.Object](r *NodeReader, path FieldPath, target T) error
- func SetCache[T any](reader *NodeReader, key CacheKey[T], val T)
- type AlphabeticalGoMapKeyOrderProvider
- type CacheKey
- type DefaultMergeMapOrderStrategy
- type FieldPath
- type GoMapKeyOrderProvider
- type JSONNodeSerializer
- type LazyJSONBlockBuilder
- type LazyJSONBlockStore
- func (s *LazyJSONBlockStore) GetBuffer(blockID, offset, length uint32) []byte
- func (s *LazyJSONBlockStore) NewBuilder(maxEntries, maxBytes int) *LazyJSONBlockBuilder
- func (s *LazyJSONBlockStore) ReserveBlock(initialUncompressed []byte) uint32
- func (s *LazyJSONBlockStore) SetCompressed(blockID uint32, compressed []byte)
- type LazyJSONNode
- type MergeArrayStrategy
- type MergeConfigResolver
- type MergeConfiguration
- type MergeMapOrderStrategy
- type MockNode
- type Node
- func FromGoValue(source any, mapKeyOrderProvider GoMapKeyOrderProvider) (Node, error)
- func FromYAML(yamlStr string) (Node, error)
- func MergeNode(prev Node, patch Node, config MergeConfiguration) (Node, error)
- func NewEmptyMapNode() Node
- func NewFieldFilterNode(original Node, keys []string) Node
- func NewLazyJSONNode(store *LazyJSONBlockStore, node Node) (Node, error)
- func NewLazyJSONNodeFromBytes(store *LazyJSONBlockStore, data []byte) Node
- func NewStandardMap(keys []string, values []Node) Node
- func NewStandardSequenceNode(values []Node) Node
- func WithKeyOrder(node Node, priorityKeys ...string) Node
- func WithScalarField[T comparable](node Node, fieldPath []string, value T) (Node, error)
- type NodeChildrenIterator
- type NodeChildrenKey
- type NodeReader
- func (n *NodeReader) Children() NodeReaderChildrenIterator
- func (n *NodeReader) GetNode(path FieldPath) (Node, error)
- func (n *NodeReader) GetReader(path FieldPath) (*NodeReader, error)
- func (n *NodeReader) Has(path FieldPath) bool
- func (n *NodeReader) ReadBool(path FieldPath) (bool, error)
- func (n *NodeReader) ReadBoolOrDefault(path FieldPath, defaultValue bool) bool
- func (n *NodeReader) ReadFloat(path FieldPath) (float64, error)
- func (n *NodeReader) ReadFloatOrDefault(path FieldPath, defaultValue float64) float64
- func (n *NodeReader) ReadInt(path FieldPath) (int, error)
- func (n *NodeReader) ReadIntOrDefault(path FieldPath, defaultValue int) int
- func (n *NodeReader) ReadString(path FieldPath) (string, error)
- func (n *NodeReader) ReadStringOrDefault(path FieldPath, defaultValue string) string
- func (n *NodeReader) ReadTimestamp(path FieldPath) (time.Time, error)
- func (n *NodeReader) ReadTimestampOrDefault(path FieldPath, defaultValue time.Time) time.Time
- func (n *NodeReader) Serialize(path FieldPath, serializer NodeSerializer) ([]byte, error)
- func (n *NodeReader) WithKeyOrder(priorityKeys ...string) *NodeReader
- type NodeReaderChildrenIterator
- type NodeSerializer
- type NodeType
- type OrderedMapNode
- type StandardMapNode
- func (n *StandardMapNode) Children() NodeChildrenIterator
- func (n *StandardMapNode) GetChildByHandle(h unique.Handle[string]) (Node, bool)
- func (n *StandardMapNode) GetChildByKey(key string) (Node, bool)
- func (n *StandardMapNode) Len() int
- func (n *StandardMapNode) MarshalJSON() ([]byte, error)
- func (n *StandardMapNode) MarshalYAML() (interface{}, error)
- func (n *StandardMapNode) NodeScalarValue() (any, error)
- func (n *StandardMapNode) Type() NodeType
- type StandardScalarNode
- func (n *StandardScalarNode[T]) Children() NodeChildrenIterator
- func (n *StandardScalarNode[T]) GetChildByKey(key string) (Node, bool)
- func (n *StandardScalarNode[T]) Len() int
- func (n *StandardScalarNode[T]) MarshalJSON() ([]byte, error)
- func (n *StandardScalarNode[T]) MarshalYAML() (interface{}, error)
- func (n *StandardScalarNode[T]) NodeScalarValue() (any, error)
- func (n *StandardScalarNode[T]) Type() NodeType
- type StandardSequenceNode
- func (n *StandardSequenceNode) Children() NodeChildrenIterator
- func (n *StandardSequenceNode) GetChildByKey(key string) (Node, bool)
- func (n *StandardSequenceNode) Len() int
- func (n *StandardSequenceNode) MarshalJSON() ([]byte, error)
- func (n *StandardSequenceNode) MarshalYAML() (interface{}, error)
- func (n *StandardSequenceNode) NodeScalarValue() (any, error)
- func (n *StandardSequenceNode) Type() NodeType
- type YAMLNodeSerializer
Constants ¶
const ( InvalidNodeType = 0 // ScalarNodeType is a NodeType for scalar values. // The scalar type currently supported is nil,bool,string,int,float and time.Time. ScalarNodeType = 1 // SequenceNdoeType is a NodeType for sequence(array, slices) values. SequenceNodeType = 2 // MapNodeType is a NodeType for map(dictionary) values. It needs to retain the order of keys. MapNodeType = 3 )
const DefaultLazyJSONBlockMaxBytes = 256 * 1024
DefaultLazyJSONBlockMaxBytes is the default maximum uncompressed byte size per block.
const DefaultLazyJSONBlockMaxEntries = 100
DefaultLazyJSONBlockMaxEntries is the default maximum number of entries per block.
const DefaultLazyJSONBlockStoreShardCap = 64
DefaultLazyJSONBlockStoreShardCap is the default capacity per shard, sizing total uncompressed cache to 1 GB (4,096 blocks * 256 KB).
const DefaultLazyJSONBlockStoreShardCount = 64
DefaultLazyJSONBlockStoreShardCount is the default shard count for LazyJSONBlockStore.
Variables ¶
var EmptyFieldPath = FieldPath{}
EmptyFieldPath represents an empty field path pointing to the root node itself.
var ErrAliasNodeNotSupported = errors.New("alias node is not supported in a yaml. FromYAML does not support alias node")
var ErrFieldNotFound = errors.New("field not found")
ErrFieldNotFound is returned when a requested field is not found in the node structure.
var ErrInvalidJSON = errors.New("invalid json format")
ErrInvalidJSON indicates that invalid JSON syntax was encountered during scanning.
var ErrMultipleDocumentNodeFound = errors.New("multiple document node found in a yaml. FromYAML only supports a single document node")
var ErrNonScalarNode = errors.New("this is not a scalar node but called NodeScalarValue method")
var ErrUnknownYAMLNodeKind = errors.New("unknown yaml node kind")
Functions ¶
func GetCache ¶ added in v0.58.4
func GetCache[T any](reader *NodeReader, key CacheKey[T]) (T, bool)
GetCache retrieves a cached value of type T for the given key from the reader in a thread-safe manner. Returns the zero value and false if no cached value for the key exists or reader is nil.
func GetMock ¶ added in v0.58.2
func GetMock[T any](reader *NodeReader) (T, bool)
GetMock retrieves a mocked value of type T from the NodeReader if it wraps a MockNode.
func ParseFieldPath ¶ added in v0.58.2
ParseFieldPath splits a field path string according to specified rules. It uses '.' as a delimiter, but '\.' is treated as an escaped literal dot.
func ReadReflect ¶
func ReadReflect[T any](r *NodeReader, path FieldPath, target T) error
ReadReflect unmarshals the structured data into a given type after the given FieldPath. TODO: ReadReflect currently marshals and unmarshals the structured data into the target.
There should be room to improve this behavior regarding the performance.
func ReadReflectK8sRuntimeObject ¶
func ReadReflectK8sRuntimeObject[T runtime.Object](r *NodeReader, path FieldPath, target T) error
ReadReflectK8sRuntimeObject unmarshals the structured data into a type implementing runtime.Object.
func SetCache ¶ added in v0.58.4
func SetCache[T any](reader *NodeReader, key CacheKey[T], val T)
SetCache stores a cached value of type T for the given key into the reader in a thread-safe, lock-free manner.
Types ¶
type AlphabeticalGoMapKeyOrderProvider ¶
type AlphabeticalGoMapKeyOrderProvider struct {
}
AlphabeticalGoMapKeyOrderProvider implements GoMapKeyOrderProvider with sorting map keys by alphabetical order.
func (*AlphabeticalGoMapKeyOrderProvider) GetOrderedKeys ¶
type CacheKey ¶ added in v0.58.4
type CacheKey[T any] struct { // contains filtered or unexported fields }
CacheKey is a type-safe token identifying a cached extraction result of type T associated with a NodeReader.
func NewCacheKey ¶ added in v0.58.4
NewCacheKey allocates a globally unique type-safe cache key for values of type T.
type DefaultMergeMapOrderStrategy ¶
type DefaultMergeMapOrderStrategy struct {
}
func (*DefaultMergeMapOrderStrategy) GetMergedKeyOrder ¶
func (d *DefaultMergeMapOrderStrategy) GetMergedKeyOrder(prevKeys []string, patchKeys []string, directiveKeys []string) ([]string, error)
GetMergedKeyOrder implements MergeMapOrderStrategy.
type FieldPath ¶ added in v0.58.2
type FieldPath struct {
// contains filtered or unexported fields
}
FieldPath represents a pre-parsed and interned field path for fast traversal on StandardMapNode.
func CompileFieldPath ¶ added in v0.58.2
CompileFieldPath parses and interns a field path string (e.g., "resource.labels.node_name").
type GoMapKeyOrderProvider ¶
type GoMapKeyOrderProvider interface {
// GetOrderedKeys returns the keys of map in the order to store keys. This interface is necessary because the order of map keys are not stable in Go.
GetOrderedKeys(fieldPath []string, mapToDecideOrder map[string]any) ([]string, error)
}
GoMapKeyOrderProvider decides the order of keys from the given map.
type JSONNodeSerializer ¶
type JSONNodeSerializer struct{}
type LazyJSONBlockBuilder ¶ added in v0.58.4
type LazyJSONBlockBuilder struct {
// contains filtered or unexported fields
}
LazyJSONBlockBuilder batches multiple JSON entries into blocks, registers them into LazyJSONBlockStore, and compresses them when size thresholds are reached.
func (*LazyJSONBlockBuilder) Add ¶ added in v0.58.4
func (b *LazyJSONBlockBuilder) Add(data []byte) *LazyJSONNode
Add appends a JSON byte slice to the current block buffer and returns a LazyJSONNode pointing to its location.
func (*LazyJSONBlockBuilder) Flush ¶ added in v0.58.4
func (b *LazyJSONBlockBuilder) Flush()
Flush compresses and commits any remaining entries in the current block buffer.
type LazyJSONBlockStore ¶ added in v0.58.4
type LazyJSONBlockStore struct {
// contains filtered or unexported fields
}
LazyJSONBlockStore manages blocks of compressed JSON data with a sharded LRU cache for decompressed blocks.
func NewDefaultLazyJSONBlockStore ¶ added in v0.58.4
func NewDefaultLazyJSONBlockStore() *LazyJSONBlockStore
NewDefaultLazyJSONBlockStore creates a new LazyJSONBlockStore with default 1 GB uncompressed cache capacity.
func NewLazyJSONBlockStore ¶ added in v0.58.4
func NewLazyJSONBlockStore(shardCount, shardCap int) *LazyJSONBlockStore
NewLazyJSONBlockStore creates a new LazyJSONBlockStore with the specified shard count and shard capacity.
func (*LazyJSONBlockStore) GetBuffer ¶ added in v0.58.4
func (s *LazyJSONBlockStore) GetBuffer(blockID, offset, length uint32) []byte
GetBuffer retrieves a byte slice from the uncompressed block at the given offset and length.
func (*LazyJSONBlockStore) NewBuilder ¶ added in v0.58.4
func (s *LazyJSONBlockStore) NewBuilder(maxEntries, maxBytes int) *LazyJSONBlockBuilder
NewBuilder creates a new LazyJSONBlockBuilder for appending log entries into this store.
func (*LazyJSONBlockStore) ReserveBlock ¶ added in v0.58.4
func (s *LazyJSONBlockStore) ReserveBlock(initialUncompressed []byte) uint32
ReserveBlock registers a new block with initial uncompressed bytes and returns its unique block ID.
func (*LazyJSONBlockStore) SetCompressed ¶ added in v0.58.4
func (s *LazyJSONBlockStore) SetCompressed(blockID uint32, compressed []byte)
SetCompressed assigns compressed bytes to the designated block and inserts it into the LRU cache.
type LazyJSONNode ¶ added in v0.57.10
type LazyJSONNode struct {
// contains filtered or unexported fields
}
LazyJSONNode represents structured data backed by an entry in LazyJSONBlockStore and an offset index. Child nodes reuse the underlying block reference without allocating sub-slices, adjusting only the offset index.
func (*LazyJSONNode) Children ¶ added in v0.57.10
func (n *LazyJSONNode) Children() NodeChildrenIterator
Children returns an iterator function over the children of this node.
func (*LazyJSONNode) GetChildByKey ¶ added in v0.58.2
func (n *LazyJSONNode) GetChildByKey(key string) (Node, bool)
GetChildByKey returns the child node matching the string key without allocating iterator closures or non-matching child nodes.
func (*LazyJSONNode) Len ¶ added in v0.57.10
func (n *LazyJSONNode) Len() int
Len returns the count of items in a map or sequence, or 0 for scalars.
func (*LazyJSONNode) NodeScalarValue ¶ added in v0.57.10
func (n *LazyJSONNode) NodeScalarValue() (any, error)
NodeScalarValue returns the scalar value of this node.
func (*LazyJSONNode) Type ¶ added in v0.57.10
func (n *LazyJSONNode) Type() NodeType
Type returns the NodeType of this node.
type MergeArrayStrategy ¶
type MergeArrayStrategy string
const MergeStrategyMerge MergeArrayStrategy = "merge"
const MergeStrategyReplace MergeArrayStrategy = "replace"
type MergeConfigResolver ¶
type MergeConfigResolver struct {
Parent *MergeConfigResolver
MergeStrategies map[string]MergeArrayStrategy
MergeKeys map[string]string
}
func (*MergeConfigResolver) GetMergeArrayStrategy ¶
func (r *MergeConfigResolver) GetMergeArrayStrategy(fieldPath string) MergeArrayStrategy
func (*MergeConfigResolver) GetMergeKey ¶
func (r *MergeConfigResolver) GetMergeKey(fieldPath string) (string, error)
type MergeConfiguration ¶
type MergeConfiguration struct {
// MergeMapOrderStrategy decides the order of map keys generated by the merge.
MergeMapOrderStrategy MergeMapOrderStrategy
// ArrayMergeConfigResolver resolves array merge strategy of a sequence node at a specific node.
// Arrays defined in kubernetes manifest can be replaced or merged with using keys. These are different by the field path of the manifest.
ArrayMergeConfigResolver *MergeConfigResolver
// contains filtered or unexported fields
}
MergeConfiguration contains configurations of merging a previous node and patch node. This configuration is modified throughout walking every nodes during the merging.
func (*MergeConfiguration) GetArrayMergeStrategyAndKey ¶
func (c *MergeConfiguration) GetArrayMergeStrategyAndKey(fieldPath []string) (strategy MergeArrayStrategy, mergeKey string, err error)
GetArrayMergeStrategyAndKey returns the strategy of merging a sequence of maps and the key field name used for merging.
type MergeMapOrderStrategy ¶
type MergeMapOrderStrategy interface {
// GetMergedKeyOrder returns the order of keys after merging.
// prevKeys is the keys of previous map.
// patchKeys is the keys of patch map.
// directiveKeys is the keys only found in the strategic patch merge directives. These fields are missing in prev and patch, but the existence is inferred from the directives.
GetMergedKeyOrder(prevKeys []string, patchKeys []string, directiveKeys []string) ([]string, error)
}
type MockNode ¶ added in v0.58.2
type MockNode struct {
// contains filtered or unexported fields
}
MockNode is a specialized Node for unit tests that stores typed mock values.
func NewMockNode ¶ added in v0.58.2
NewMockNode instantiates a MockNode containing the given mock values.
func (*MockNode) Children ¶ added in v0.58.2
func (m *MockNode) Children() NodeChildrenIterator
Children implements Node.
func (*MockNode) Get ¶ added in v0.58.2
Get retrieves a mock value of the target type (supports both value and pointer registrations).
func (*MockNode) GetChildByKey ¶ added in v0.58.2
GetChildByKey implements Node.
func (*MockNode) NodeScalarValue ¶ added in v0.58.2
NodeScalarValue implements Node.
type Node ¶
type Node interface {
Type() NodeType
NodeScalarValue() (any, error)
Children() NodeChildrenIterator
Len() int
// GetChildByKey returns the child node matching the key.
// For MapNodeType, implementations should perform direct lookup without iterating all children.
GetChildByKey(key string) (Node, bool)
}
Node interface is a recursive data structure representing structured data.
func FromGoValue ¶
func FromGoValue(source any, mapKeyOrderProvider GoMapKeyOrderProvider) (Node, error)
FromGoValue instantiate the Node interface from given Go map, slice or scalars.
func MergeNode ¶
func MergeNode(prev Node, patch Node, config MergeConfiguration) (Node, error)
MergeNode merge a previous node with patch node and generates a new Node. This patch supports strategic-merge patch https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/strategic-merge-patch.md Refer the following mermaid graph to understand call hierarchy. ```mermaid flowchart TD
MergeNode --> mergeNode mergeNode -->|when the node is scalar| mergeScalarNode mergeNode -->|when the node is sequence| mergeSequenceNode mergeNode -->|when the node is map| mergeMapNode mergeSequenceNode -->|when the sequence items are scalar| mergeScalarSequenceNode mergeSequenceNode -->|when the sequence items are sequence| mergeSequenceSequenceNode mergeSequenceNode -->|when the sequence items are map| mergeMapSequenceNode mergeMapSequenceNode -->|when the patch policy is replace| mergeMapSequenceNodeWithReplaceStrategy mergeMapSequenceNode -->|when the patch policy is merge| mergeMapSequenceNodeWithMergeStrategy mergeMapNode o-..->|for each items| mergeNode mergeSequenceSequenceNode o-..->|for each sequences| mergeNode mergeMapSequenceNodeWithReplaceStrategy o-..->|for each maps| mergeNode mergeMapSequenceNodeWithMergeStrategy o-.->|for each maps| mergeNode
```
func NewFieldFilterNode ¶ added in v0.56.0
NewFieldFilterNode returns a filtered Node that wraps the original Node. It filters out any map children whose keys are present in the ignored keys list.
func NewLazyJSONNode ¶ added in v0.57.10
func NewLazyJSONNode(store *LazyJSONBlockStore, node Node) (Node, error)
NewLazyJSONNode serializes a given Node to JSON and registers it into the LazyJSONBlockStore.
func NewLazyJSONNodeFromBytes ¶ added in v0.57.10
func NewLazyJSONNodeFromBytes(store *LazyJSONBlockStore, data []byte) Node
NewLazyJSONNodeFromBytes creates a LazyJSONNode backed by a LazyJSONBlockStore from a JSON byte slice.
func NewStandardMap ¶
NewStandardMap returns a map node from given key and values with keeping the order of map keys.
func NewStandardSequenceNode ¶ added in v0.56.0
NewStandardSequenceNode returns a sequence node from given values.
func WithKeyOrder ¶ added in v0.57.10
WithKeyOrder wraps a map Node to customize its Children() iteration order. It yields children with keys matching priorityKeys in the specified order first, followed by any remaining children in their original order. If the node is not a MapNodeType or priorityKeys is empty, it returns the original node.
func WithScalarField ¶
func WithScalarField[T comparable](node Node, fieldPath []string, value T) (Node, error)
WithScalarField add a new scalar value node at the specified field path.
type NodeChildrenIterator ¶
type NodeChildrenIterator = func(func(key NodeChildrenKey, value Node) bool)
NodeChildrenIterator is a type to represent the iterator returned from the Children method of Node interface.
type NodeChildrenKey ¶
type NodeChildrenKey struct {
// Index is the index of the children
Index int
// Key is the key of the children in the map.
// This value is empty when the Node is a sequence and not a map.
Key string
}
NodeChildrenElement represents an item of Chidlren of a Node.
type NodeReader ¶
type NodeReader struct {
Node
// contains filtered or unexported fields
}
NodeReader provides a convenient way to read values from a node structure. It offers type-safe accessor methods and path navigation capabilities.
func NewNodeReader ¶
func NewNodeReader(node Node) *NodeReader
NewNodeReader creates a new NodeReader instance from a given Node.
func (*NodeReader) Children ¶
func (n *NodeReader) Children() NodeReaderChildrenIterator
Children returns an iterator for navigating through readers of the children of this node.
func (*NodeReader) GetNode ¶ added in v0.58.2
func (n *NodeReader) GetNode(path FieldPath) (Node, error)
GetNode obtains the Node at the given pre-compiled FieldPath.
func (*NodeReader) GetReader ¶
func (n *NodeReader) GetReader(path FieldPath) (*NodeReader, error)
GetReader obtains a NodeReader at the given pre-compiled FieldPath.
func (*NodeReader) Has ¶
func (n *NodeReader) Has(path FieldPath) bool
Has checks if a field exists at the pre-compiled FieldPath.
func (*NodeReader) ReadBool ¶
func (n *NodeReader) ReadBool(path FieldPath) (bool, error)
ReadBool retrieves a boolean value from the pre-compiled FieldPath. Returns an error if the field doesn't exist or cannot be cast to a boolean.
func (*NodeReader) ReadBoolOrDefault ¶
func (n *NodeReader) ReadBoolOrDefault(path FieldPath, defaultValue bool) bool
ReadBoolOrDefault retrieves a boolean value from the pre-compiled FieldPath.
func (*NodeReader) ReadFloat ¶
func (n *NodeReader) ReadFloat(path FieldPath) (float64, error)
ReadFloat retrieves a floating-point value from the pre-compiled FieldPath. Returns an error if the field doesn't exist or cannot be cast to a float64.
func (*NodeReader) ReadFloatOrDefault ¶
func (n *NodeReader) ReadFloatOrDefault(path FieldPath, defaultValue float64) float64
ReadFloatOrDefault retrieves a floating-point value from the pre-compiled FieldPath.
func (*NodeReader) ReadInt ¶
func (n *NodeReader) ReadInt(path FieldPath) (int, error)
ReadInt retrieves an integer value from the pre-compiled FieldPath. Returns an error if the field doesn't exist or cannot be cast to an integer.
func (*NodeReader) ReadIntOrDefault ¶
func (n *NodeReader) ReadIntOrDefault(path FieldPath, defaultValue int) int
ReadIntOrDefault retrieves an integer value from the pre-compiled FieldPath.
func (*NodeReader) ReadString ¶
func (n *NodeReader) ReadString(path FieldPath) (string, error)
ReadString retrieves a string value from the pre-compiled FieldPath. Returns an error if the field doesn't exist or cannot be cast to a string.
func (*NodeReader) ReadStringOrDefault ¶
func (n *NodeReader) ReadStringOrDefault(path FieldPath, defaultValue string) string
ReadStringOrDefault retrieves a string value from the pre-compiled FieldPath.
func (*NodeReader) ReadTimestamp ¶
func (n *NodeReader) ReadTimestamp(path FieldPath) (time.Time, error)
ReadTimestamp retrieves a timestamp value from the pre-compiled FieldPath. Returns an error if the field doesn't exist or cannot be cast to a time.Time.
func (*NodeReader) ReadTimestampOrDefault ¶
ReadTimestampOrDefault retrieves a timestamp value from the pre-compiled FieldPath.
func (*NodeReader) Serialize ¶
func (n *NodeReader) Serialize(path FieldPath, serializer NodeSerializer) ([]byte, error)
Serialize serializes the structured data at the given pre-compiled FieldPath with the given NodeSerializer.
func (*NodeReader) WithKeyOrder ¶ added in v0.57.10
func (n *NodeReader) WithKeyOrder(priorityKeys ...string) *NodeReader
WithKeyOrder returns a new NodeReader wrapping the node with the specified key order.
type NodeReaderChildrenIterator ¶
type NodeReaderChildrenIterator = func(func(key NodeChildrenKey, value NodeReader) bool)
NodeReaderChildrenIterator is a type that represents an iterator function for navigating
type NodeSerializer ¶
type OrderedMapNode ¶ added in v0.59.0
type OrderedMapNode struct {
// contains filtered or unexported fields
}
OrderedMapNode wraps a map Node and customizes its Children() iteration order.
func (*OrderedMapNode) Children ¶ added in v0.59.0
func (o *OrderedMapNode) Children() NodeChildrenIterator
Children implements Node.
func (*OrderedMapNode) GetChildByKey ¶ added in v0.59.0
func (o *OrderedMapNode) GetChildByKey(key string) (Node, bool)
GetChildByKey implements Node.
func (*OrderedMapNode) Len ¶ added in v0.59.0
func (o *OrderedMapNode) Len() int
Len implements Node.
func (*OrderedMapNode) NodeScalarValue ¶ added in v0.59.0
func (o *OrderedMapNode) NodeScalarValue() (any, error)
NodeScalarValue implements Node.
func (*OrderedMapNode) Type ¶ added in v0.59.0
func (o *OrderedMapNode) Type() NodeType
Type implements Node.
func (*OrderedMapNode) Unwrap ¶ added in v0.59.0
func (o *OrderedMapNode) Unwrap() Node
Unwrap returns the inner wrapped Node.
type StandardMapNode ¶
type StandardMapNode struct {
// contains filtered or unexported fields
}
StandardMapNode is a map field of structured data implementing Node interface. This type retain the order of keys.
func (*StandardMapNode) Children ¶
func (n *StandardMapNode) Children() NodeChildrenIterator
func (*StandardMapNode) GetChildByHandle ¶ added in v0.58.2
GetChildByHandle returns the child node matching the unique handle without allocating iterator closures.
func (*StandardMapNode) GetChildByKey ¶ added in v0.58.2
func (n *StandardMapNode) GetChildByKey(key string) (Node, bool)
GetChildByKey returns the child node matching the string key without allocating iterator closures.
func (*StandardMapNode) Len ¶
func (n *StandardMapNode) Len() int
func (*StandardMapNode) MarshalJSON ¶
func (n *StandardMapNode) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*StandardMapNode) MarshalYAML ¶
func (n *StandardMapNode) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*StandardMapNode) NodeScalarValue ¶
func (n *StandardMapNode) NodeScalarValue() (any, error)
func (*StandardMapNode) Type ¶
func (n *StandardMapNode) Type() NodeType
type StandardScalarNode ¶
type StandardScalarNode[T comparable] struct { // contains filtered or unexported fields }
StandardScalarNode is a leaf of structured data implementing Node interface.
func NewStandardScalarNode ¶
func NewStandardScalarNode[T comparable](value T) *StandardScalarNode[T]
NewStandardScalarNode instantiates the value of StandardScalarNode from the given value.
func (*StandardScalarNode[T]) Children ¶
func (n *StandardScalarNode[T]) Children() NodeChildrenIterator
func (*StandardScalarNode[T]) GetChildByKey ¶ added in v0.58.2
func (n *StandardScalarNode[T]) GetChildByKey(key string) (Node, bool)
GetChildByKey implements Node.
func (*StandardScalarNode[T]) Len ¶
func (n *StandardScalarNode[T]) Len() int
func (*StandardScalarNode[T]) MarshalJSON ¶
func (n *StandardScalarNode[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*StandardScalarNode[T]) MarshalYAML ¶
func (n *StandardScalarNode[T]) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*StandardScalarNode[T]) NodeScalarValue ¶
func (n *StandardScalarNode[T]) NodeScalarValue() (any, error)
func (*StandardScalarNode[T]) Type ¶
func (n *StandardScalarNode[T]) Type() NodeType
type StandardSequenceNode ¶
type StandardSequenceNode struct {
// contains filtered or unexported fields
}
StandardScalarNode is a sequence field of a structured data implementing Node interface.
func (*StandardSequenceNode) Children ¶
func (n *StandardSequenceNode) Children() NodeChildrenIterator
func (*StandardSequenceNode) GetChildByKey ¶ added in v0.58.2
func (n *StandardSequenceNode) GetChildByKey(key string) (Node, bool)
GetChildByKey implements Node.
func (*StandardSequenceNode) Len ¶
func (n *StandardSequenceNode) Len() int
func (*StandardSequenceNode) MarshalJSON ¶
func (n *StandardSequenceNode) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*StandardSequenceNode) MarshalYAML ¶
func (n *StandardSequenceNode) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marshaler.
func (*StandardSequenceNode) NodeScalarValue ¶
func (n *StandardSequenceNode) NodeScalarValue() (any, error)
func (*StandardSequenceNode) Type ¶
func (n *StandardSequenceNode) Type() NodeType
type YAMLNodeSerializer ¶
type YAMLNodeSerializer struct{}