Documentation
¶
Index ¶
- Constants
- func CompareVersions(a string, b string) int
- func DesiredMetadataEqual(existing apiextensions.CustomResourceDefinition, ...) bool
- func FilterKnownTypesByReadyCRDs(logger logr.Logger, scheme *runtime.Scheme, ...) ([]*registration.KnownType, error)
- func FilterStorageTypesByReadyCRDs(logger logr.Logger, scheme *runtime.Scheme, ...) ([]*registration.StorageType, error)
- func GetAllDeprecatedStorageVersions(crds map[string]apiextensions.CustomResourceDefinition) map[string][]string
- func GetDeprecatedStorageVersions(crd apiextensions.CustomResourceDefinition) ([]string, []string)
- func IsReservedLabel(key string) bool
- func MakeCRDMap(crds []apiextensions.CustomResourceDefinition) map[string]apiextensions.CustomResourceDefinition
- func VersionEqual(a apiextensions.CustomResourceDefinition, ...) bool
- type CRDComparator
- type CRDComparisonResult
- type CRDInstallationInstruction
- type DiffResult
- type FilterResult
- type LeaderElector
- type Manager
- func (m *Manager) BuildCRDFileFilter(patterns string, existingCRDs []apiextensions.CustomResourceDefinition) func(filename string) (bool, error)
- func (m *Manager) CompareCRDs(existing []apiextensions.CustomResourceDefinition, ...) map[string][]CRDComparisonResult
- func (m *Manager) DetermineCRDsToInstallOrUpgrade(goalCRDs []apiextensions.CustomResourceDefinition, ...) ([]*CRDInstallationInstruction, error)
- func (m *Manager) Install(ctx context.Context, options Options) error
- func (m *Manager) ListCRDs(ctx context.Context, list *apiextensions.CustomResourceDefinitionList) error
- func (m *Manager) LoadOperatorCRDs(path string, podNamespace string, ...) ([]apiextensions.CustomResourceDefinition, error)
- type Options
Constants ¶
const ( NoDifference = DiffResult("NoDifference") VersionDifferent = DiffResult("VersionDifferent") MetadataDifferent = DiffResult("MetadataDifferent") )
const ( MatchedExistingCRD = FilterResult("MatchedExistingCRD") MatchedPattern = FilterResult("MatchedPattern") Excluded = FilterResult("Excluded") )
const CRDFilePrefix = "apiextensions.k8s.io_v1_customresourcedefinition_"
const CRDLocation = "crds"
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶ added in v2.17.0
CompareVersions compares two group version strings, for example: v1api20230101preview, v1api20220101, v20220101, v1api20220101storage, and v20220101storage and returns -1 if a < b, 0 if a == b, and 1 if a > b. The storage suffix is ignored in the comparison. Preview versions are considered less than non-preview versions.
func DesiredMetadataEqual ¶ added in v2.21.0
func DesiredMetadataEqual(existing apiextensions.CustomResourceDefinition, desired apiextensions.CustomResourceDefinition) bool
DesiredMetadataEqual returns true when all labels and annotations specified by the desired CRD are present on the existing CRD. Additional metadata on the existing CRD is intentionally ignored and preserved during updates.
func FilterKnownTypesByReadyCRDs ¶
func FilterKnownTypesByReadyCRDs( logger logr.Logger, scheme *runtime.Scheme, include map[string]apiextensions.CustomResourceDefinition, knownTypes []*registration.KnownType, ) ([]*registration.KnownType, error)
func FilterStorageTypesByReadyCRDs ¶
func FilterStorageTypesByReadyCRDs( logger logr.Logger, scheme *runtime.Scheme, include map[string]apiextensions.CustomResourceDefinition, storageTypes []*registration.StorageType, ) ([]*registration.StorageType, error)
func GetAllDeprecatedStorageVersions ¶ added in v2.15.0
func GetAllDeprecatedStorageVersions(crds map[string]apiextensions.CustomResourceDefinition) map[string][]string
GetDeprecatedStorageVersions returns a map of CRD names to their deprecated storage versions.
func GetDeprecatedStorageVersions ¶ added in v2.15.0
func GetDeprecatedStorageVersions(crd apiextensions.CustomResourceDefinition) ([]string, []string)
GetDeprecatedStorageVersions returns a new list of storedVersions by removing the deprecated versions The first return value is the list of versions that are NOT deprecated. The second return value is the list of versions that ARE deprecated.
func IsReservedLabel ¶ added in v2.21.0
IsReservedLabel returns true if the given label key is reserved for ASO's own use and so may not be set by the user. Overwriting these labels would break CRD discovery (ListCRDs matches on ServiceOperatorAppLabel) or CRD upgrade detection (VersionEqual compares ServiceOperatorVersionLabel). Surrounding whitespace is ignored so that the result doesn't depend on the caller having trimmed the key.
func MakeCRDMap ¶ added in v2.9.0
func MakeCRDMap( crds []apiextensions.CustomResourceDefinition, ) map[string]apiextensions.CustomResourceDefinition
func VersionEqual ¶
func VersionEqual(a apiextensions.CustomResourceDefinition, b apiextensions.CustomResourceDefinition) bool
Types ¶
type CRDComparator ¶ added in v2.21.0
type CRDComparator struct {
Compare func(a apiextensions.CustomResourceDefinition, b apiextensions.CustomResourceDefinition) bool
DifferenceReason DiffResult
}
CRDComparator associates a CRD comparison with the result to report when the comparison fails.
type CRDComparisonResult ¶ added in v2.21.0
type CRDComparisonResult struct {
DifferenceResult DiffResult
}
CRDComparisonResult records the result of applying a comparator to a CRD.
type CRDInstallationInstruction ¶ added in v2.1.0
type CRDInstallationInstruction struct {
CRD apiextensions.CustomResourceDefinition
// FilterResult contains the result of if the CRD was considered for installation or not
FilterResult FilterResult
// FilterReason contains a user-facing reason for why the CRD was or was not considered for installation
FilterReason string
// DiffResult contains the result of the diff between the existing CRD (if any) and the goal CRD. This may
// be NoDifference if the CRD was filtered from consideration before the diff phase.
DiffResult DiffResult
}
func IncludedCRDs ¶ added in v2.1.0
func IncludedCRDs(instructions []*CRDInstallationInstruction) []*CRDInstallationInstruction
func (*CRDInstallationInstruction) ShouldApply ¶ added in v2.1.0
func (i *CRDInstallationInstruction) ShouldApply() (bool, string)
type DiffResult ¶ added in v2.1.0
type DiffResult string
func (DiffResult) DiffReason ¶ added in v2.1.0
func (i DiffResult) DiffReason(crd apiextensions.CustomResourceDefinition) string
type FilterResult ¶ added in v2.1.0
type FilterResult string
type LeaderElector ¶ added in v2.12.0
type LeaderElector struct {
Elector *leaderelection.LeaderElector
LeaseAcquired *sync.WaitGroup
LeaseReleased *sync.WaitGroup
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(logger logr.Logger, kubeClient kubeclient.Client, leaderElection *LeaderElector) *Manager
NewManager creates a new CRD manager. The leaderElection argument is optional, but strongly recommended.
func (*Manager) BuildCRDFileFilter ¶ added in v2.19.0
func (m *Manager) BuildCRDFileFilter(patterns string, existingCRDs []apiextensions.CustomResourceDefinition) func(filename string) (bool, error)
BuildCRDFileFilter returns a predicate that determines whether a CRD file should be loaded based on patterns and existing CRDs. This allows skipping files that can't possibly be needed, avoiding the cost of reading and unmarshalling them.
A file should be loaded if:
- Its derived CRD name matches an existing CRD in the cluster (needed for upgrades), OR
- Its group (from the filename) could match one of the specified patterns
If there are no patterns and no existing CRDs, no files are loaded.
func (*Manager) CompareCRDs ¶ added in v2.21.0
func (m *Manager) CompareCRDs( existing []apiextensions.CustomResourceDefinition, goal []apiextensions.CustomResourceDefinition, comparators ...CRDComparator, ) map[string][]CRDComparisonResult
CompareCRDs compares each CRD in "goal" with the corresponding CRD in "existing". Every comparator is evaluated in a single pass through the goal CRDs, and results are returned in comparator order, allowing callers to define their precedence. If a goal CRD is not found in existing, comparators receive a default initialized CRD.
func (*Manager) DetermineCRDsToInstallOrUpgrade ¶ added in v2.1.0
func (m *Manager) DetermineCRDsToInstallOrUpgrade( goalCRDs []apiextensions.CustomResourceDefinition, existingCRDs []apiextensions.CustomResourceDefinition, patterns string, ) ([]*CRDInstallationInstruction, error)
DetermineCRDsToInstallOrUpgrade examines the set of goal CRDs and installed CRDs to determine the set which should be installed or upgraded.
func (*Manager) ListCRDs ¶ added in v2.12.0
func (m *Manager) ListCRDs(ctx context.Context, list *apiextensions.CustomResourceDefinitionList) error
ListCRDs lists ASO CRDs. This accepts a list rather than returning one to allow re-using the same list object (they're large and having multiple) copies of the collection results in huge memory usage. NOTE: This function also clears Versions[i].Schema.OpenAPIV3Schema for every CRD, as these are large and we don't use them for any of our comparisons DO NOT use this function to inspect the schema.
func (*Manager) LoadOperatorCRDs ¶
func (m *Manager) LoadOperatorCRDs( path string, podNamespace string, shouldLoad func(filename string) (bool, error), ) ([]apiextensions.CustomResourceDefinition, error)
type Options ¶ added in v2.12.0
type Options struct {
Path string
Namespace string
CRDPatterns string
CRDLabels map[string]string
ExistingCRDs *apiextensions.CustomResourceDefinitionList
}