pipeline

package
v1.8.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelOwnedByCapsule = "rig.dev/owned-by-capsule"
)

Variables

View Source
var (
	AppsDeploymentGVK                      = appsv1.SchemeGroupVersion.WithKind("Deployment")
	CoreServiceGVK                         = corev1.SchemeGroupVersion.WithKind("Service")
	CMCertificateGVK                       = cmv1.SchemeGroupVersion.WithKind(cmv1.CertificateKind)
	NetIngressGVK                          = netv1.SchemeGroupVersion.WithKind("Ingress")
	AutoscalingvHorizontalPodAutoscalerGVK = autoscalingv2.SchemeGroupVersion.WithKind("HorizontalPodAutoscaler")
	BatchCronJobGVK                        = batchv1.SchemeGroupVersion.WithKind("CronJob")
	MonitoringServiceMonitorGVK            = monitorv1.SchemeGroupVersion.WithKind(monitorv1.ServiceMonitorsKind)
	VPAVerticalPodAutoscalerGVK            = vpav1.SchemeGroupVersion.WithKind("VerticalPodAutoscaler")
	CoreServiceAccount                     = corev1.SchemeGroupVersion.WithKind("ServiceAccount")
)

Functions

func IsOwnedBy

func IsOwnedBy(owner metav1.Object, obj metav1.Object) bool

func ObjectsEquals

func ObjectsEquals(o1, o2 client.Object) bool

Types

type CapsuleRequest

type CapsuleRequest interface {
	// Scheme returns the serialization scheme used by the rig operator.
	// It contains all the types used by a Capsule.
	Scheme() *runtime.Scheme
	// Reader is a Kubernetes reader with access to the cluster the rig operator is running in.
	Reader() client.Reader
	// Capsule returns a deepcopy of the capsule object being reconciled.
	Capsule() *v1alpha2.Capsule
	// GetExisting populates 'obj' with a copy of the corresponding object owned by the capsule currently present in the cluster.
	// If the name of 'obj' isn't set, it defaults to the Capsule name.
	GetExisting(obj client.Object) error
	// GetNew populates 'obj' with a copy of the corresponding object owned by the capsule about to be applied.
	// If the name of 'obj' isn't set, it defaults to the Capsule name.
	GetNew(obj client.Object) error
	// Set updates the object recorded to be applied.
	// If the name of 'obj' isn't set, it defaults to the Capsule name.
	Set(obj client.Object) error
	// Delete records the given object to be deleted.
	// The behaviour is such that that calling
	// req.Delete(obj) and then req.GetNew(obj)
	// returns a not-found error from GetNew.
	// If an object of the given type and name is present in the cluster, calling req.GetExisting(obj) succeds
	// as calls to Delete (or Set) will only be applied to the cluster at the very end.
	// If the name of 'obj' isn't set, it defaults to the Capsule name.
	Delete(obj client.Object) error
	// MarkUsedObject marks the object as used by the Capsule which will be present in the Capsule's Status
	MarkUsedObject(res v1alpha2.UsedResource) error
}

CapsuleRequest contains a single reconcile request for a given capsule. It contains both the set of existing kubernetes objects owned by the capsule and the set of objects recorded to be applied after all steps in the pipeline has been executed (called 'new' objects). The set of existing objects cannot be modified (as the interface does not allow for writing to Kubernetes) but there are both read and write access to the set of new objects.

func NewCapsuleRequest

func NewCapsuleRequest(p *Pipeline, capsule *v1alpha2.Capsule, opts ...CapsuleRequestOption) CapsuleRequest

type CapsuleRequestOption

type CapsuleRequestOption interface {
	// contains filtered or unexported methods
}

func WithAdditionalResources added in v1.7.4

func WithAdditionalResources(resources []*pipeline.Object) CapsuleRequestOption

func WithDryRun

func WithDryRun() CapsuleRequestOption

func WithForce

func WithForce() CapsuleRequestOption

type Object

type Object struct {
	Current      client.Object
	New          client.Object
	Materialized client.Object
}

type ObjectsEqual

type ObjectsEqual func(o1, o2 client.Object) bool

type OutputObject

type OutputObject struct {
	ObjectKey objectKey
	Object    client.Object
	State     ResourceState
}

type Pipeline

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

func New

func New(
	cc client.Client,
	cr client.Reader,
	config *configv1alpha1.OperatorConfig,
	scheme *runtime.Scheme,
	logger logr.Logger,
) *Pipeline

func (*Pipeline) AddStep

func (p *Pipeline) AddStep(step Step)

func (*Pipeline) RunCapsule

func (p *Pipeline) RunCapsule(
	ctx context.Context,
	capsule *v1alpha2.Capsule,
	opts ...CapsuleRequestOption,
) (*Result, error)

func (*Pipeline) RunSteps

func (p *Pipeline) RunSteps(ctx context.Context, capReq CapsuleRequest, commit bool) (*Result, error)

type ResourceState

type ResourceState string
const (
	ResourceStateDeleted       ResourceState = "deleted"
	ResourceStateUpdated       ResourceState = "updated"
	ResourceStateUnchanged     ResourceState = "unchanged"
	ResourceStateCreated       ResourceState = "created"
	ResourceStateFailed        ResourceState = "failed"
	ResourceStateAlreadyExists ResourceState = "alreadyExists"
	ResourceStateChangePending ResourceState = "changePending"
)

type Result

type Result struct {
	InputObjects  []client.Object
	OutputObjects []OutputObject
	Objects       []*Object
}

type Step

type Step interface {
	Apply(ctx context.Context, req CapsuleRequest) error
}

Jump to

Keyboard shortcuts

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