Skip to content

Commit 18053e1

Browse files
use // +required instead of // +kubebuilder:validation:Required
1 parent a3d27bb commit 18053e1

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

api/v1/clustercatalog_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type ClusterCatalog struct {
6262

6363
// spec is a required field that defines the desired state of the ClusterCatalog.
6464
// The controller ensures that the catalog is unpacked and served over the catalog content HTTP server.
65-
// +kubebuilder:validation:Required
65+
// +required
6666
Spec ClusterCatalogSpec `json:"spec"`
6767

6868
// status contains the following information about the state of the ClusterCatalog:
@@ -85,7 +85,7 @@ type ClusterCatalogList struct {
8585

8686
// items is a list of ClusterCatalogs.
8787
// items is required.
88-
// +kubebuilder:validation:Required
88+
// +required
8989
Items []ClusterCatalog `json:"items"`
9090
}
9191

@@ -105,7 +105,7 @@ type ClusterCatalogSpec struct {
105105
// image:
106106
// ref: quay.io/operatorhubio/catalog:latest
107107
//
108-
// +kubebuilder:validation:Required
108+
// +required
109109
Source CatalogSource `json:"source"`
110110

111111
// priority is an optional field that defines a priority for this ClusterCatalog.
@@ -199,7 +199,7 @@ type ClusterCatalogURLs struct {
199199
//
200200
// New endpoints may be added as needs evolve.
201201
//
202-
// +kubebuilder:validation:Required
202+
// +required
203203
// +kubebuilder:validation:MaxLength:=525
204204
// +kubebuilder:validation:XValidation:rule="isURL(self)",message="must be a valid URL"
205205
// +kubebuilder:validation:XValidation:rule="isURL(self) ? (url(self).getScheme() == \"http\" || url(self).getScheme() == \"https\") : true",message="scheme must be either http or https"
@@ -220,7 +220,7 @@ type CatalogSource struct {
220220
//
221221
// +unionDiscriminator
222222
// +kubebuilder:validation:Enum:="Image"
223-
// +kubebuilder:validation:Required
223+
// +required
224224
Type SourceType `json:"type"`
225225
// image configures how catalog contents are sourced from an OCI image.
226226
// It is required when type is Image, and forbidden otherwise.
@@ -241,7 +241,7 @@ type ResolvedCatalogSource struct {
241241
//
242242
// +unionDiscriminator
243243
// +kubebuilder:validation:Enum:="Image"
244-
// +kubebuilder:validation:Required
244+
// +required
245245
Type SourceType `json:"type"`
246246
// image contains resolution information for a catalog sourced from an image.
247247
// It must be set when type is Image, and forbidden otherwise.
@@ -253,7 +253,7 @@ type ResolvedImageSource struct {
253253
// ref contains the resolved image digest-based reference.
254254
// The digest format allows you to use other tooling to fetch the exact OCI manifests
255255
// that were used to extract the catalog contents.
256-
// +kubebuilder:validation:Required
256+
// +required
257257
// +kubebuilder:validation:MaxLength:=1000
258258
// +kubebuilder:validation:XValidation:rule="self.matches('^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])((\\\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(:[0-9]+)?\\\\b')",message="must start with a valid domain. valid domains must be alphanumeric characters (lowercase and uppercase) separated by the \".\" character."
259259
// +kubebuilder:validation:XValidation:rule="self.find('(\\\\/[a-z0-9]+((([._]|__|[-]*)[a-z0-9]+)+)?((\\\\/[a-z0-9]+((([._]|__|[-]*)[a-z0-9]+)+)?)+)?)') != \"\"",message="a valid name is required. valid names must contain lowercase alphanumeric characters separated only by the \".\", \"_\", \"__\", \"-\" characters."
@@ -307,7 +307,7 @@ type ImageSource struct {
307307
// An example of a valid digest-based image reference is "quay.io/operatorhubio/catalog@sha256:200d4ddb2a73594b91358fe6397424e975205bfbe44614f5846033cad64b3f05"
308308
// An example of a valid tag-based image reference is "quay.io/operatorhubio/catalog:latest"
309309
//
310-
// +kubebuilder:validation:Required
310+
// +required
311311
// +kubebuilder:validation:MaxLength:=1000
312312
// +kubebuilder:validation:XValidation:rule="self.matches('^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])((\\\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(:[0-9]+)?\\\\b')",message="must start with a valid domain. valid domains must be alphanumeric characters (lowercase and uppercase) separated by the \".\" character."
313313
// +kubebuilder:validation:XValidation:rule="self.find('(\\\\/[a-z0-9]+((([._]|__|[-]*)[a-z0-9]+)+)?((\\\\/[a-z0-9]+((([._]|__|[-]*)[a-z0-9]+)+)?)+)?)') != \"\"",message="a valid name is required. valid names must contain lowercase alphanumeric characters separated only by the \".\", \"_\", \"__\", \"-\" characters."

api/v1/clusterextension_types.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type ClusterExtensionSpec struct {
6363
// +kubebuilder:validation:MaxLength:=63
6464
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
6565
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\")",message="namespace must be a valid DNS1123 label"
66-
// +kubebuilder:validation:Required
66+
// +required
6767
Namespace string `json:"namespace"`
6868

6969
// serviceAccount specifies a ServiceAccount used to perform all interactions with the cluster
@@ -72,7 +72,7 @@ type ClusterExtensionSpec struct {
7272
// The ServiceAccount must exist in the namespace referenced in the spec.
7373
// The serviceAccount field is required.
7474
//
75-
// +kubebuilder:validation:Required
75+
// +required
7676
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
7777

7878
// source is required and selects the installation source of content for this ClusterExtension.
@@ -88,7 +88,7 @@ type ClusterExtensionSpec struct {
8888
// catalog:
8989
// packageName: example-package
9090
//
91-
// +kubebuilder:validation:Required
91+
// +required
9292
Source SourceConfig `json:"source"`
9393

9494
// install is optional and configures installation options for the ClusterExtension,
@@ -127,7 +127,7 @@ type SourceConfig struct {
127127
//
128128
// +unionDiscriminator
129129
// +kubebuilder:validation:Enum:="Catalog"
130-
// +kubebuilder:validation:Required
130+
// +required
131131
SourceType string `json:"sourceType"`
132132

133133
// catalog configures how information is sourced from a catalog.
@@ -167,7 +167,7 @@ type ClusterExtensionConfig struct {
167167
//
168168
// +unionDiscriminator
169169
// +kubebuilder:validation:Enum:="Inline"
170-
// +kubebuilder:validation:Required
170+
// +required
171171
ConfigType ClusterExtensionConfigType `json:"configType"`
172172

173173
// inline contains JSON or YAML values specified directly in the ClusterExtension.
@@ -210,7 +210,7 @@ type CatalogFilter struct {
210210
// +kubebuilder:validation:MaxLength:=253
211211
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable"
212212
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="packageName must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
213-
// +kubebuilder:validation:Required
213+
// +required
214214
PackageName string `json:"packageName"`
215215

216216
// version is an optional semver constraint (a specific version or range of versions).
@@ -393,7 +393,7 @@ type ServiceAccountReference struct {
393393
// +kubebuilder:validation:MaxLength:=253
394394
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
395395
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="name must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
396-
// +kubebuilder:validation:Required
396+
// +required
397397
Name string `json:"name"`
398398
}
399399

@@ -421,7 +421,7 @@ type CRDUpgradeSafetyPreflightConfig struct {
421421
// When set to "Strict", the CRD Upgrade Safety pre-flight check runs during an upgrade operation.
422422
//
423423
// +kubebuilder:validation:Enum:="None";"Strict"
424-
// +kubebuilder:validation:Required
424+
// +required
425425
Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"`
426426
}
427427

@@ -445,14 +445,14 @@ type BundleMetadata struct {
445445
// It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.),
446446
// start and end with an alphanumeric character, and be no longer than 253 characters.
447447
//
448-
// +kubebuilder:validation:Required
448+
// +required
449449
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="packageName must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
450450
Name string `json:"name"`
451451

452452
// version is required and references the version that this bundle represents.
453453
// It follows the semantic versioning standard as defined in https://semver.org/.
454454
//
455-
// +kubebuilder:validation:Required
455+
// +required
456456
// +kubebuilder:validation:XValidation:rule="self.matches(\"^([0-9]+)(\\\\.[0-9]+)?(\\\\.[0-9]+)?(-([-0-9A-Za-z]+(\\\\.[-0-9A-Za-z]+)*))?(\\\\+([-0-9A-Za-z]+(-\\\\.[-0-9A-Za-z]+)*))?\")",message="version must be well-formed semver"
457457
Version string `json:"version"`
458458
}
@@ -521,7 +521,7 @@ type ClusterExtensionInstallStatus struct {
521521
// A "bundle" is a versioned set of content that represents the resources that need to be applied
522522
// to a cluster to install a package.
523523
//
524-
// +kubebuilder:validation:Required
524+
// +required
525525
Bundle BundleMetadata `json:"bundle"`
526526
}
527527

@@ -559,7 +559,7 @@ type ClusterExtensionList struct {
559559

560560
// items is a required list of ClusterExtension objects.
561561
//
562-
// +kubebuilder:validation:Required
562+
// +required
563563
Items []ClusterExtension `json:"items"`
564564
}
565565

api/v1/clusterextensionrevision_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type ClusterExtensionRevisionSpec struct {
6161
// Each ClusterExtensionRevision belonging to the same parent ClusterExtension must have a unique revision number.
6262
// The revision number must always be the previous revision number plus one, or 1 for the first revision.
6363
//
64-
// +kubebuilder:validation:Required
64+
// +required
6565
// +kubebuilder:validation:Minimum:=1
6666
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="revision is immutable"
6767
Revision int64 `json:"revision"`
@@ -238,7 +238,7 @@ type ClusterExtensionRevisionList struct {
238238

239239
// items is a required list of ClusterExtensionRevision objects.
240240
//
241-
// +kubebuilder:validation:Required
241+
// +required
242242
Items []ClusterExtensionRevision `json:"items"`
243243
}
244244

0 commit comments

Comments
 (0)