Documentation
¶
Overview ¶
Package runtime defines an internal runtime to work with component constructors in all schema versions without restricting the code to the public API for future major changes.
Overall this package makes it easier to work with embedded types as well due to its reliance on interfaces instead of Raw like the external versions.
This package should be preferred whenever working with non-serialization relevant routines (such as working with accesses or components)
This package SHOULD NOT be used for serialization and any kind of attempt at serialization will fail on purpose, be buggy and is not supported!
Instead, use dedicated converters to the scheme versions available.
This package is not guaranteed to be stable, but will always support conversion from and to all advertised component descriptor schemes.
Thus, it is much easier to migrate from/to than if one would program against the scheme directly.
The conversions offered in this package are guaranteed to be lossless unless otherwise specified, so it is usually safe to convert back and forth between scheme versions.
Index ¶
- Constants
- func AsRawMessage(value interface{}) (json.RawMessage, error)
- func ConvertAccessToDescriptor(accessOrInput AccessOrInput) runtime.Typed
- func ConvertElementMetaToDescriptor(meta ElementMeta) descriptor.ElementMeta
- func ConvertObjectMetaToDescriptor(meta ObjectMeta) descriptor.ObjectMeta
- func ConvertProviderToDescriptor(provider Provider) (descriptor.Provider, error)
- func ConvertToDescriptor(constructor *ComponentConstructor) *descriptor.Descriptor
- func ConvertToDescriptorComponent(component *Component) *descriptor.Component
- func ConvertToDescriptorLabels(labels []Label) []descriptor.Label
- func ConvertToDescriptorReference(reference *Reference) *descriptor.Reference
- func ConvertToDescriptorResource(resource *Resource) *descriptor.Resource
- func ConvertToDescriptorSource(source *Source) *descriptor.Source
- func ConvertToDescriptorSourceRefs(refs []SourceRef) []descriptor.SourceRef
- func ConvertToV1Component(component *Component) (*v1.Component, error)
- func ConvertToV1ElementMeta(meta ElementMeta) v1.ElementMeta
- func ConvertToV1Labels(labels []Label) []v1.Label
- func ConvertToV1ObjectMeta(meta ObjectMeta) v1.ObjectMeta
- func ConvertToV1Reference(reference *Reference) (*v1.Reference, error)
- func ConvertToV1Resource(resource *Resource) (*v1.Resource, error)
- func ConvertToV1Source(source *Source) (*v1.Source, error)
- func MustAsRawMessage(value interface{}) json.RawMessage
- type AccessOrInput
- type Component
- type ComponentConstructor
- type ComponentMeta
- type ConstructorAttributes
- type CopyPolicy
- type ElementMeta
- type Label
- type Meta
- type ObjectMeta
- type Provider
- type Reference
- type Resource
- type ResourceRelation
- type Source
- type SourceRef
Constants ¶
const ( IdentityAttributeName = "name" IdentityAttributeVersion = "version" )
These constants describe identity attributes predefined by the model used to identify elements (resources, sources and references) in a component version.
Variables ¶
This section is empty.
Functions ¶
func AsRawMessage ¶
func AsRawMessage(value interface{}) (json.RawMessage, error)
AsRawMessage converts any given value to a json.RawMessage.
func ConvertAccessToDescriptor ¶
func ConvertAccessToDescriptor(accessOrInput AccessOrInput) runtime.Typed
ConvertAccessToDescriptor converts runtime AccessOrInput to descriptor Typed. Returns nil if the input Access is nil.
func ConvertElementMetaToDescriptor ¶
func ConvertElementMetaToDescriptor(meta ElementMeta) descriptor.ElementMeta
ConvertElementMetaToDescriptor converts runtime ElementMeta to descriptor ElementMeta.
func ConvertObjectMetaToDescriptor ¶
func ConvertObjectMetaToDescriptor(meta ObjectMeta) descriptor.ObjectMeta
ConvertObjectMetaToDescriptor converts runtime ObjectMeta to descriptor ObjectMeta.
func ConvertProviderToDescriptor ¶
func ConvertProviderToDescriptor(provider Provider) (descriptor.Provider, error)
ConvertProviderToDescriptor converts runtime Provider to descriptor Provider. Returns an error if the conversion fails.
func ConvertToDescriptor ¶
func ConvertToDescriptor(constructor *ComponentConstructor) *descriptor.Descriptor
ConvertToDescriptor converts a ComponentConstructor to a Descriptor. Returns nil if the input is nil or has no components.
func ConvertToDescriptorComponent ¶
func ConvertToDescriptorComponent(component *Component) *descriptor.Component
ConvertToDescriptorComponent converts a runtime Component to descriptor Component. Returns nil if the input is nil.
func ConvertToDescriptorLabels ¶
func ConvertToDescriptorLabels(labels []Label) []descriptor.Label
ConvertToDescriptorLabels converts a slice of runtime Labels to descriptor Labels. Returns nil if the input slice is nil.
func ConvertToDescriptorReference ¶
func ConvertToDescriptorReference(reference *Reference) *descriptor.Reference
ConvertToDescriptorReference converts a runtime Reference to descriptor Reference. Returns nil if the input is nil.
func ConvertToDescriptorResource ¶
func ConvertToDescriptorResource(resource *Resource) *descriptor.Resource
ConvertToDescriptorResource converts a runtime Resource to descriptor Resource. Returns nil if the input is nil.
func ConvertToDescriptorSource ¶
func ConvertToDescriptorSource(source *Source) *descriptor.Source
ConvertToDescriptorSource converts a runtime Source to descriptor Source. Returns nil if the input is nil.
func ConvertToDescriptorSourceRefs ¶
func ConvertToDescriptorSourceRefs(refs []SourceRef) []descriptor.SourceRef
ConvertToDescriptorSourceRefs converts runtime SourceRefs to descriptor SourceRefs. Returns nil if the input slice is nil.
func ConvertToV1Component ¶
ConvertToV1Component converts a runtime Component to v1 Component. Returns nil if the input is nil.
func ConvertToV1ElementMeta ¶
func ConvertToV1ElementMeta(meta ElementMeta) v1.ElementMeta
ConvertToV1ElementMeta converts runtime ElementMeta to v1 ElementMeta.
func ConvertToV1Labels ¶
ConvertToV1Labels converts a slice of runtime Labels to v1 Labels. Returns nil if the input slice is nil.
func ConvertToV1ObjectMeta ¶
func ConvertToV1ObjectMeta(meta ObjectMeta) v1.ObjectMeta
ConvertToV1ObjectMeta converts runtime ObjectMeta to v1 ObjectMeta.
func ConvertToV1Reference ¶
ConvertToV1Reference converts a runtime Reference to v1 Reference. Returns nil if the input is nil.
func ConvertToV1Resource ¶
ConvertToV1Resource converts a runtime Resource to v1 Resource. Returns nil and no error if the input is nil.
func ConvertToV1Source ¶
ConvertToV1Source converts a runtime Source to v1 Source. Returns nil and no error if the input is nil.
func MustAsRawMessage ¶
func MustAsRawMessage(value interface{}) json.RawMessage
MustAsRawMessage converts any given value to a json.RawMessage. It panics if the conversion fails, so it should only be used when the conversion is guaranteed to succeed.
Types ¶
type AccessOrInput ¶
AccessOrInput describes the access or input information of a resource or source. In a component constructor, there is only one access or input information. +k8s:deepcopy-gen=true
func ConvertAccessFromDescriptor ¶
func ConvertAccessFromDescriptor(access runtime.Typed) AccessOrInput
ConvertAccessFromDescriptor converts descriptor Typed to runtime AccessOrInput. Returns empty AccessOrInput if the input is nil.
func (*AccessOrInput) DeepCopy ¶
func (in *AccessOrInput) DeepCopy() *AccessOrInput
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AccessOrInput.
func (*AccessOrInput) DeepCopyInto ¶
func (in *AccessOrInput) DeepCopyInto(out *AccessOrInput)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*AccessOrInput) HasAccess ¶
func (a *AccessOrInput) HasAccess() bool
func (*AccessOrInput) HasInput ¶
func (a *AccessOrInput) HasInput() bool
func (*AccessOrInput) Validate ¶
func (a *AccessOrInput) Validate() error
type Component ¶
type Component struct {
ComponentMeta `json:",inline"`
Provider Provider `json:"-"`
Resources []Resource `json:"-"`
Sources []Source `json:"-"`
References []Reference `json:"-"`
}
Component defines a named and versioned component containing dependencies such as sources, resources and references pointing to further component versions. +k8s:deepcopy-gen=true
func ConvertFromDescriptorComponent ¶
func ConvertFromDescriptorComponent(component *descriptor.Component) *Component
ConvertFromDescriptorComponent converts a descriptor Component to runtime Component. Returns nil if the input is nil.
func ConvertToRuntimeComponent ¶
ConvertToRuntimeComponent converts a v1 Component to runtime Component. Returns an empty Component if the input is nil.
func (*Component) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Component.
func (*Component) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ComponentConstructor ¶
type ComponentConstructor struct {
Components []Component `json:"-"`
}
ComponentConstructor defines a constructor for creating component versions. +k8s:deepcopy-gen=true
func ConvertToRuntimeConstructor ¶
func ConvertToRuntimeConstructor(constructor *v1.ComponentConstructor) *ComponentConstructor
ConvertToRuntimeConstructor converts a v1 ComponentConstructor to runtime ComponentConstructor. Returns nil if the input is nil.
func (*ComponentConstructor) DeepCopy ¶
func (in *ComponentConstructor) DeepCopy() *ComponentConstructor
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentConstructor.
func (*ComponentConstructor) DeepCopyInto ¶
func (in *ComponentConstructor) DeepCopyInto(out *ComponentConstructor)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ComponentMeta ¶
type ComponentMeta struct {
ObjectMeta `json:",inline"`
// CreationTime is the creation time of the component version
CreationTime string `json:"-"`
}
ComponentMeta defines the metadata of a component. +k8s:deepcopy-gen=true
func (*ComponentMeta) DeepCopy ¶
func (in *ComponentMeta) DeepCopy() *ComponentMeta
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentMeta.
func (*ComponentMeta) DeepCopyInto ¶
func (in *ComponentMeta) DeepCopyInto(out *ComponentMeta)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ComponentMeta) ToIdentity ¶
func (r *ComponentMeta) ToIdentity() runtime.Identity
type ConstructorAttributes ¶
type ConstructorAttributes struct {
CopyPolicy `json:"-"`
}
ConstructorAttributes defines additional attributes used during component construction. +k8s:deepcopy-gen=true
func (*ConstructorAttributes) DeepCopy ¶
func (in *ConstructorAttributes) DeepCopy() *ConstructorAttributes
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConstructorAttributes.
func (*ConstructorAttributes) DeepCopyInto ¶
func (in *ConstructorAttributes) DeepCopyInto(out *ConstructorAttributes)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type CopyPolicy ¶
type CopyPolicy string
CopyPolicy defines how the given object should be added during the component construction. If set to "reference", the object is copied by reference, otherwise it is copied by value. Note that an object that is copied by reference may still have its access type modified. This can happen when the access is pinned at the point of the component construction.
- A typical example of "by value" copying is an image that should be stored in the component version, and not in the original registry.
- A typical example of "by reference" copying is an image that is already stored in the correct registry and should be referenced by the component version.
const ( // CopyPolicyByReference defines that the resource is copied by reference. See CopyPolicy for details. CopyPolicyByReference CopyPolicy = "byReference" // CopyPolicyByValue defines that the resource is copied by value. See CopyPolicy for details. CopyPolicyByValue CopyPolicy = "byValue" )
type ElementMeta ¶
type ElementMeta struct {
ObjectMeta `json:",inline"`
// ExtraIdentity is the identity of an object.
// An additional identity attribute with key "name" is not allowed
ExtraIdentity runtime.Identity `json:"-"`
}
ElementMeta defines an object with name and version containing labels. It is an implementation of the Element Identity as per https://github.com/open-component-model/ocm-spec/blob/main/doc/01-model/03-elements-sub.md#element-identity +k8s:deepcopy-gen=true
func ConvertElementMetaFromDescriptor ¶
func ConvertElementMetaFromDescriptor(meta descriptor.ElementMeta) ElementMeta
ConvertElementMetaFromDescriptor converts descriptor ElementMeta to runtime ElementMeta.
func ConvertFromV1ElementMeta ¶
func ConvertFromV1ElementMeta(meta v1.ElementMeta) ElementMeta
ConvertFromV1ElementMeta converts v1 ElementMeta to runtime ElementMeta.
func (*ElementMeta) DeepCopy ¶
func (in *ElementMeta) DeepCopy() *ElementMeta
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ElementMeta.
func (*ElementMeta) DeepCopyInto ¶
func (in *ElementMeta) DeepCopyInto(out *ElementMeta)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*ElementMeta) ToIdentity ¶
func (m *ElementMeta) ToIdentity() runtime.Identity
type Label ¶
type Label struct {
// Name is the unique name of the label.
Name string `json:"-"`
// Value is the json/yaml data of the label
Value json.RawMessage `json:"-"`
// Signing describes whether the label should be included into the signature
Signing bool `json:"-"`
// Version is the optional specification version of the attribute value
Version string `json:"-"`
}
Label that can be set on various objects in the Open Component Model domain. See https://github.com/open-component-model/ocm-spec/blob/main/doc/01-model/03-elements-sub.md#labels +k8s:deepcopy-gen=true
func ConvertFromDescriptorLabels ¶
func ConvertFromDescriptorLabels(labels []descriptor.Label) []Label
ConvertFromDescriptorLabels converts a slice of descriptor Labels to runtime Labels. Returns nil if the input slice is nil.
func ConvertFromV1Labels ¶
ConvertFromV1Labels converts a slice of v1 Labels to runtime Labels. Returns nil if the input slice is nil.
func (*Label) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Label.
func (*Label) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Meta ¶
type Meta struct {
// Version is the schema version of the component descriptor.
Version string `json:"-"`
}
Meta defines the metadata of the component descriptor. +k8s:deepcopy-gen=true
func (*Meta) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Meta.
func (*Meta) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ObjectMeta ¶
type ObjectMeta struct {
// Name is the context unique name of the object.
Name string `json:"-"`
// Version is the semver version of the object.
Version string `json:"-"`
// Labels defines an optional set of additional labels
// describing the object.
Labels []Label `json:"-"`
}
ObjectMeta defines an object that is uniquely identified by its name and version. Additionally the object can be defined by an optional set of labels. +k8s:deepcopy-gen=true
func ConvertFromV1ObjectMeta ¶
func ConvertFromV1ObjectMeta(meta v1.ObjectMeta) ObjectMeta
ConvertFromV1ObjectMeta converts v1 ObjectMeta to runtime ObjectMeta.
func ConvertObjectMetaFromDescriptor ¶
func ConvertObjectMetaFromDescriptor(meta descriptor.ObjectMeta) ObjectMeta
ConvertObjectMetaFromDescriptor converts descriptor ObjectMeta to runtime ObjectMeta.
func (*ObjectMeta) DeepCopy ¶
func (in *ObjectMeta) DeepCopy() *ObjectMeta
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectMeta.
func (*ObjectMeta) DeepCopyInto ¶
func (in *ObjectMeta) DeepCopyInto(out *ObjectMeta)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Provider ¶
Provider describes the provider of a component. It contains a name and optional labels. +k8s:deepcopy-gen=true
func (*Provider) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Provider.
func (*Provider) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Reference ¶
type Reference struct {
ElementMeta `json:",inline"`
// Component describes the remote name of the referenced object.
Component string `json:"-"`
}
Reference describes the reference to another component in the registry. A component version may refer to other component versions by adding a reference to the component version. +k8s:deepcopy-gen=true
func ConvertFromDescriptorReference ¶
func ConvertFromDescriptorReference(reference *descriptor.Reference) *Reference
ConvertFromDescriptorReference converts a descriptor Reference to runtime Reference. Returns nil if the input is nil.
func ConvertToRuntimeConstructorReference ¶
ConvertToRuntimeConstructorReference converts a v1 Reference to runtime Reference for use in a ComponentConstructor.
func ConvertToRuntimeReference ¶
ConvertToRuntimeReference converts a v1 Reference to runtime Reference. Returns an empty Reference if the input is nil. Note: This conversion is lossy as it does not include the digest field.
func (*Reference) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reference.
func (*Reference) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Reference) ToComponentIdentity ¶
type Resource ¶
type Resource struct {
ElementMeta `json:",inline"`
// SourceRefs defines a list of source names.
// These entries reference the sources defined in the
// component.sources.
SourceRefs []SourceRef `json:"-"`
// Type describes the type of the object.
Type string `json:"-"`
// Relation describes the relation of the resource to the component.
// Can be a local or external resource.
Relation ResourceRelation `json:"-"`
// AccessOrInput defines the access or input information of the resource.
// In a component constructor, there is only one access or input information.
AccessOrInput `json:"-"`
ConstructorAttributes `json:"-"`
}
A Resource is a delivery artifact, intended for deployment into a runtime environment, or describing additional content, relevant for a deployment mechanism. For example, installation procedures or meta-model descriptions controlling orchestration and/or deployment mechanisms. See https://github.com/open-component-model/ocm-spec/blob/main/doc/01-model/02-elements-toplevel.md#resources +k8s:deepcopy-gen=true
func ConvertFromDescriptorResource ¶
func ConvertFromDescriptorResource(resource *descriptor.Resource) *Resource
ConvertFromDescriptorResource converts a descriptor Resource to runtime Resource. Returns nil if the input is nil.
func ConvertFromV1Resource ¶
ConvertFromV1Resource converts a v1 Resource to runtime Resource. Returns an empty Resource if the input is nil.
func ConvertToRuntimeConstructorResource ¶
ConvertToRuntimeConstructorResource converts a v1 Resource to runtime Resource for use in a ComponentConstructor.
func (*Resource) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Resource.
func (*Resource) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ResourceRelation ¶
type ResourceRelation string
ResourceRelation describes whether the component is created by a third party or internally.
const ( // LocalRelation defines a internal relation // which describes a internally maintained resource in the origin's context. LocalRelation ResourceRelation = "local" // ExternalRelation defines a external relation // which describes a resource maintained by a third party vendor in the origin's context. ExternalRelation ResourceRelation = "external" )
type Source ¶
type Source struct {
ElementMeta `json:",inline"`
Type string `json:"-"`
// AccessOrInput defines the access or input information of the source.
// In a component constructor, there is only one access or input information.
AccessOrInput `json:"-"`
ConstructorAttributes `json:"-"`
}
Source is an artifact which describes the sources that were used to generate one or more of the resources. Source elements do not have specific additional formal attributes. See https://github.com/open-component-model/ocm-spec/blob/main/doc/01-model/02-elements-toplevel.md#sources +k8s:deepcopy-gen=true
func ConvertFromDescriptorSource ¶
func ConvertFromDescriptorSource(source *descriptor.Source) *Source
ConvertFromDescriptorSource converts a descriptor Source to runtime Source. Returns nil if the input is nil.
func ConvertFromV1Source ¶
ConvertFromV1Source converts a v1 Source to runtime Source. Returns an empty Source if the input is nil.
func ConvertToRuntimeConstructorSource ¶
ConvertToRuntimeConstructorSource converts a v1 Source to runtime Source for use in a ComponentConstructor.
func (*Source) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Source.
func (*Source) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type SourceRef ¶
type SourceRef struct {
// IdentitySelector provides selection means for sources.
IdentitySelector map[string]string `json:"-"`
// Labels provided for further identification and extra selection rules.
Labels []Label `json:"-"`
}
SourceRef defines a reference to a source. +k8s:deepcopy-gen=true
func ConvertFromDescriptorSourceRefs ¶
func ConvertFromDescriptorSourceRefs(refs []descriptor.SourceRef) []SourceRef
ConvertFromDescriptorSourceRefs converts descriptor SourceRefs to runtime SourceRefs. Returns nil if the input slice is nil.
func (*SourceRef) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceRef.
func (*SourceRef) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.