yamlutil

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIObject

type APIObject interface {
	runtime.Object
	GetName() string
}

APIObject represents a kubernetes API object.

type APIObjectGenerator

type APIObjectGenerator func() APIObject

APIObjectGenerator returns an implementor of the APIObject interface.

type Builder

type Builder interface {
	BuildFromParsed(ObjectLookup) error
}

Builder processes the parsed API objects contained in a lookup.

type Mapping

type Mapping[T APIObject] struct {
	New  func() T
	Kind string
}

Mapping mapping between a kubernetes Kind and an API concrete type of type T.

func NewMapping

func NewMapping[T APIObject](kind string, new func() T) Mapping[T]

func (Mapping[T]) ToAPIObjectMapping

func (m Mapping[T]) ToAPIObjectMapping() Mapping[APIObject]

ToAPIObjectMapping is helper to convert from other concrete types of Mapping to a APIObject Mapping This is mostly to help pass Mappings to RegisterMappings.

type ObjectLookup

type ObjectLookup map[string]APIObject

ObjectLookup allows to search APIObjects by a unique key composed of apiVersion, kind, and name.

func (ObjectLookup) GetFromRef

func (o ObjectLookup) GetFromRef(ref corev1.ObjectReference) APIObject

GetFromRef searches in a ObjectLookup for an APIObject referenced by a corev1.ObjectReference.

type ObjectLookupBuilder

type ObjectLookupBuilder struct {
	// contains filtered or unexported fields
}

ObjectLookupBuilder allows to construct an ObjectLookup and add APIObjects to it.

func NewObjectLookupBuilder

func NewObjectLookupBuilder() *ObjectLookupBuilder

func (*ObjectLookupBuilder) Add

Add acumulates an API object that will be included in the built ObjectLookup.

func (*ObjectLookupBuilder) Build

func (o *ObjectLookupBuilder) Build() ObjectLookup

Build constructs and returns an ObjectLookup After this method is called, the builder is reset and loses track of all previously added objects.

type ParsedProcessor

type ParsedProcessor[T any] func(*T, ObjectLookup)

ParsedProcessor fills the struct of type T with the parsed API objects in ObjectLookup.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser allows to parse from yaml with kubernetes style objects and store them in a type implementing Builder It allows to dynamically register configuration for mappings between kind and concrete types.

func NewParser

func NewParser(logger logr.Logger) *Parser

func (*Parser) Parse

func (p *Parser) Parse(yamlManifest []byte, b Builder) error

Parse reads yaml manifest content with the registered mappings and passes the result to the Builder for further processing.

func (*Parser) Read

func (p *Parser) Read(reader io.Reader, b Builder) error

Read reads yaml manifest content with the registered mappings and passes the result to the Builder for further processing.

func (*Parser) RegisterMapping

func (c *Parser) RegisterMapping(kind string, generator APIObjectGenerator) error

RegisterMapping records the mapping between a kubernetes Kind and an API concrete type.

func (*Parser) RegisterMappingForAnyKind added in v0.13.0

func (c *Parser) RegisterMappingForAnyKind(generator APIObjectGenerator)

RegisterMappingForAnyKind records an object generator that will be used as fallback when there is not a specific APIObjectGenerator registered for that particular kind.

func (*Parser) RegisterMappings

func (c *Parser) RegisterMappings(mappings ...Mapping[APIObject]) error

RegisterMappings records a collection of mappings.

Jump to

Keyboard shortcuts

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