Skip to content

Commit e116b54

Browse files
authored
Merge pull request #2825 from NikhilSharmaWe/addMarkersForSizeSpec
✨deploy-image/v1alpha: add validation markers for size spec
2 parents 08236ba + cb8d02c commit e116b54

File tree

9 files changed

+45
-4
lines changed

9 files changed

+45
-4
lines changed

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/api/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ type {{ .Resource.Kind }}Spec struct {
7777
// Important: Run "make" to regenerate code after modifying this file
7878
7979
// Size defines the number of {{ .Resource.Kind }} instances
80+
// The following markers will use OpenAPI v3 schema to validate the value
81+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
82+
// +kubebuilder:validation:Minimum=1
83+
// +kubebuilder:validation:Maximum=3
84+
// +kubebuilder:validation:ExclusiveMaximum=false
8085
Size int32 ` + "`" + `json:"size,omitempty"` + "`" + `
8186
8287
{{ if not (isEmptyStr .Port) -}}

testdata/project-v3-with-deploy-image/api/v1alpha1/busybox_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type BusyboxSpec struct {
2929
// Important: Run "make" to regenerate code after modifying this file
3030

3131
// Size defines the number of Busybox instances
32+
// The following markers will use OpenAPI v3 schema to validate the value
33+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
34+
// +kubebuilder:validation:Minimum=1
35+
// +kubebuilder:validation:Maximum=3
36+
// +kubebuilder:validation:ExclusiveMaximum=false
3237
Size int32 `json:"size,omitempty"`
3338
}
3439

testdata/project-v3-with-deploy-image/api/v1alpha1/memcached_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type MemcachedSpec struct {
2929
// Important: Run "make" to regenerate code after modifying this file
3030

3131
// Size defines the number of Memcached instances
32+
// The following markers will use OpenAPI v3 schema to validate the value
33+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
34+
// +kubebuilder:validation:Minimum=1
35+
// +kubebuilder:validation:Maximum=3
36+
// +kubebuilder:validation:ExclusiveMaximum=false
3237
Size int32 `json:"size,omitempty"`
3338

3439
// Port defines the port that will be used to init the container with the image

testdata/project-v3-with-deploy-image/config/crd/bases/example.com.testproject.org_busyboxes.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ spec:
3636
description: BusyboxSpec defines the desired state of Busybox
3737
properties:
3838
size:
39-
description: Size defines the number of Busybox instances
39+
description: 'Size defines the number of Busybox instances The following
40+
markers will use OpenAPI v3 schema to validate the value More info:
41+
https://book.kubebuilder.io/reference/markers/crd-validation.html'
4042
format: int32
43+
maximum: 3
44+
minimum: 1
4145
type: integer
4246
type: object
4347
status:

testdata/project-v3-with-deploy-image/config/crd/bases/example.com.testproject.org_memcacheds.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ spec:
4141
format: int32
4242
type: integer
4343
size:
44-
description: Size defines the number of Memcached instances
44+
description: 'Size defines the number of Memcached instances The following
45+
markers will use OpenAPI v3 schema to validate the value More info:
46+
https://book.kubebuilder.io/reference/markers/crd-validation.html'
4547
format: int32
48+
maximum: 3
49+
minimum: 1
4650
type: integer
4751
type: object
4852
status:

testdata/project-v4-with-deploy-image/api/v1alpha1/busybox_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type BusyboxSpec struct {
2929
// Important: Run "make" to regenerate code after modifying this file
3030

3131
// Size defines the number of Busybox instances
32+
// The following markers will use OpenAPI v3 schema to validate the value
33+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
34+
// +kubebuilder:validation:Minimum=1
35+
// +kubebuilder:validation:Maximum=3
36+
// +kubebuilder:validation:ExclusiveMaximum=false
3237
Size int32 `json:"size,omitempty"`
3338
}
3439

testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type MemcachedSpec struct {
2929
// Important: Run "make" to regenerate code after modifying this file
3030

3131
// Size defines the number of Memcached instances
32+
// The following markers will use OpenAPI v3 schema to validate the value
33+
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
34+
// +kubebuilder:validation:Minimum=1
35+
// +kubebuilder:validation:Maximum=3
36+
// +kubebuilder:validation:ExclusiveMaximum=false
3237
Size int32 `json:"size,omitempty"`
3338

3439
// Port defines the port that will be used to init the container with the image

testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_busyboxes.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ spec:
3636
description: BusyboxSpec defines the desired state of Busybox
3737
properties:
3838
size:
39-
description: Size defines the number of Busybox instances
39+
description: 'Size defines the number of Busybox instances The following
40+
markers will use OpenAPI v3 schema to validate the value More info:
41+
https://book.kubebuilder.io/reference/markers/crd-validation.html'
4042
format: int32
43+
maximum: 3
44+
minimum: 1
4145
type: integer
4246
type: object
4347
status:

testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_memcacheds.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ spec:
4141
format: int32
4242
type: integer
4343
size:
44-
description: Size defines the number of Memcached instances
44+
description: 'Size defines the number of Memcached instances The following
45+
markers will use OpenAPI v3 schema to validate the value More info:
46+
https://book.kubebuilder.io/reference/markers/crd-validation.html'
4547
format: int32
48+
maximum: 3
49+
minimum: 1
4650
type: integer
4751
type: object
4852
status:

0 commit comments

Comments
 (0)