@@ -25,8 +25,8 @@ import (
2525var ClusterExtensionKind = "ClusterExtension"
2626
2727type (
28- UpgradeConstraintPolicy string
29- CRDUpgradeSafetyPolicy string
28+ UpgradeConstraintPolicy string
29+ CRDUpgradeSafetyEnforcement string
3030)
3131
3232const (
@@ -58,6 +58,7 @@ type ClusterExtensionSpec struct {
5858 // catalog:
5959 // packageName: example-package
6060 //
61+ // +kubebuilder:validation:Required
6162 Source SourceConfig `json:"source"`
6263
6364 // install is a required field used to configure the installation options
@@ -69,6 +70,7 @@ type ClusterExtensionSpec struct {
6970 // namespace: example-namespace
7071 // serviceAccount:
7172 // name: example-sa
73+ // +kubebuilder:validation:Required
7274 Install ClusterExtensionInstallConfig `json:"install"`
7375}
7476
@@ -80,14 +82,16 @@ const SourceTypeCatalog = "Catalog"
8082type SourceConfig struct {
8183 // sourceType is a required reference to the type of install source.
8284 //
83- // Allowed values are [ "Catalog"]
85+ // Allowed values are "Catalog"
8486 //
85- // When this field is set to "Catalog", information for determining the appropriate
86- // bundle of content to install will be fetched from ClusterCatalog resources existing
87- // on the cluster. When using the Catalog sourceType, the catalog field must also be set.
87+ // When this field is set to "Catalog", information for determining the
88+ // appropriate bundle of content to install will be fetched from
89+ // ClusterCatalog resources existing on the cluster.
90+ // When using the Catalog sourceType, the catalog field must also be set.
8891 //
8992 // +unionDiscriminator
9093 // +kubebuilder:validation:Enum:="Catalog"
94+ // +kubebuilder:validation:Required
9195 SourceType string `json:"sourceType"`
9296
9397 // catalog is used to configure how information is sourced from a catalog. This field must be defined when sourceType is set to "Catalog",
@@ -130,6 +134,7 @@ type ClusterExtensionInstallConfig struct {
130134 //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
131135 //+kubebuilder:validation:MaxLength:=63
132136 //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
137+ //+kubebuilder:validation:Required
133138 Namespace string `json:"namespace"`
134139
135140 // serviceAccount is a required reference to a ServiceAccount that exists
@@ -140,6 +145,7 @@ type ClusterExtensionInstallConfig struct {
140145 // the ServiceAccount provided via this field should be configured with the
141146 // appropriate permissions to perform the necessary operations on all the
142147 // resources that are included in the bundle of content being applied.
148+ //+kubebuilder:validation:Required
143149 ServiceAccount ServiceAccountReference `json:"serviceAccount"`
144150
145151 // preflight is an optional field that can be used to configure the preflight checks run before installation or upgrade of the content for the package specified in the packageName field.
@@ -181,6 +187,7 @@ type CatalogSource struct {
181187 //+kubebuilder:validation:MaxLength:=253
182188 //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
183189 //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable"
190+ //+kubebuilder:validation:Required
184191 PackageName string `json:"packageName"`
185192
186193 // version is an optional semver constraint (a specific version or range of versions). When unspecified, the latest version available will be installed.
@@ -258,14 +265,14 @@ type CatalogSource struct {
258265 // For more information on semver, please see https://semver.org/
259266 //
260267 //+kubebuilder:validation:MaxLength:=64
261- //+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*)*$`
268+ //+kubebuilder:validation:XValidation:rule="self.matches(\" ^(\\\\ 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*)*$\")",message="invalid version expression in the catalog source"
262269 //+optional
263270 Version string `json:"version,omitempty"`
264271
265272 // channels is an optional reference to a set of channels belonging to
266273 // the package specified in the packageName field.
267274 //
268- // A "channel" is a package author defined stream of updates for an extension.
275+ // A "channel" is a package- author- defined stream of updates for an extension.
269276 //
270277 // When specified, it is used to constrain the set of installable bundles and
271278 // the automated upgrade path. This constraint is an AND operation with the
@@ -322,7 +329,7 @@ type CatalogSource struct {
322329 // the upgrade path(s) defined in the catalog are enforced for the package
323330 // referenced in the packageName field.
324331 //
325- // Allowed values are: [ "CatalogProvided", "SelfCertified"] .
332+ // Allowed values are: "CatalogProvided" or "SelfCertified".
326333 //
327334 // When this field is set to "CatalogProvided", automatic upgrades will only occur
328335 // when upgrade constraints specified by the package author are met.
@@ -373,6 +380,7 @@ type ServiceAccountReference struct {
373380 //+kubebuilder:validation:MaxLength:=253
374381 //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
375382 //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
383+ //+kubebuilder:validation:Required
376384 Name string `json:"name"`
377385}
378386
@@ -386,28 +394,30 @@ type PreflightConfig struct {
386394 // consequences of upgrading a CRD, such as data loss.
387395 //
388396 // This field is required if the spec.install.preflight field is specified.
397+ //+kubebuilder:validation:Required
389398 CRDUpgradeSafety * CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety"`
390399}
391400
392401// CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check.
393402type CRDUpgradeSafetyPreflightConfig struct {
394- // policy is used to configure the state of the CRD Upgrade Safety pre-flight check.
403+ // enforcement is used to configure the state of the CRD Upgrade Safety pre-flight check.
395404 //
396405 // This field is required when the spec.install.preflight.crdUpgradeSafety field is
397406 // specified.
398407 //
399- // Allowed values are ["Enabled", "Disabled"] . The default value is "Enabled ".
408+ // Allowed values are "None" or "Strict" . The default value is "Strict ".
400409 //
401- // When set to "Disabled ", the CRD Upgrade Safety pre-flight check will be skipped
410+ // When set to "None ", the CRD Upgrade Safety pre-flight check will be skipped
402411 // when performing an upgrade operation. This should be used with caution as
403412 // unintended consequences such as data loss can occur.
404413 //
405- // When set to "Enabled ", the CRD Upgrade Safety pre-flight check will be run when
414+ // When set to "Strict ", the CRD Upgrade Safety pre-flight check will be run when
406415 // performing an upgrade operation.
407416 //
408- //+kubebuilder:validation:Enum:="Enabled";"Disabled"
409- //+kubebuilder:default:=Enabled
410- Policy CRDUpgradeSafetyPolicy `json:"policy"`
417+ //+kubebuilder:validation:Enum:="None";"Strict"
418+ //+kubebuilder:default:=Strict
419+ //+kubebuilder:validation:Required
420+ Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"`
411421}
412422
413423const (
@@ -428,8 +438,10 @@ const (
428438 ReasonBlocked = "Blocked"
429439 ReasonRetrying = "Retrying"
430440
431- CRDUpgradeSafetyPolicyEnabled CRDUpgradeSafetyPolicy = "Enabled"
432- CRDUpgradeSafetyPolicyDisabled CRDUpgradeSafetyPolicy = "Disabled"
441+ // None will not perform CRD upgrade safety checks.
442+ CRDUpgradeSafetyEnforcementNone CRDUpgradeSafetyEnforcement = "None"
443+ // Strict will enforce the CRD upgrade safety check and block the upgrade if the CRD would not pass the check.
444+ CRDUpgradeSafetyEnforcementStrict CRDUpgradeSafetyEnforcement = "Strict"
433445)
434446
435447func init () {
@@ -455,9 +467,11 @@ func init() {
455467type BundleMetadata struct {
456468 // name is a required field and is a reference
457469 // to the name of a bundle
470+ //+kubebuilder:validation:Required
458471 Name string `json:"name"`
459472 // version is a required field and is a reference
460473 // to the version that this bundle represents
474+ //+kubebuilder:validation:Required
461475 Version string `json:"version"`
462476}
463477
@@ -496,6 +510,7 @@ type ClusterExtensionStatus struct {
496510 // +patchStrategy=merge
497511 // +listType=map
498512 // +listMapKey=type
513+ // +optional
499514 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
500515}
501516
@@ -504,6 +519,7 @@ type ClusterExtensionInstallStatus struct {
504519 //
505520 // A "bundle" is a versioned set of content that represents the resources that
506521 // need to be applied to a cluster to install a package.
522+ //+kubebuilder:validation:Required
507523 Bundle BundleMetadata `json:"bundle"`
508524}
509525
@@ -516,7 +532,9 @@ type ClusterExtension struct {
516532 metav1.TypeMeta `json:",inline"`
517533 metav1.ObjectMeta `json:"metadata,omitempty"`
518534
519- Spec ClusterExtensionSpec `json:"spec,omitempty"`
535+ //+optional
536+ Spec ClusterExtensionSpec `json:"spec,omitempty"`
537+ //+optional
520538 Status ClusterExtensionStatus `json:"status,omitempty"`
521539}
522540
@@ -525,8 +543,10 @@ type ClusterExtension struct {
525543// ClusterExtensionList contains a list of ClusterExtension
526544type ClusterExtensionList struct {
527545 metav1.TypeMeta `json:",inline"`
546+ //+optional
528547 metav1.ListMeta `json:"metadata,omitempty"`
529- Items []ClusterExtension `json:"items"`
548+ //+kubebuilder:validation:Required
549+ Items []ClusterExtension `json:"items"`
530550}
531551
532552func init () {
0 commit comments