Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePodAnnotations(req CapsuleRequest) map[string]string
- func EnvSources(refs []v1alpha2.EnvReference) []v1.EnvFromSource
- func FileToVolume(f v1alpha2.File) (v1.Volume, v1.VolumeMount)
- func FilesToVolumes(files []v1alpha2.File) ([]v1.Volume, []v1.VolumeMount)
- func IsOwnedBy(owner metav1.Object, obj metav1.Object) bool
- func ListConvert[T client.Object](objects []client.Object) ([]T, error)
- func ListExisting[T client.Object](r Request, obj T) ([]T, error)
- func ListNew[T client.Object](r Request, obj T) ([]T, error)
- func LookupGVK(gk schema.GroupKind) (schema.GroupVersionKind, error)
- func ObjectsEquals(o1, o2 client.Object) bool
- type CapsulePipeline
- func (p *CapsulePipeline) AddStep(step Step[CapsuleRequest])
- func (p *CapsulePipeline) DeleteCapsule(ctx context.Context, capsule *v1alpha2.Capsule, client client.Client, ...) (*Result, error)
- func (p *CapsulePipeline) RunCapsule(ctx context.Context, capsule *v1alpha2.Capsule, client client.Client, ...) (*Result, error)
- func (p *CapsulePipeline) Steps() []Step[CapsuleRequest]
- type CapsuleRequest
- type CapsuleRequestOption
- type Change
- type ExecutableRequest
- type Object
- type ObjectKey
- type ObjectStatusCallback
- type ObjectsEqual
- type OutputObject
- type ProjectEnvironmentRequest
- type Request
- type RequestBase
- func (r *RequestBase) Commit(ctx context.Context) (map[ObjectKey]*Change, error)
- func (r *RequestBase) Delete(obj client.Object) error
- func (r *RequestBase) GetExisting(obj client.Object) error
- func (r *RequestBase) GetNew(obj client.Object) error
- func (r *RequestBase) ListExisting(obj client.Object) ([]client.Object, error)
- func (r *RequestBase) ListNew(obj client.Object) ([]client.Object, error)
- func (r *RequestBase) PrepareRequest() *Result
- func (r *RequestBase) Reader() client.Reader
- func (r *RequestBase) Scheme() *runtime.Scheme
- func (r *RequestBase) Set(obj client.Object) error
- type RequestDeps
- type RequestState
- type RequestStrategies
- type ResourceState
- type Result
- type Step
Constants ¶
View Source
const ( LabelOwnedByCapsule = "rig.dev/owned-by-capsule" AnnotationOverrideOwnership = "rig.dev/override-ownership" AnnotationPullSecret = "rig.dev/pull-secret" LabelCapsule = "rig.dev/capsule" LabelCron = "batch.kubernets.io/cronjob" RigDevRolloutLabel = "rig.dev/rollout" AnnotationChecksumFiles = "rig.dev/config-checksum-files" AnnotationChecksumAutoEnv = "rig.dev/config-checksum-auto-env" AnnotationChecksumEnv = "rig.dev/config-checksum-env" )
View Source
const (
LabelOwnedByProject = "rig.dev/owned-by-project"
)
Variables ¶
View Source
var ( AppsDeploymentGVK = appsv1.SchemeGroupVersion.WithKind("Deployment") CoreServiceGVK = corev1.SchemeGroupVersion.WithKind("Service") CoreNamespace = corev1.SchemeGroupVersion.WithKind("Namespace") 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 CreatePodAnnotations ¶
func CreatePodAnnotations(req CapsuleRequest) map[string]string
func EnvSources ¶
func EnvSources(refs []v1alpha2.EnvReference) []v1.EnvFromSource
func FileToVolume ¶
func FilesToVolumes ¶
func ObjectsEquals ¶
Types ¶
type CapsulePipeline ¶
type CapsulePipeline struct {
// contains filtered or unexported fields
}
func NewCapsulePipeline ¶
func NewCapsulePipeline( config *configv1alpha1.OperatorConfig, scheme *runtime.Scheme, logger logr.Logger, ) *CapsulePipeline
func (*CapsulePipeline) AddStep ¶
func (p *CapsulePipeline) AddStep(step Step[CapsuleRequest])
func (*CapsulePipeline) DeleteCapsule ¶
func (p *CapsulePipeline) DeleteCapsule( ctx context.Context, capsule *v1alpha2.Capsule, client client.Client, opts ...CapsuleRequestOption, ) (*Result, error)
func (*CapsulePipeline) RunCapsule ¶
func (p *CapsulePipeline) RunCapsule( ctx context.Context, capsule *v1alpha2.Capsule, client client.Client, opts ...CapsuleRequestOption, ) (*Result, error)
func (*CapsulePipeline) Steps ¶
func (p *CapsulePipeline) Steps() []Step[CapsuleRequest]
type CapsuleRequest ¶
type CapsuleRequest interface { Request // Capsule returns a deepcopy of the capsule object being reconciled. Capsule() *v1alpha2.Capsule // 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 *CapsulePipeline, capsule *v1alpha2.Capsule, client client.Client, opts ...CapsuleRequestOption, ) CapsuleRequest
type CapsuleRequestOption ¶
type CapsuleRequestOption interface {
// contains filtered or unexported methods
}
func WithAdditionalResources ¶
func WithAdditionalResources(resources []*pipeline.Object) CapsuleRequestOption
func WithDryRun ¶
func WithDryRun() CapsuleRequestOption
func WithForce ¶
func WithForce() CapsuleRequestOption
type ExecutableRequest ¶
type ExecutableRequest[T Request] interface { GetRequest() T GetBase() *RequestBase }
TODO This ExecuteableRequest type construction is a bit messy Find a better abstraction
func NewProjectEnvironmentRequest ¶
func NewProjectEnvironmentRequest( c client.Client, reader client.Reader, config *configv1alpha1.OperatorConfig, scheme *runtime.Scheme, logger logr.Logger, projectEnv *v1alpha2.ProjectEnvironment, ) ExecutableRequest[ProjectEnvironmentRequest]
type ObjectKey ¶
type ObjectKey struct { client.ObjectKey schema.GroupVersionKind }
func (ObjectKey) MarshalLog ¶
func (ok ObjectKey) MarshalLog() interface{}
type ObjectStatusCallback ¶
type ObjectsEqual ¶
type OutputObject ¶
type OutputObject struct { ObjectKey ObjectKey Object client.Object State ResourceState }
type ProjectEnvironmentRequest ¶
type ProjectEnvironmentRequest interface { Request // ProjectEnvironment returns a deepcopy of the capsule object being reconciled. ProjectEnvironment() *v1alpha2.ProjectEnvironment }
type Request ¶
type Request 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 // 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 of the reconcilliation. // If the name of 'obj' isn't set, it defaults to the Capsule name. Delete(obj client.Object) error // ListExisting returns a list with a copy of the objects of the corresponding type owned by the capsule and currently present in the cluster. // If you want a slice of typed objects, use the generic free-standing ListExisting function. ListExisting(obj client.Object) ([]client.Object, error) // ListNew returns a list with a copy of the objects of the corresponding type owned by the capsule and about to be applied. // If you want a slice of typed objects, use the generic free-standing ListNew function. ListNew(obj client.Object) ([]client.Object, error) }
type RequestBase ¶
type RequestBase struct { RequestDeps RequestState Strategies RequestStrategies }
func NewRequestBase ¶
func NewRequestBase( c client.Client, reader client.Reader, config *configv1alpha1.OperatorConfig, scheme *runtime.Scheme, logger logr.Logger, strategies RequestStrategies, object client.Object, ) RequestBase
func (*RequestBase) GetExisting ¶
func (r *RequestBase) GetExisting(obj client.Object) error
func (*RequestBase) ListExisting ¶
func (*RequestBase) PrepareRequest ¶
func (r *RequestBase) PrepareRequest() *Result
func (*RequestBase) Reader ¶
func (r *RequestBase) Reader() client.Reader
func (*RequestBase) Scheme ¶
func (r *RequestBase) Scheme() *runtime.Scheme
type RequestDeps ¶
type RequestDeps struct {
// contains filtered or unexported fields
}
type RequestState ¶
type RequestState struct {
// contains filtered or unexported fields
}
TODO Make generic over object?
type RequestStrategies ¶
type RequestStrategies interface { // Status updating strategies UpdateStatusWithChanges(ctx context.Context, changes map[ObjectKey]*Change, generation int64) error UpdateStatusWithError(ctx context.Context, err error) error // Execution loop strategies LoadExistingObjects(ctx context.Context) error Prepare() OwnedLabel() string GetKey(obj client.Object) (ObjectKey, 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 }
func ExecuteRequest ¶
Click to show internal directories.
Click to hide internal directories.