revisiongenerator

package
v0.0.0-...-637b28f Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AdoptExistingAnnotation controls whether collision protection is disabled
	// for a specific object, allowing us to adopt an object which already
	// exists on the cluster but is not managed by the CAPI operator.  Permitted
	// values are AdoptExistingAlways and AdoptExistingNever. The annotation is
	// stripped from the object before it is applied to the cluster, but is
	// included in the content hash so that adding or removing the annotation
	// triggers a new revision.
	AdoptExistingAnnotation = operatorstatus.CAPIOperatorIdentifierDomain + "/adopt-existing"

	// AdoptExistingAlways disables collision protection for the annotated
	// object. This allows us to adopt an object which was not created by the
	// CAPI operator.
	AdoptExistingAlways = "always"

	// AdoptExistingNever does not disable collision protection for the
	// annotated object. This is the default behavior and is equivalent to not
	// setting the annotation at all.
	AdoptExistingNever = "never"
)
View Source
const ManagedLabelKey = operatorstatus.CAPIOperatorIdentifierDomain + "/managed-by"

ManagedLabelKey is a label key used to identify objects managed by the CAPI operator.

Variables

View Source
var ErrInvalidAdoptExistingAnnotation = errors.New("invalid " + AdoptExistingAnnotation + " annotation value")

ErrInvalidAdoptExistingAnnotation is returned when an object has an adopt-existing annotation with an unrecognised value.

Functions

func RevisionsToApplyConfig

RevisionsToApplyConfig converts a slice of ClusterAPIInstallerRevision to their apply configuration representations via JSON round-trip. Both types share identical JSON tags (code-generated from the same schema), so this conversion is lossless and maintenance-free.

func ValidateAdoptExistingAnnotation

func ValidateAdoptExistingAnnotation(obj client.Object) error

ValidateAdoptExistingAnnotation returns an error if the object has an adopt-existing annotation with an unrecognised value.

func WithManifestSubstitutions

func WithManifestSubstitutions(subs map[string]string) revisionRenderOption

WithManifestSubstitutions adds envsubst-style substitutions that will be applied to manifests during rendering and recorded on the revision. When called multiple times, later values merge with and override earlier ones.

func WithObjectCollectors

func WithObjectCollectors(collectors ...RevisionObjectCollector) revisionRenderOption

WithObjectCollectors adds object collectors to the revision render config.

Types

type InstallerRevision

type InstallerRevision interface {
	RenderedRevision

	// RevisionName returns the name of this revision.
	RevisionName() operatorv1alpha1.RevisionName

	// RevisionIndex returns the revision index.
	RevisionIndex() int64

	// ToAPIRevision converts this revision to an API revision.
	ToAPIRevision() (operatorv1alpha1.ClusterAPIInstallerRevision, error)
}

InstallerRevision is a RenderedRevision that has been assigned a revision identity (name and index), making it ready for installation or conversion to an API revision.

func NewInstallerRevisionFromAPI

func NewInstallerRevisionFromAPI(
	apiRev operatorv1alpha1.ClusterAPIInstallerRevision,
	providerProfiles []providerimages.ProviderImageManifests,
	opts ...revisionRenderOption,
) (InstallerRevision, error)

NewInstallerRevisionFromAPI creates an InstallerRevision by matching the components in an API revision against the provided provider profiles and rendering the matched manifests. The revision name and index are taken directly from the API revision. Components are matched by Image.Ref and Image.Profile. An error is returned if any component cannot be found in the provided profiles, or if the rendered content ID does not match the content ID recorded in the API revision.

type RenderedComponent

type RenderedComponent interface {
	// Name returns the component name.
	Name() string
	// CRDs returns the CRD objects for this component.
	CRDs() []client.Object
	// Objects returns the non-CRD objects for this component.
	Objects() []client.Object
}

RenderedComponent represents a single provider component with manifests separated into CRDs and other objects.

type RenderedRevision

type RenderedRevision interface {
	// ContentID returns a unique identifier for the revision's content.
	ContentID() (string, error)

	// Components returns the rendered components for this revision.
	Components() []RenderedComponent

	// ForInstall creates an InstallerRevision by assigning a release version
	// and revision index to this rendered content.
	ForInstall(releaseVersion string, revisionIndex int64) (InstallerRevision, error)
}

RenderedRevision represents a set of components whose manifests have been fully rendered and are ready to be applied to a cluster.

func NewRenderedRevision

func NewRenderedRevision(profiles []providerimages.ProviderImageManifests, opts ...revisionRenderOption) (RenderedRevision, error)

NewRenderedRevision creates a new RenderedRevision from a list of provider image manifests.

type RevisionObjectCollector

type RevisionObjectCollector func(obj unstructured.Unstructured)

RevisionObjectCollector is a function that will be called for each object in the rendered revision.

Jump to

Keyboard shortcuts

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