@@ -18,53 +18,35 @@ package v1alpha1
1818
1919import (
2020 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21-
22- "github.com/operator-framework/operator-controller/internal/conditionsets"
2321)
2422
25- type UpgradeConstraintPolicy string
26-
27- const (
28- // The extension will only upgrade if the new version satisfies
29- // the upgrade constraints set by the package author.
30- UpgradeConstraintPolicyEnforce UpgradeConstraintPolicy = "Enforce"
31-
32- // Unsafe option which allows an extension to be
33- // upgraded or downgraded to any available version of the package and
34- // ignore the upgrade path designed by package authors.
35- // This assumes that users independently verify the outcome of the changes.
36- // Use with caution as this can lead to unknown and potentially
37- // disastrous results such as data loss.
38- UpgradeConstraintPolicyIgnore UpgradeConstraintPolicy = "Ignore"
39- )
23+ // +kubebuilder:validation:XValidation:rule="self.sourceType=='package' && has(self.__package__)",message="sourceType must match populated union field"
24+ //
25+ // ClusterExtensionSource defines the source for this ClusterExtension, right now, only a package is supported.
26+ type ClusterExtensionSource struct {
27+ //+kubebuilder:validation:Enum:=package
28+ //+kubebuilder:validation:Required
29+ // SourceType is the discriminator for the source type
30+ SourceType string `json:"sourceType"`
31+
32+ // Package defines a reference for a bundle in a catalog defined by a name and a version and/or channel
33+ Package * SourcePackage `json:"package,omitempty"`
34+ }
4035
4136// ClusterExtensionSpec defines the desired state of ClusterExtension
4237type ClusterExtensionSpec struct {
43- //+kubebuilder:validation:MaxLength:=48
44- //+kubebuilder:validation:Pattern:=^[a-z0-9]+(-[a-z0-9]+)*$
45- PackageName string `json:"packageName"`
46-
47- //+kubebuilder:validation:MaxLength:=64
48- //+kubebuilder:validation:Pattern=`^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$`
4938 //+kubebuilder:Optional
50- // Version is an optional semver constraint on the package version. If not specified, the latest version available of the package will be installed.
51- // If specified, the specific version of the package will be installed so long as it is available in any of the content sources available.
52- // Examples: 1.2.3, 1.0.0-alpha, 1.0.0-rc.1
5339 //
54- // For more information on semver, please see https://semver.org/
55- Version string `json:"version ,omitempty"`
40+ // paused controls the management state of the ClusterExtension. If paused, it will be ignored by the ClusterExtension controller.
41+ Paused bool `json:"paused ,omitempty"`
5642
57- //+kubebuilder:validation:MaxLength:=48
58- //+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
59- // Channel constraint definition
60- Channel string `json:"channel,omitempty"`
43+ // source of ClusterExtension to be installed
44+ Source ClusterExtensionSource `json:"source"`
6145
62- //+kubebuilder:validation:Enum:=Enforce;Ignore
63- //+kubebuilder:default:=Enforce
6446 //+kubebuilder:Optional
6547 //
66- // Defines the policy for how to handle upgrade constraints
67- UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy ,omitempty"`
48+ // skipCRDUpgradeSafetyCheck specifies whether the CRD upgrade safety checks should be skipped when attempting to install the ClusterExtension
49+ SkipCRDUpgradeSafetyCheck bool `json:"skipCRDUpgradeSafetyCheck ,omitempty"`
6850
6951 //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
7052 //+kubebuilder:validation:MaxLength:=63
@@ -75,54 +57,11 @@ type ClusterExtensionSpec struct {
7557 InstallNamespace string `json:"installNamespace"`
7658}
7759
78- const (
79- // TODO(user): add more Types, here and into init()
80- TypeInstalled = "Installed"
81- TypeResolved = "Resolved"
82- // TypeDeprecated is a rollup condition that is present when
83- // any of the deprecated conditions are present.
84- TypeDeprecated = "Deprecated"
85- TypePackageDeprecated = "PackageDeprecated"
86- TypeChannelDeprecated = "ChannelDeprecated"
87- TypeBundleDeprecated = "BundleDeprecated"
88-
89- ReasonBundleLookupFailed = "BundleLookupFailed"
90- ReasonInstallationFailed = "InstallationFailed"
91- ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
92- ReasonInstallationSucceeded = "InstallationSucceeded"
93- ReasonInvalidSpec = "InvalidSpec"
94- ReasonResolutionFailed = "ResolutionFailed"
95- ReasonResolutionUnknown = "ResolutionUnknown"
96- ReasonSuccess = "Success"
97- ReasonDeprecated = "Deprecated"
98- )
99-
100- func init () {
101- // TODO(user): add Types from above
102- conditionsets .ConditionTypes = append (conditionsets .ConditionTypes ,
103- TypeInstalled ,
104- TypeResolved ,
105- TypeDeprecated ,
106- TypePackageDeprecated ,
107- TypeChannelDeprecated ,
108- TypeBundleDeprecated ,
109- )
110- // TODO(user): add Reasons from above
111- conditionsets .ConditionReasons = append (conditionsets .ConditionReasons ,
112- ReasonInstallationSucceeded ,
113- ReasonResolutionFailed ,
114- ReasonResolutionUnknown ,
115- ReasonBundleLookupFailed ,
116- ReasonInstallationFailed ,
117- ReasonInstallationStatusUnknown ,
118- ReasonInvalidSpec ,
119- ReasonSuccess ,
120- ReasonDeprecated ,
121- )
122- }
123-
12460// ClusterExtensionStatus defines the observed state of ClusterExtension
12561type ClusterExtensionStatus struct {
62+ // Paused indicates the current reconciliation state of this ClusterExtension
63+ Paused bool `json:"paused"`
64+
12665 // +optional
12766 InstalledBundle * BundleMetadata `json:"installedBundle,omitempty"`
12867 // +optional
@@ -138,6 +77,7 @@ type ClusterExtensionStatus struct {
13877//+kubebuilder:object:root=true
13978//+kubebuilder:resource:scope=Cluster
14079//+kubebuilder:subresource:status
80+ //+kubebuilder:printcolumn:name="Paused",type=string,JSONPath=`.status.paused`,description="The current reconciliation state of this ClusterExtension"
14181
14282// ClusterExtension is the Schema for the clusterextensions API
14383type ClusterExtension struct {
0 commit comments