dataobjects

package
v0.104.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHashableContent

func GetHashableContent(t *lsv1alpha1.Target) []byte

GetHashableContent returns the value of the Target based on which its hash can be computed. This is either .Spec.Configuration.RawMessage or a json representation of .Spec.SecretRef. If neither is set (or the given target is nil), nil is returned.

func SetMetadataFromObject

func SetMetadataFromObject(objAcc metav1.Object, meta Metadata)

SetMetadataFromObject sets the given metadata as the object's labels and annotations

func SetTargetMapKeyLabel

func SetTargetMapKeyLabel(target *lsv1alpha1.Target, targetMapKey string)

Types

type DataObject

type DataObject struct {
	Raw  *lsv1alpha1.DataObject
	Data interface{}

	FieldValue *lsv1alpha1.FieldValueDefinition
	Metadata   Metadata
	Def        *lsv1alpha1.DataImport
}

DataObject is the internal representation of a data object.

func New

func New() *DataObject

New creates a new internal dataobject.

func NewFromDataObject

func NewFromDataObject(do *lsv1alpha1.DataObject) (*DataObject, error)

NewFromDataObject creates a new internal dataobject instance from a raw data object.

func (DataObject) Apply

func (do DataObject) Apply(raw *lsv1alpha1.DataObject) error

Apply applies data and metadata to a existing object.

func (DataObject) Build

func (do DataObject) Build() (*lsv1alpha1.DataObject, error)

Build creates a new data object based on the given data and metadata.

func (*DataObject) ComputeConfigGeneration

func (do *DataObject) ComputeConfigGeneration() string

func (*DataObject) GetData

func (do *DataObject) GetData(path string, out interface{}) error

GetData searches its data for the given Javascript Object Notation path and unmarshals it into the given object

func (*DataObject) GetImportDefinition

func (do *DataObject) GetImportDefinition() interface{}

func (*DataObject) GetImportReference

func (do *DataObject) GetImportReference() string

func (*DataObject) GetImportType

func (do *DataObject) GetImportType() lsv1alpha1.ImportType

func (*DataObject) GetInClusterObject

func (do *DataObject) GetInClusterObject() client.Object

func (*DataObject) GetInClusterObjects

func (do *DataObject) GetInClusterObjects() []client.Object

func (*DataObject) GetListItems

func (do *DataObject) GetListItems() []ImportedBase

func (*DataObject) IsListTypeImport

func (do *DataObject) IsListTypeImport() bool

func (*DataObject) SetContext

func (do *DataObject) SetContext(ctx string) *DataObject

SetContext sets the installation context for the given data object.

func (*DataObject) SetData

func (do *DataObject) SetData(data interface{}) *DataObject

SetData sets the data for the given object.

func (*DataObject) SetJobID

func (do *DataObject) SetJobID(jobID string) *DataObject

func (*DataObject) SetKey

func (do *DataObject) SetKey(key string) *DataObject

SetKey sets the key for the given data object.

func (*DataObject) SetNamespace

func (do *DataObject) SetNamespace(ns string) *DataObject

SetNamespace sets the namespace for the given data object.

func (*DataObject) SetSource

func (do *DataObject) SetSource(src string) *DataObject

SetSource sets the source for the given data object.

func (*DataObject) SetSourceType

func (do *DataObject) SetSourceType(ctx lsv1alpha1.DataObjectSourceType) *DataObject

SetSourceType sets the context for the given data object.

type Imported

type Imported struct {
	ImportedBase
	// contains filtered or unexported fields
}

func NewImported

func NewImported(importName string, data ImportedBase) *Imported

func (*Imported) GetImportName

func (imp *Imported) GetImportName() string

GetImportName returns the name under which the import was imported.

func (*Imported) GetImportPath

func (imp *Imported) GetImportPath() *field.Path

GetImportPath returns the field path for the import. This is helpful for providing better error messages.

func (*Imported) GetImportReferences

func (imp *Imported) GetImportReferences() map[string]string

GetImportReferences is the list-type import implementation for GetImportReference() It returns a mapping from in-cluster object names to import references.

func (*Imported) GetOwnerReference

func (imp *Imported) GetOwnerReference() *metav1.OwnerReference

GetOwnerReference returns the owner reference. This is only meant for single-type imports, for list-type imports use GetOwnerReferences() instead.

func (*Imported) GetOwnerReferences

func (imp *Imported) GetOwnerReferences() map[string]*metav1.OwnerReference

GetOwnerReferences is the list-type import variant of GetOwnerReference. It returns a mapping from in-cluster object names to owner references. The result should contain one entry per item in the imported list.

type ImportedBase

type ImportedBase interface {
	GetImportType() lsv1alpha1.ImportType
	// IsListTypeImport returns true if the import refers (or could refer) to multiple in-cluster objects.
	// List imports with zero or only one element are still considered list-type imports.
	// There are several methods which work for only either single-type or list-type imports, use this method to find out which ones to use.
	IsListTypeImport() bool
	// GetInClusterObject returns the in-cluster object referenced by this import
	GetInClusterObject() client.Object
	// GetInClusterObjects is the same as GetInClusterObject, but for list-type imports
	GetInClusterObjects() []client.Object
	// ComputeConfigGeneration computes the config generation for the import to compare it to the one stored in the import status
	GetListItems() []ImportedBase
	// GetImportReference returns the (non-hashed) name under which the imported object was exported. It is implemented for single-type imports only.
	GetImportReference() string
	// GetImportDefinition returns the import definition which caused this import.
	// Unfortunately, there is no common interface for import definitions, so it can only return interface{}.
	GetImportDefinition() interface{}
}

This is the attempt to create a common interface for all imports to not always have big switch-case-statements when working with them. Unfortunately, the different imports behave quite differently, most notable are the differences between imports referring to a single object (single-type imports) and imports referring to multiple objects (list-type imports), which is why there are multiple methods which are only implemented for either type and calling them on a 'wrong' import will return a dummy value.

type Metadata

type Metadata struct {
	Namespace    string
	Context      string
	SourceType   lsv1alpha1.DataObjectSourceType
	Source       string
	Key          string
	Hash         string
	Index        *int
	TargetMapKey *string
	JobID        string
}

Metadata describes the metadata of a data object. This metadata is also represented as annotations/labels at the object.

func GetMetadataFromObject

func GetMetadataFromObject(objAcc metav1.Object, data []byte) Metadata

GetMetadataFromObject read optional metadata from object's labels and annotations

type TargetExtension

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

TargetExtension is the internal representation of a target.

func NewTargetExtension

func NewTargetExtension(target *lsv1alpha1.Target, targetImport *lsv1alpha1.TargetImport) *TargetExtension

NewTargetExtension creates a new internal target instance from a raw target.

func (*TargetExtension) Apply

func (t *TargetExtension) Apply(target *lsv1alpha1.Target) error

Apply applies data and metadata to an existing target (except owner references).

func (*TargetExtension) ApplyNameAndNamespace

func (t *TargetExtension) ApplyNameAndNamespace(target *lsv1alpha1.Target)

ApplyNameAndNamespace sets name and namespace based on the given metadata.

func (*TargetExtension) ComputeConfigGeneration

func (t *TargetExtension) ComputeConfigGeneration() string

func (*TargetExtension) GetData

func (t *TargetExtension) GetData() (interface{}, error)

GetData returns the target as internal go map.

func (*TargetExtension) GetImportDefinition

func (t *TargetExtension) GetImportDefinition() interface{}

func (*TargetExtension) GetImportReference

func (t *TargetExtension) GetImportReference() string

func (*TargetExtension) GetImportType

func (t *TargetExtension) GetImportType() lsv1alpha1.ImportType

func (*TargetExtension) GetInClusterObject

func (t *TargetExtension) GetInClusterObject() client.Object

func (*TargetExtension) GetInClusterObjects

func (t *TargetExtension) GetInClusterObjects() []client.Object

func (*TargetExtension) GetListItems

func (t *TargetExtension) GetListItems() []ImportedBase

func (*TargetExtension) GetMetadata

func (t *TargetExtension) GetMetadata() Metadata

func (*TargetExtension) GetTarget

func (t *TargetExtension) GetTarget() *lsv1alpha1.Target

func (*TargetExtension) IsListTypeImport

func (t *TargetExtension) IsListTypeImport() bool

func (*TargetExtension) SetContext

func (t *TargetExtension) SetContext(ctx string) *TargetExtension

SetContext sets the installation context for the given data object.

func (*TargetExtension) SetIndex

func (t *TargetExtension) SetIndex(idx *int) *TargetExtension

SetIndex sets the index (for list-type objects)

func (*TargetExtension) SetJobID

func (t *TargetExtension) SetJobID(jobID string) *TargetExtension

func (*TargetExtension) SetKey

func (t *TargetExtension) SetKey(key string) *TargetExtension

SetKey sets the key for the given data object.

func (*TargetExtension) SetMetadata

func (t *TargetExtension) SetMetadata(metadata Metadata)

func (*TargetExtension) SetNamespace

func (t *TargetExtension) SetNamespace(ns string) *TargetExtension

SetNamespace sets the namespace for the given data object.

func (*TargetExtension) SetSource

func (t *TargetExtension) SetSource(src string) *TargetExtension

SetSource sets the source for the given data object.

func (*TargetExtension) SetSourceType

SetSourceType sets the context for the given data object.

func (*TargetExtension) SetTarget

func (t *TargetExtension) SetTarget(target *lsv1alpha1.Target)

func (*TargetExtension) SetTargetMapKey

func (t *TargetExtension) SetTargetMapKey(targetMapKey *string) *TargetExtension

type TargetExtensionList

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

TargetExtensionList is the internal representation of a list of targets.

func NewTargetExtensionList

func NewTargetExtensionList(targets []lsv1alpha1.Target, def *lsv1alpha1.TargetImport) *TargetExtensionList

NewTargetExtensionList creates a new internal targetlist instance from a list of raw targets.

func (TargetExtensionList) Apply

func (tl TargetExtensionList) Apply(raw *lsv1alpha1.Target, index int) error

Apply applies data and metadata to a existing target (except owner references).

func (TargetExtensionList) Build

func (tl TargetExtensionList) Build(tlName string) ([]*lsv1alpha1.Target, error)

Build creates a new data object based on the given data and metadata. Does not set owner references.

func (*TargetExtensionList) ComputeConfigGeneration

func (tl *TargetExtensionList) ComputeConfigGeneration() string

func (*TargetExtensionList) GetData

func (t *TargetExtensionList) GetData() ([]interface{}, error)

GetData returns the targets as list of internal go maps.

func (*TargetExtensionList) GetImportDefinition

func (tl *TargetExtensionList) GetImportDefinition() interface{}

func (*TargetExtensionList) GetImportReference

func (tl *TargetExtensionList) GetImportReference() string

func (*TargetExtensionList) GetImportType

func (tl *TargetExtensionList) GetImportType() lsv1alpha1.ImportType

func (*TargetExtensionList) GetInClusterObject

func (tl *TargetExtensionList) GetInClusterObject() client.Object

func (*TargetExtensionList) GetInClusterObjects

func (tl *TargetExtensionList) GetInClusterObjects() []client.Object

func (*TargetExtensionList) GetListItems

func (tl *TargetExtensionList) GetListItems() []ImportedBase

func (*TargetExtensionList) GetTargetExtensions

func (tl *TargetExtensionList) GetTargetExtensions() []*TargetExtension

func (*TargetExtensionList) IsListTypeImport

func (tl *TargetExtensionList) IsListTypeImport() bool

func (*TargetExtensionList) SetAllSourceType

SetAllSourceType sets the source type for all targets in the list.

type TargetMapExtension

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

func NewTargetMapExtension

func NewTargetMapExtension(targetMap map[string]lsv1alpha1.Target, def *lsv1alpha1.TargetImport) *TargetMapExtension

func NewTargetMapExtensionFromList

func NewTargetMapExtensionFromList(targets *lsv1alpha1.TargetList, def *lsv1alpha1.TargetImport) (*TargetMapExtension, error)

func (*TargetMapExtension) Apply

func (m *TargetMapExtension) Apply(raw *lsv1alpha1.Target, targetMapKey string) error

Apply applies data and metadata to an existing target (except owner references).

func (*TargetMapExtension) Build

func (m *TargetMapExtension) Build(_ string) (map[string]*lsv1alpha1.Target, error)

func (*TargetMapExtension) ComputeConfigGeneration

func (m *TargetMapExtension) ComputeConfigGeneration() string

func (*TargetMapExtension) GetData

func (m *TargetMapExtension) GetData() (map[string]interface{}, error)

GetData returns the targets as map[string]interface{}.

func (*TargetMapExtension) GetImportDefinition

func (m *TargetMapExtension) GetImportDefinition() interface{}

func (*TargetMapExtension) GetImportReference

func (m *TargetMapExtension) GetImportReference() string

func (*TargetMapExtension) GetImportType

func (m *TargetMapExtension) GetImportType() lsv1alpha1.ImportType

func (*TargetMapExtension) GetInClusterObject

func (m *TargetMapExtension) GetInClusterObject() client.Object

func (*TargetMapExtension) GetInClusterObjects

func (m *TargetMapExtension) GetInClusterObjects() []client.Object

func (*TargetMapExtension) GetListItems

func (m *TargetMapExtension) GetListItems() []ImportedBase

func (*TargetMapExtension) GetTargetExtensions

func (m *TargetMapExtension) GetTargetExtensions() map[string]*TargetExtension

func (*TargetMapExtension) IsListTypeImport

func (m *TargetMapExtension) IsListTypeImport() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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