types

package
v0.0.0-...-5e84c48 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier interface {
	Apply(deployInfo InstallInfo, objects *ManifestResources, namespace string) (bool, error)
}

type ApplierOptions

type ApplierOptions struct {
	Manifest string

	RESTConfig *rest.Config
	RESTMapper meta.RESTMapper
	Namespace  string
	Validate   bool
	ExtraArgs  []string
}

type BaseCustomObject

type BaseCustomObject interface {
	runtime.Object
	metav1.Object
}

type CacheManager

type CacheManager interface {
	// InvalidateForOwner invalidates all cache entries which are cached by an owner key.
	// Here all caches should be deleted where entries are unique by a parent resource.
	InvalidateForOwner(key client.ObjectKey)

	// InvalidateSelf invalidates all cache entries which are cached on resource level.
	// Here all cache entries should be deleted where entries are unique by a resource itself.
	InvalidateSelf(key client.ObjectKey)

	// GetRendererCache returns the cache stored under RendererCache.
	GetRendererCache() RendererCache
}

CacheManager contains ClusterInfoCache and RendererCache cached entries. It offers utility methods to access the underlying caches as well as invalidate entries.

type ChartFlags

type ChartFlags struct {
	// ConfigFlags support string, bool and int types as helm chart flags
	// check: https://github.com/helm/helm/blob/d7b4c38c42cb0b77f1bcebf9bb4ae7695a10da0b/pkg/action/install.go#L67
	ConfigFlags Flags

	// SetFlags are chart value overrides
	SetFlags Flags
}

ChartFlags define flag based configurations for helm chart processing.

type ChartInfo

type ChartInfo struct {
	ChartPath   string
	RepoName    string
	URL         string
	ChartName   string
	ReleaseName string
	Flags       ChartFlags
}

ChartInfo defines helm chart information.

type ClusterInfo

type ClusterInfo struct {
	Config *rest.Config
	Client client.Client
}

ClusterInfo describes client and config for a cluster.

func (ClusterInfo) IsEmpty

func (r ClusterInfo) IsEmpty() bool

IsEmpty indicates if ClusterInfo is empty.

type ClusterInfoCache

type ClusterInfoCache interface {
	// Get returns the cluster information cached entry by the key passed.
	Get(key client.ObjectKey) ClusterInfo

	// Set sets the cluster information cached entry by the key passed.
	Set(key client.ObjectKey, info ClusterInfo)

	// Delete deletes the cluster information cached entry by the key passed.
	Delete(key client.ObjectKey)
}

ClusterInfoCache offers utility methods to access ClusterInfo cached instances.

type Codec

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

+kubebuilder:object:generate=false

func NewCodec

func NewCodec() (*Codec, error)

func (*Codec) Decode

func (c *Codec) Decode(data []byte, obj interface{}, refType RefTypeMetadata) error

func (*Codec) Validate

func (c *Codec) Validate(data []byte, refType RefTypeMetadata) error

type CustomObject

type CustomObject interface {
	runtime.Object
	metav1.Object
	ComponentName() string
	GetStatus() Status
	SetStatus(Status)
}

type Flags

type Flags map[string]interface{}

Flags define a set of configurable flags.

type HelmChartSpec

type HelmChartSpec struct {
	// URL defines the helm repo URL
	// +kubebuilder:validation:Optional
	URL string `json:"url"`

	// ChartName defines the helm chart name
	// +kubebuilder:validation:Optional
	ChartName string `json:"chartName"`

	// Type defines the chart as "helm-chart"
	// +kubebuilder:validation:Optional
	Type RefTypeMetadata `json:"type"`
}

HelmChartSpec defines the specification for a helm chart.

type HelmOperation

type HelmOperation OperationType
const (
	OperationCreate HelmOperation = "create"
	OperationDelete HelmOperation = "delete"
)

type ImageSpec

type ImageSpec struct {
	// Repo defines the Image repo
	// +kubebuilder:validation:Optional
	Repo string `json:"repo"`

	// Name defines the Image name
	// +kubebuilder:validation:Optional
	Name string `json:"name"`

	// Ref is either a sha value, tag or version
	// +kubebuilder:validation:Optional
	Ref string `json:"ref"`

	// Type defines the chart as "oci-ref"
	// +kubebuilder:validation:Optional
	Type RefTypeMetadata `json:"type"`
}

ImageSpec defines OCI Image specifications.

type InstallInfo

type InstallInfo struct {
	// ChartInfo represents chart information to be processed
	*ChartInfo
	// ResourceInfo represents additional resources to be processed
	ResourceInfo
	// ClusterInfo represents target cluster information
	ClusterInfo
	// Ctx hold the current context
	Ctx context.Context //nolint:containedctx
	// CheckFn returns a boolean indicating ready state based on custom checks
	CheckFn CheckFnType
	// CheckReadyStates indicates if native resources should be checked for ready states
	CheckReadyStates bool
	// UpdateRepositories indicates if repositories should be updated
	UpdateRepositories bool
}

InstallInfo represents deployment information artifacts to be processed.

type InstallationSpec

type InstallationSpec struct {
	ChartPath   string
	ReleaseName string
	ChartFlags
}

type KustomizeSpec

type KustomizeSpec struct {
	// Path defines the Kustomize local path
	Path string `json:"path"`

	// URL defines the Kustomize remote URL
	URL string `json:"url"`

	// Type defines the chart as "kustomize"
	// +kubebuilder:validation:Optional
	Type RefTypeMetadata `json:"type"`
}

KustomizeSpec defines the specification for a Kustomize specification.

type LabelNotFoundError

type LabelNotFoundError struct {
	Resource  client.Object
	LabelName string
}

func (*LabelNotFoundError) Error

func (m *LabelNotFoundError) Error() string

type ManifestClient

type ManifestClient interface {
	// GetRawManifest returns processed resource manifest using the client.
	GetRawManifest(deployInfo InstallInfo) *ParsedFile

	// Install transforms and applies resources based on InstallInfo.
	Install(manifest string, deployInfo InstallInfo, transforms []ObjectTransform) (bool, error)

	// Uninstall transforms and applies resources based on InstallInfo.
	Uninstall(manifest string, deployInfo InstallInfo, transforms []ObjectTransform) (bool, error)

	// IsConsistent transforms and checks if resources are consistently installed based on InstallInfo.
	IsConsistent(manifest string, deployInfo InstallInfo, transforms []ObjectTransform) (bool, error)

	// GetCachedResources returns a resource manifest which was already cached during previous operations.
	// By default, it looks inside <chart-path>/manifest/manifest.yaml
	GetCachedResources(chartName, chartPath string) *ParsedFile

	// DeleteCachedResources deletes cached resource manifest.
	// By default, it deletes <chart-path>/manifest/manifest.yaml.
	DeleteCachedResources(chartPath string) *ParsedFile

	// GetManifestResources returns a pre-rendered resource manifest file located at the passed chartPath.
	// If multiple YAML files are present at the dirPath, it cannot resolve the file to be used, hence will not process.
	GetManifestResources(dirPath string) *ParsedFile

	// InvalidateConfigAndRenderedManifest compares the cached hash with the processed hash for helm flags.
	// On mismatch, it invalidates the cached manifest and resets flags on client.
	InvalidateConfigAndRenderedManifest(deployInfo InstallInfo, cachedHash uint32) (uint32, error)

	// GetClusterInfo returns Client and REST config for the target cluster
	GetClusterInfo() (ClusterInfo, error)
}

ManifestClient offers client utility methods for processing of manifest resources.

type ManifestResolver

type ManifestResolver interface {
	// Get returns chart information to be processed, based on the passed CR.
	Get(object BaseCustomObject, logger logr.Logger) (InstallationSpec, error)
}

ManifestResolver represents local chart processing information.

type ManifestResources

type ManifestResources struct {
	Items []*unstructured.Unstructured
	Blobs [][]byte
}

ManifestResources holds a collection of objects, so that we can filter / sequence them.

type MultiError

type MultiError struct {
	Errs []error
}

func NewMultiError

func NewMultiError(errs []error) *MultiError

func (MultiError) Error

func (m MultiError) Error() string

type ObjectTransform

type ObjectTransform = func(context.Context, BaseCustomObject, *ManifestResources) error

ObjectTransform is an operation that transforms the manifest objects before applying it.

type OperationType

type OperationType string

type ParsedFile

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

ParsedFile contains the parsed content and any error encountered during processing of a file.

func NewParsedFile

func NewParsedFile(content string, err error) *ParsedFile

func (*ParsedFile) Error

func (fe *ParsedFile) Error() string

Error returns the error message during parsing of the file.

func (*ParsedFile) FilterOsErrors

func (fe *ParsedFile) FilterOsErrors() *ParsedFile

FilterOsErrors filters out os.IsPermission and os.IsNotExist errors.

func (*ParsedFile) GetContent

func (fe *ParsedFile) GetContent() string

GetContent returns the raw content of the parsed file.

func (*ParsedFile) GetRawError

func (fe *ParsedFile) GetRawError() error

GetRawError returns the raw error during parsing of the file.

func (*ParsedFile) IsResultConclusive

func (fe *ParsedFile) IsResultConclusive() bool

IsResultConclusive indicates if caching results are processed.

type RefTypeMetadata

type RefTypeMetadata string

RefTypeMetadata specifies the type of installation specification that could be provided as part of a custom resource. This time is used in codec to successfully decode from raw extensions. +kubebuilder:validation:Enum=helm-chart;oci-ref;"kustomize";""

const (
	HelmChartType RefTypeMetadata = "helm-chart"
	OciRefType    RefTypeMetadata = "oci-ref"
	KustomizeType RefTypeMetadata = "kustomize"
	NilRefType    RefTypeMetadata = ""
)

func GetSpecType

func GetSpecType(data []byte) (RefTypeMetadata, error)

func (RefTypeMetadata) NotEmpty

func (r RefTypeMetadata) NotEmpty() bool

type RendererCache

type RendererCache interface {
	// GetProcessor returns the manifest processor cached entry by key passed.
	GetProcessor(key client.ObjectKey) ManifestClient

	// SetProcessor sets the manifest processor cached entry by key passed.
	SetProcessor(key client.ObjectKey, renderSrc ManifestClient)

	// DeleteProcessor deletes the manifest processor cached entry by key passed.
	DeleteProcessor(key client.ObjectKey)

	// GetConfig returns the hashed configuration cached entry by key passed.
	GetConfig(key client.ObjectKey) uint32

	// SetConfig returns the hashed configuration cached entry by key passed.
	SetConfig(key client.ObjectKey, cfg uint32)

	// DeleteConfig deletes the hashed configuration cached entry by key passed.
	DeleteConfig(key client.ObjectKey)
}

RendererCache offers utility methods to access ManifestClient cached instances.

type ResourceInfo

type ResourceInfo struct {
	// BaseResource represents base custom resource that is being reconciled
	BaseResource *unstructured.Unstructured
	// CustomResources represents a set of additional custom resources to be installed
	CustomResources []*unstructured.Unstructured
	// Crds represents a set of additional custom resource definitions to be installed
	Crds []*v1.CustomResourceDefinition
}

ResourceInfo represents additional resources.

type ResourceLists

type ResourceLists struct {
	Target    kube.ResourceList
	Installed kube.ResourceList
	Namespace kube.ResourceList
}

func (*ResourceLists) GetResourcesToBeDeleted

func (r *ResourceLists) GetResourcesToBeDeleted() kube.ResourceList

func (*ResourceLists) GetWaitForResources

func (r *ResourceLists) GetWaitForResources() kube.ResourceList

type State

type State string
const (
	// StateReady signifies CustomObject is ready and has been installed successfully.
	StateReady State = "Ready"

	// StateProcessing signifies CustomObject is reconciling and is in the process of installation.
	// Processing can also signal that the Installation previously encountered an error and is now recovering.
	StateProcessing State = "Processing"

	// StateError signifies an error for CustomObject. This signifies that the Installation
	// process encountered an error.
	// Contrary to Processing, it can be expected that this state should change on the next retry.
	StateError State = "Error"

	// StateDeleting signifies CustomObject is being deleted. This is the state that is used
	// when a deletionTimestamp was detected and Finalizers are picked up.
	StateDeleting State = "Deleting"
)

Valid CustomObject States.

type Status

type Status struct {
	// State signifies current state of CustomObject.
	// Value can be one of ("Ready", "Processing", "Error", "Deleting").
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Enum=Processing;Deleting;Ready;Error
	State State `json:"state"`

	// Conditions associated with CustomStatus.
	Conditions []*metav1.Condition `json:"conditions,omitempty"`
}

Status defines the observed state of CustomObject.

func (*Status) DeepCopy

func (in *Status) DeepCopy() *Status

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Status.

func (*Status) DeepCopyInto

func (in *Status) DeepCopyInto(out *Status)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Status) WithState

func (s *Status) WithState(state State) Status

Jump to

Keyboard shortcuts

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