@@ -18,53 +18,35 @@ package v1alpha1
18
18
19
19
import (
20
20
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
-
22
- "github.com/operator-framework/operator-controller/internal/conditionsets"
23
21
)
24
22
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
+ }
40
35
41
36
// ClusterExtensionSpec defines the desired state of ClusterExtension
42
37
type 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*)*$`
49
38
//+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
53
39
//
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"`
56
42
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"`
61
45
62
- //+kubebuilder:validation:Enum:=Enforce;Ignore
63
- //+kubebuilder:default:=Enforce
64
46
//+kubebuilder:Optional
65
47
//
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"`
68
50
69
51
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
70
52
//+kubebuilder:validation:MaxLength:=63
@@ -75,54 +57,11 @@ type ClusterExtensionSpec struct {
75
57
InstallNamespace string `json:"installNamespace"`
76
58
}
77
59
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
-
124
60
// ClusterExtensionStatus defines the observed state of ClusterExtension
125
61
type ClusterExtensionStatus struct {
62
+ // Paused indicates the current reconciliation state of this ClusterExtension
63
+ Paused bool `json:"paused"`
64
+
126
65
// +optional
127
66
InstalledBundle * BundleMetadata `json:"installedBundle,omitempty"`
128
67
// +optional
@@ -138,6 +77,7 @@ type ClusterExtensionStatus struct {
138
77
//+kubebuilder:object:root=true
139
78
//+kubebuilder:resource:scope=Cluster
140
79
//+kubebuilder:subresource:status
80
+ //+kubebuilder:printcolumn:name="Paused",type=string,JSONPath=`.status.paused`,description="The current reconciliation state of this ClusterExtension"
141
81
142
82
// ClusterExtension is the Schema for the clusterextensions API
143
83
type ClusterExtension struct {
0 commit comments