@@ -25,8 +25,8 @@ import (
25
25
var ClusterExtensionKind = "ClusterExtension"
26
26
27
27
type (
28
- UpgradeConstraintPolicy string
29
- CRDUpgradeSafetyPolicy string
28
+ UpgradeConstraintPolicy string
29
+ CRDUpgradeSafetyEnforcement string
30
30
)
31
31
32
32
const (
@@ -58,6 +58,7 @@ type ClusterExtensionSpec struct {
58
58
// catalog:
59
59
// packageName: example-package
60
60
//
61
+ // +kubebuilder:validation:Required
61
62
Source SourceConfig `json:"source"`
62
63
63
64
// install is a required field used to configure the installation options
@@ -69,6 +70,7 @@ type ClusterExtensionSpec struct {
69
70
// namespace: example-namespace
70
71
// serviceAccount:
71
72
// name: example-sa
73
+ // +kubebuilder:validation:Required
72
74
Install ClusterExtensionInstallConfig `json:"install"`
73
75
}
74
76
@@ -88,6 +90,7 @@ type SourceConfig struct {
88
90
//
89
91
// +unionDiscriminator
90
92
// +kubebuilder:validation:Enum:="Catalog"
93
+ // +kubebuilder:validation:Required
91
94
SourceType string `json:"sourceType"`
92
95
93
96
// 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 +133,7 @@ type ClusterExtensionInstallConfig struct {
130
133
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
131
134
//+kubebuilder:validation:MaxLength:=63
132
135
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
136
+ //+kubebuilder:validation:Required
133
137
Namespace string `json:"namespace"`
134
138
135
139
// serviceAccount is a required reference to a ServiceAccount that exists
@@ -140,6 +144,7 @@ type ClusterExtensionInstallConfig struct {
140
144
// the ServiceAccount provided via this field should be configured with the
141
145
// appropriate permissions to perform the necessary operations on all the
142
146
// resources that are included in the bundle of content being applied.
147
+ //+kubebuilder:validation:Required
143
148
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
144
149
145
150
// 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 +186,7 @@ type CatalogSource struct {
181
186
//+kubebuilder:validation:MaxLength:=253
182
187
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
183
188
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable"
189
+ //+kubebuilder:validation:Required
184
190
PackageName string `json:"packageName"`
185
191
186
192
// version is an optional semver constraint (a specific version or range of versions). When unspecified, the latest version available will be installed.
@@ -258,7 +264,7 @@ type CatalogSource struct {
258
264
// For more information on semver, please see https://semver.org/
259
265
//
260
266
//+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*)*$`
267
+ //+kubebuilder:validation.XValidation:rule="self.matches(r' ^(\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"
262
268
//+optional
263
269
Version string `json:"version,omitempty"`
264
270
@@ -373,6 +379,7 @@ type ServiceAccountReference struct {
373
379
//+kubebuilder:validation:MaxLength:=253
374
380
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
375
381
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
382
+ //+kubebuilder:validation:Required
376
383
Name string `json:"name"`
377
384
}
378
385
@@ -386,28 +393,30 @@ type PreflightConfig struct {
386
393
// consequences of upgrading a CRD, such as data loss.
387
394
//
388
395
// This field is required if the spec.install.preflight field is specified.
396
+ //+kubebuilder:validation:Required
389
397
CRDUpgradeSafety * CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety"`
390
398
}
391
399
392
400
// CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check.
393
401
type CRDUpgradeSafetyPreflightConfig struct {
394
- // policy is used to configure the state of the CRD Upgrade Safety pre-flight check.
402
+ // enforcement is used to configure the state of the CRD Upgrade Safety pre-flight check.
395
403
//
396
404
// This field is required when the spec.install.preflight.crdUpgradeSafety field is
397
405
// specified.
398
406
//
399
- // Allowed values are ["Enabled ", "Disabled "]. The default value is "Enabled ".
407
+ // Allowed values are ["None ", "Strict "]. The default value is "Strict ".
400
408
//
401
- // When set to "Disabled ", the CRD Upgrade Safety pre-flight check will be skipped
409
+ // When set to "None ", the CRD Upgrade Safety pre-flight check will be skipped
402
410
// when performing an upgrade operation. This should be used with caution as
403
411
// unintended consequences such as data loss can occur.
404
412
//
405
- // When set to "Enabled ", the CRD Upgrade Safety pre-flight check will be run when
413
+ // When set to "Strict ", the CRD Upgrade Safety pre-flight check will be run when
406
414
// performing an upgrade operation.
407
415
//
408
- //+kubebuilder:validation:Enum:="Enabled";"Disabled"
409
- //+kubebuilder:default:=Enabled
410
- Policy CRDUpgradeSafetyPolicy `json:"policy"`
416
+ //+kubebuilder:validation:Enum:="None";"Strict"
417
+ //+kubebuilder:default:=Strict
418
+ //+kubebuilder:validation:Required
419
+ Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"`
411
420
}
412
421
413
422
const (
@@ -428,8 +437,10 @@ const (
428
437
ReasonBlocked = "Blocked"
429
438
ReasonRetrying = "Retrying"
430
439
431
- CRDUpgradeSafetyPolicyEnabled CRDUpgradeSafetyPolicy = "Enabled"
432
- CRDUpgradeSafetyPolicyDisabled CRDUpgradeSafetyPolicy = "Disabled"
440
+ // None will not perform CRD upgrade safety checks.
441
+ CRDUpgradeSafetyEnforcementNone CRDUpgradeSafetyEnforcement = "None"
442
+ // Strict will enforce the CRD upgrade safety check and block the upgrade if the CRD would not pass the check.
443
+ CRDUpgradeSafetyEnforcementStrict CRDUpgradeSafetyEnforcement = "Strict"
433
444
)
434
445
435
446
func init () {
@@ -455,9 +466,11 @@ func init() {
455
466
type BundleMetadata struct {
456
467
// name is a required field and is a reference
457
468
// to the name of a bundle
469
+ //+kubebuilder:validation:Required
458
470
Name string `json:"name"`
459
471
// version is a required field and is a reference
460
472
// to the version that this bundle represents
473
+ //+kubebuilder:validation:Required
461
474
Version string `json:"version"`
462
475
}
463
476
@@ -496,6 +509,7 @@ type ClusterExtensionStatus struct {
496
509
// +patchStrategy=merge
497
510
// +listType=map
498
511
// +listMapKey=type
512
+ // +optional
499
513
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
500
514
}
501
515
@@ -504,6 +518,7 @@ type ClusterExtensionInstallStatus struct {
504
518
//
505
519
// A "bundle" is a versioned set of content that represents the resources that
506
520
// need to be applied to a cluster to install a package.
521
+ //+kubebuilder:validation:Required
507
522
Bundle BundleMetadata `json:"bundle"`
508
523
}
509
524
@@ -516,7 +531,9 @@ type ClusterExtension struct {
516
531
metav1.TypeMeta `json:",inline"`
517
532
metav1.ObjectMeta `json:"metadata,omitempty"`
518
533
519
- Spec ClusterExtensionSpec `json:"spec,omitempty"`
534
+ //+optional
535
+ Spec ClusterExtensionSpec `json:"spec,omitempty"`
536
+ //+optional
520
537
Status ClusterExtensionStatus `json:"status,omitempty"`
521
538
}
522
539
@@ -525,8 +542,10 @@ type ClusterExtension struct {
525
542
// ClusterExtensionList contains a list of ClusterExtension
526
543
type ClusterExtensionList struct {
527
544
metav1.TypeMeta `json:",inline"`
545
+ //+optional
528
546
metav1.ListMeta `json:"metadata,omitempty"`
529
- Items []ClusterExtension `json:"items"`
547
+ //+kubebuilder:validation:Required
548
+ Items []ClusterExtension `json:"items"`
530
549
}
531
550
532
551
func init () {
0 commit comments