addhdlrs

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForUnknown

func CheckForUnknown(fldPath *field.Path, plainOrig, accepted interface{}) error

func CheckForUnknownForData

func CheckForUnknownForData(fldPath *field.Path, orig []byte, accepted interface{}) error

func PrintElements

func PrintElements(p common2.Printer, elems []Element, outfile string, fss ...vfs.FileSystem) error

func Validate

func Validate(r *ResourceInput, ctx inputs.Context, inputFilePath string) error

func ValidateElementIdentities

func ValidateElementIdentities(kind string, elems []Element) error

func ValidateElementSpecIdentities

func ValidateElementSpecIdentities(kind string, src string, elems []ElementSpec) error

ValidateElementSpecIdentities validate the element specifications taken from some source (for example a resources.yaml or component-constructor.yaml). The parameter src somehow identifies the element source, for example the path of the parsed file.

Types

type Element

type Element interface {
	// Source provides info about the source the element has been
	// derived from. (for example a component-constructor.yaml or resources.yaml).
	Source() SourceInfo
	// Spec provides access to the element specification.
	Spec() ElementSpec
	// Type is used for types elements, like sources and resources.
	Type() string
	// Data provides access to the element descriptor representation.
	Data() []byte
	// Input provides access to the underlying data specification.
	// It is either an access specification or an input specification.
	Input() *ResourceInput
}

Element is the abstraction over model elements handled by the add handler, for example, resources, sources, references or complete component versions.

func DetermineElement

func DetermineElement(ctx clictx.Context, ictx inputs.Context, si SourceInfo, d map[string]interface{}, h ElementSpecHandler) (Element, error)

func DetermineElementForData

func DetermineElementForData(ctx clictx.Context, ictx inputs.Context, si SourceInfo, d []byte, h ElementSpecHandler) (Element, error)

func DetermineElements

func DetermineElements(ctx clictx.Context, ictx inputs.Context, origin SourceInfo, d interface{}, h ElementSpecHandler) ([]Element, error)

DetermineElements maps a list of raw element specifications into an evaluated element list.

func DetermineElementsForSource

func DetermineElementsForSource(ctx clictx.Context, ictx inputs.Context, templ template.Options, h ElementSpecHandler, source ElementSource) ([]Element, error)

func MapSpecsToElems

func MapSpecsToElems[T ElementSpec](ctx clictx.Context, ictx inputs.Context, si SourceInfo, specs []T, h ElementSpecHandler) ([]Element, error)

func NewElement

func NewElement(spec ElementSpec, input *ResourceInput, src SourceInfo, data []byte, indices ...interface{}) Element

func ProcessDescriptions

func ProcessDescriptions(ctx clictx.Context, printer common2.Printer, templ template.Options, h ElementSpecHandler, sources []ElementSource) ([]Element, inputs.Context, error)

type ElementSource

type ElementSource interface {
	// Origin provides access to the source
	// specification used to provide elements.
	Origin() SourceInfo
	// Get provides access to the content of the element source.
	Get() (string, error)
}

type ElementSpec

type ElementSpec interface {
	GetName() string
	GetVersion() string
	SetVersion(string)
	GetRawIdentity() metav1.Identity
	Info() string
	Validate(ctx clictx.Context, input *ResourceInput) error
}

ElementSpec is the specification of the model element. It provides access to common attributes, like the identity.

func DecodeElement

func DecodeElement(data []byte, h ElementSpecHandler) (ElementSpec, error)

type ElementSpecHandler

type ElementSpecHandler interface {
	Key() string
	RequireInputs() bool
	Decode(data []byte) (ElementSpec, error)
}

ElementSpecHandler is the interface for a handler responsible to handle a dedicated kind of element specification.

type Options

type Options struct {
	Replace bool
}

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) ApplyBlobModificationOption

func (o *Options) ApplyBlobModificationOption(opts *ocm.BlobModificationOptions)

func (*Options) ApplyModificationOption

func (o *Options) ApplyModificationOption(opts *ocm.ModificationOptions)

func (*Options) ApplyTargetOption

func (o *Options) ApplyTargetOption(opts *ocm.TargetOptions)

func (*Options) Description

func (o *Options) Description() string

type ResourceInput

type ResourceInput struct {
	// SourceFile described the original source (file) the input
	// is taken from. By default, this is not set since it is taken from the
	// file information of the processed constructor resource.
	// If an input aggregated in a constructor resource is provided
	// by some other source, this field can be set.
	// The source information is finally used by the input implementations
	// to evaluate relative path specifications in the input specification.
	// This should always relate to the original source.
	SourceFile string                 `json:"sourceFile,omitempty"`
	Access     *cpi.GenericAccessSpec `json:"access"`
	// Input  *inputs.BlobInput                `json:"input,omitempty"`
	Input *inputs.GenericInputSpec `json:"input,omitempty"`
}

ResourceInput describe the source for the content of a content based element (sources or resources). It is either an input or access specification.

func DecodeInput

func DecodeInput(data []byte, ctx clictx.Context) (*ResourceInput, error)

func (*ResourceInput) SetSourceFile added in v0.16.0

func (r *ResourceInput) SetSourceFile(s string)

type ResourceSpecHandlerBase

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

func NewBase

func NewBase(opts ...options.Options) ResourceSpecHandlerBase

func (*ResourceSpecHandlerBase) AddFlags

func (h *ResourceSpecHandlerBase) AddFlags(opts *pflag.FlagSet)

func (*ResourceSpecHandlerBase) GetOptions

func (h *ResourceSpecHandlerBase) GetOptions() options.OptionSet

func (*ResourceSpecHandlerBase) GetTargetOpts

func (h *ResourceSpecHandlerBase) GetTargetOpts() []ocm.TargetOption

func (*ResourceSpecHandlerBase) RequireInputs

func (*ResourceSpecHandlerBase) RequireInputs() bool

func (*ResourceSpecHandlerBase) WithCLIOptions

type SourceInfo

type SourceInfo interface {
	Origin() string
	Id() string

	String() string
	Sub(indices ...interface{}) SourceInfo
}

func NewSourceInfo

func NewSourceInfo(origin string) SourceInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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