Skip to content

Commit 91ceed6

Browse files
use // +required instead of // +kubebuilder:validation:Required
1 parent 024f5c8 commit 91ceed6

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

api/v1/clustercatalog_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type ClusterCatalog struct {
6464
// spec is required.
6565
// The controller will work to ensure that the desired
6666
// catalog is unpacked and served over the catalog content HTTP server.
67-
// +kubebuilder:validation:Required
67+
// +required
6868
Spec ClusterCatalogSpec `json:"spec"`
6969

7070
// status contains information about the state of the ClusterCatalog such as:
@@ -87,7 +87,7 @@ type ClusterCatalogList struct {
8787

8888
// items is a list of ClusterCatalogs.
8989
// items is required.
90-
// +kubebuilder:validation:Required
90+
// +required
9191
Items []ClusterCatalog `json:"items"`
9292
}
9393

@@ -110,7 +110,7 @@ type ClusterCatalogSpec struct {
110110
// image:
111111
// ref: quay.io/operatorhubio/catalog:latest
112112
//
113-
// +kubebuilder:validation:Required
113+
// +required
114114
Source CatalogSource `json:"source"`
115115

116116
// priority allows the user to define a priority for a ClusterCatalog.
@@ -214,7 +214,7 @@ type ClusterCatalogURLs struct {
214214
//
215215
// As the needs of users and clients of the evolve, new endpoints may be added.
216216
//
217-
// +kubebuilder:validation:Required
217+
// +required
218218
// +kubebuilder:validation:MaxLength:=525
219219
// +kubebuilder:validation:XValidation:rule="isURL(self)",message="must be a valid URL"
220220
// +kubebuilder:validation:XValidation:rule="isURL(self) ? (url(self).getScheme() == \"http\" || url(self).getScheme() == \"https\") : true",message="scheme must be either http or https"
@@ -236,7 +236,7 @@ type CatalogSource struct {
236236
//
237237
// +unionDiscriminator
238238
// +kubebuilder:validation:Enum:="Image"
239-
// +kubebuilder:validation:Required
239+
// +required
240240
Type SourceType `json:"type"`
241241
// image is used to configure how catalog contents are sourced from an OCI image.
242242
// This field is required when type is Image, and forbidden otherwise.
@@ -258,7 +258,7 @@ type ResolvedCatalogSource struct {
258258
//
259259
// +unionDiscriminator
260260
// +kubebuilder:validation:Enum:="Image"
261-
// +kubebuilder:validation:Required
261+
// +required
262262
Type SourceType `json:"type"`
263263
// image is a field containing resolution information for a catalog sourced from an image.
264264
// This field must be set when type is Image, and forbidden otherwise.
@@ -270,7 +270,7 @@ type ResolvedImageSource struct {
270270
// ref contains the resolved image digest-based reference.
271271
// The digest format is used so users can use other tooling to fetch the exact
272272
// OCI manifests that were used to extract the catalog contents.
273-
// +kubebuilder:validation:Required
273+
// +required
274274
// +kubebuilder:validation:MaxLength:=1000
275275
// +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."
276276
// +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."
@@ -325,7 +325,7 @@ type ImageSource struct {
325325
// An example of a valid digest-based image reference is "quay.io/operatorhubio/catalog@sha256:200d4ddb2a73594b91358fe6397424e975205bfbe44614f5846033cad64b3f05"
326326
// An example of a valid tag-based image reference is "quay.io/operatorhubio/catalog:latest"
327327
//
328-
// +kubebuilder:validation:Required
328+
// +required
329329
// +kubebuilder:validation:MaxLength:=1000
330330
// +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."
331331
// +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
@@ -64,7 +64,7 @@ type ClusterExtensionSpec struct {
6464
// +kubebuilder:validation:MaxLength:=63
6565
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
6666
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\")",message="namespace must be a valid DNS1123 label"
67-
// +kubebuilder:validation:Required
67+
// +required
6868
Namespace string `json:"namespace"`
6969

7070
// serviceAccount is a reference to a ServiceAccount used to perform all interactions
@@ -73,7 +73,7 @@ type ClusterExtensionSpec struct {
7373
// The ServiceAccount must exist in the namespace referenced in the spec.
7474
// serviceAccount is required.
7575
//
76-
// +kubebuilder:validation:Required
76+
// +required
7777
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
7878

7979
// source is a required field which selects the installation source of content
@@ -89,7 +89,7 @@ type ClusterExtensionSpec struct {
8989
// catalog:
9090
// packageName: example-package
9191
//
92-
// +kubebuilder:validation:Required
92+
// +required
9393
Source SourceConfig `json:"source"`
9494

9595
// install is an optional field used to configure the installation options
@@ -129,7 +129,7 @@ type SourceConfig struct {
129129
//
130130
// +unionDiscriminator
131131
// +kubebuilder:validation:Enum:="Catalog"
132-
// +kubebuilder:validation:Required
132+
// +required
133133
SourceType string `json:"sourceType"`
134134

135135
// catalog is used to configure how information is sourced from a catalog.
@@ -170,7 +170,7 @@ type ClusterExtensionConfig struct {
170170
//
171171
// +unionDiscriminator
172172
// +kubebuilder:validation:Enum:="Inline"
173-
// +kubebuilder:validation:Required
173+
// +required
174174
ConfigType ClusterExtensionConfigType `json:"configType"`
175175

176176
// inline contains JSON or YAML values specified directly in the
@@ -215,7 +215,7 @@ type CatalogFilter struct {
215215
// +kubebuilder:validation:MaxLength:=253
216216
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable"
217217
// +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"
218-
// +kubebuilder:validation:Required
218+
// +required
219219
PackageName string `json:"packageName"`
220220

221221
// version is an optional semver constraint (a specific version or range of versions). When unspecified, the latest version available will be installed.
@@ -405,7 +405,7 @@ type ServiceAccountReference struct {
405405
// +kubebuilder:validation:MaxLength:=253
406406
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
407407
// +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"
408-
// +kubebuilder:validation:Required
408+
// +required
409409
Name string `json:"name"`
410410
}
411411

@@ -435,7 +435,7 @@ type CRDUpgradeSafetyPreflightConfig struct {
435435
// performing an upgrade operation.
436436
//
437437
// +kubebuilder:validation:Enum:="None";"Strict"
438-
// +kubebuilder:validation:Required
438+
// +required
439439
Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"`
440440
}
441441

@@ -460,14 +460,14 @@ type BundleMetadata struct {
460460
// hyphens (-) or periods (.), start and end with an alphanumeric character,
461461
// and be no longer than 253 characters.
462462
//
463-
// +kubebuilder:validation:Required
463+
// +required
464464
// +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"
465465
Name string `json:"name"`
466466

467467
// version is a required field and is a reference to the version that this bundle represents
468468
// version follows the semantic versioning standard as defined in https://semver.org/.
469469
//
470-
// +kubebuilder:validation:Required
470+
// +required
471471
// +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"
472472
Version string `json:"version"`
473473
}
@@ -536,7 +536,7 @@ type ClusterExtensionInstallStatus struct {
536536
// A "bundle" is a versioned set of content that represents the resources that
537537
// need to be applied to a cluster to install a package.
538538
//
539-
// +kubebuilder:validation:Required
539+
// +required
540540
Bundle BundleMetadata `json:"bundle"`
541541
}
542542

@@ -574,7 +574,7 @@ type ClusterExtensionList struct {
574574

575575
// items is a required list of ClusterExtension objects.
576576
//
577-
// +kubebuilder:validation:Required
577+
// +required
578578
Items []ClusterExtension `json:"items"`
579579
}
580580

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

hack/tools/crd-generator/testdata/api/v1/clusterextension_types.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type ClusterExtensionSpec struct {
6060
// <opcon:standard:validation:XValidation:rule="self == oldSelf",message="namespace is immutable">
6161
// <opcon:experimental:validation:XValidation:rule="self == oldSelf",message="namespace really is immutable">
6262
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\")",message="namespace must be a valid DNS1123 label"
63-
// +kubebuilder:validation:Required
63+
// +required
6464
Namespace string `json:"namespace"`
6565

6666
// serviceAccount is a reference to a ServiceAccount used to perform all interactions
@@ -69,7 +69,7 @@ type ClusterExtensionSpec struct {
6969
// The ServiceAccount must exist in the namespace referenced in the spec.
7070
// serviceAccount is required.
7171
//
72-
// +kubebuilder:validation:Required
72+
// +required
7373
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
7474

7575
// source is a required field which selects the installation source of content
@@ -85,7 +85,7 @@ type ClusterExtensionSpec struct {
8585
// catalog:
8686
// packageName: example-package
8787
//
88-
// +kubebuilder:validation:Required
88+
// +required
8989
Source SourceConfig `json:"source"`
9090

9191
// install is an optional field used to configure the installation options
@@ -114,7 +114,7 @@ type SourceConfig struct {
114114
// +unionDiscriminator
115115
// <opcon:standard:validation:Enum=Catalog>
116116
// <opcon:experimental:validation:Enum=Catalog;NotCatalog>
117-
// +kubebuilder:validation:Required
117+
// +required
118118
SourceType string `json:"sourceType"`
119119

120120
// catalog is used to configure how information is sourced from a catalog.
@@ -180,7 +180,7 @@ type CatalogFilter struct {
180180
// +kubebuilder:validation:MaxLength:=253
181181
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable"
182182
// +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"
183-
// +kubebuilder:validation:Required
183+
// +required
184184
PackageName string `json:"packageName"`
185185

186186
// version is an optional semver constraint (a specific version or range of versions). When unspecified, the latest version available will be installed.
@@ -370,7 +370,7 @@ type ServiceAccountReference struct {
370370
// +kubebuilder:validation:MaxLength:=253
371371
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
372372
// +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"
373-
// +kubebuilder:validation:Required
373+
// +required
374374
Name string `json:"name"`
375375
}
376376

@@ -400,7 +400,7 @@ type CRDUpgradeSafetyPreflightConfig struct {
400400
// performing an upgrade operation.
401401
//
402402
// +kubebuilder:validation:Enum:="None";"Strict"
403-
// +kubebuilder:validation:Required
403+
// +required
404404
Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"`
405405
}
406406

@@ -425,14 +425,14 @@ type BundleMetadata struct {
425425
// hyphens (-) or periods (.), start and end with an alphanumeric character,
426426
// and be no longer than 253 characters.
427427
//
428-
// +kubebuilder:validation:Required
428+
// +required
429429
// +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"
430430
Name string `json:"name"`
431431

432432
// version is a required field and is a reference to the version that this bundle represents
433433
// version follows the semantic versioning standard as defined in https://semver.org/.
434434
//
435-
// +kubebuilder:validation:Required
435+
// +required
436436
// +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"
437437
Version string `json:"version"`
438438
}
@@ -475,7 +475,7 @@ type ClusterExtensionInstallStatus struct {
475475
// A "bundle" is a versioned set of content that represents the resources that
476476
// need to be applied to a cluster to install a package.
477477
//
478-
// +kubebuilder:validation:Required
478+
// +required
479479
Bundle BundleMetadata `json:"bundle"`
480480
}
481481

@@ -513,7 +513,7 @@ type ClusterExtensionList struct {
513513

514514
// items is a required list of ClusterExtension objects.
515515
//
516-
// +kubebuilder:validation:Required
516+
// +required
517517
Items []ClusterExtension `json:"items"`
518518
}
519519

0 commit comments

Comments
 (0)