Skip to content

Commit 5e0e36d

Browse files
committed
update updateRun validations to ensure ApprovalRequest name uniqueness
1 parent a85779b commit 5e0e36d

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

apis/placement/v1alpha1/stagedupdate_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ import (
1919
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2020
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
2121
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
22-
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
2322
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
2423
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
2524
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
2625
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
26+
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
27+
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 128",message="metadata.name max length is 127"
2728

2829
// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
2930
// selected resources to specified clusters.
@@ -109,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
109110
type StageConfig struct {
110111
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
111112
// +kubebuilder:validation:MaxLength=63
112-
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
113+
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
113114
// +kubebuilder:validation:Required
114115
Name string `json:"name"`
115116

apis/placement/v1beta1/stageupdate_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import (
1818
// +kubebuilder:storageversion
1919
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
2020
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
21-
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
2221
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
2322
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
2423
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
2524
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
25+
// +kubebuilder:printcolumn:JSONPath=`.spec.stagedRolloutStrategyName`,name="Strategy",priority=1,type=string
26+
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) < 128",message="metadata.name max length is 127"
2627

2728
// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
2829
// selected resources to specified clusters.
@@ -109,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
109110
type StageConfig struct {
110111
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
111112
// +kubebuilder:validation:MaxLength=63
112-
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
113+
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
113114
// +kubebuilder:validation:Required
114115
Name string `json:"name"`
115116

config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdateruns.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ spec:
2626
- jsonPath: .spec.resourceSnapshotIndex
2727
name: Resource-Snapshot
2828
type: string
29-
- jsonPath: .spec.stagedRolloutStrategyName
30-
name: Strategy
31-
priority: 1
32-
type: string
3329
- jsonPath: .status.policySnapshotIndexUsed
3430
name: Policy-Snapshot
3531
type: string
@@ -42,6 +38,10 @@ spec:
4238
- jsonPath: .metadata.creationTimestamp
4339
name: Age
4440
type: date
41+
- jsonPath: .spec.stagedRolloutStrategyName
42+
name: Strategy
43+
priority: 1
44+
type: string
4545
name: v1alpha1
4646
schema:
4747
openAPIV3Schema:
@@ -884,7 +884,7 @@ spec:
884884
description: The name of the stage. This MUST be unique
885885
within the same StagedUpdateStrategy.
886886
maxLength: 63
887-
pattern: '[A-Za-z0-9]+$'
887+
pattern: ^[a-z0-9]+$
888888
type: string
889889
sortingLabelKey:
890890
description: |-
@@ -1232,6 +1232,9 @@ spec:
12321232
required:
12331233
- spec
12341234
type: object
1235+
x-kubernetes-validations:
1236+
- message: metadata.name max length is 127
1237+
rule: size(self.metadata.name) < 128
12351238
served: true
12361239
storage: false
12371240
subresources:
@@ -1243,10 +1246,6 @@ spec:
12431246
- jsonPath: .spec.resourceSnapshotIndex
12441247
name: Resource-Snapshot
12451248
type: string
1246-
- jsonPath: .spec.stagedRolloutStrategyName
1247-
name: Strategy
1248-
priority: 1
1249-
type: string
12501249
- jsonPath: .status.policySnapshotIndexUsed
12511250
name: Policy-Snapshot
12521251
type: string
@@ -1259,6 +1258,10 @@ spec:
12591258
- jsonPath: .metadata.creationTimestamp
12601259
name: Age
12611260
type: date
1261+
- jsonPath: .spec.stagedRolloutStrategyName
1262+
name: Strategy
1263+
priority: 1
1264+
type: string
12621265
name: v1beta1
12631266
schema:
12641267
openAPIV3Schema:
@@ -2101,7 +2104,7 @@ spec:
21012104
description: The name of the stage. This MUST be unique
21022105
within the same StagedUpdateStrategy.
21032106
maxLength: 63
2104-
pattern: '[A-Za-z0-9]+$'
2107+
pattern: ^[a-z0-9]+$
21052108
type: string
21062109
sortingLabelKey:
21072110
description: |-
@@ -2449,6 +2452,9 @@ spec:
24492452
required:
24502453
- spec
24512454
type: object
2455+
x-kubernetes-validations:
2456+
- message: metadata.name max length is 127
2457+
rule: size(self.metadata.name) < 128
24522458
served: true
24532459
storage: true
24542460
subresources:

config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdatestrategies.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ spec:
134134
description: The name of the stage. This MUST be unique within
135135
the same StagedUpdateStrategy.
136136
maxLength: 63
137-
pattern: '[A-Za-z0-9]+$'
137+
pattern: ^[a-z0-9]+$
138138
type: string
139139
sortingLabelKey:
140140
description: |-
@@ -273,7 +273,7 @@ spec:
273273
description: The name of the stage. This MUST be unique within
274274
the same StagedUpdateStrategy.
275275
maxLength: 63
276-
pattern: '[A-Za-z0-9]+$'
276+
pattern: ^[a-z0-9]+$
277277
type: string
278278
sortingLabelKey:
279279
description: |-

0 commit comments

Comments
 (0)