Skip to content

Commit 7dfc13c

Browse files
authored
interface: improve ClusterStagedUpdateRun APIs (#1008)
1 parent 2ddff5f commit 7dfc13c

File tree

7 files changed

+322
-14
lines changed

7 files changed

+322
-14
lines changed

apis/placement/v1alpha1/stagedupdate_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import (
1717
// +kubebuilder:subresource:status
1818
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur
1919
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
20+
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
21+
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
22+
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
23+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
24+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
25+
// +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"
2028

2129
// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
2230
// selected resources to specified clusters.
@@ -102,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
102110
type StageConfig struct {
103111
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
104112
// +kubebuilder:validation:MaxLength=63
105-
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
113+
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
106114
// +kubebuilder:validation:Required
107115
Name string `json:"name"`
108116

@@ -397,6 +405,10 @@ type ClusterStagedUpdateRunList struct {
397405
// +kubebuilder:subresource:status
398406
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=careq
399407
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
408+
// +kubebuilder:printcolumn:JSONPath=`.spec.parentStageRollout`,name="Update-Run",type=string
409+
// +kubebuilder:printcolumn:JSONPath=`.spec.targetStage`,name="Stage",type=string
410+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Approved")].status`,name="Approved",type=string
411+
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
400412

401413
// ClusterApprovalRequest defines a request for user approval for cluster staged update run.
402414
// The request object MUST have the following labels:

apis/placement/v1beta1/stageupdate_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ import (
1616
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur
1717
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1818
// +kubebuilder:storageversion
19+
// +kubebuilder:printcolumn:JSONPath=`.spec.placementName`,name="Placement",type=string
20+
// +kubebuilder:printcolumn:JSONPath=`.spec.resourceSnapshotIndex`,name="Resource-Snapshot",type=string
21+
// +kubebuilder:printcolumn:JSONPath=`.status.policySnapshotIndexUsed`,name="Policy-Snapshot",type=string
22+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Initialized")].status`,name="Initialized",type=string
23+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Succeeded")].status`,name="Succeeded",type=string
24+
// +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"
1927

2028
// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement
2129
// selected resources to specified clusters.
@@ -102,7 +110,7 @@ type ClusterStagedUpdateStrategyList struct {
102110
type StageConfig struct {
103111
// The name of the stage. This MUST be unique within the same StagedUpdateStrategy.
104112
// +kubebuilder:validation:MaxLength=63
105-
// +kubebuilder:validation:Pattern="[A-Za-z0-9]+$"
113+
// +kubebuilder:validation:Pattern="^[a-z0-9]+$"
106114
// +kubebuilder:validation:Required
107115
Name string `json:"name"`
108116

@@ -398,6 +406,10 @@ type ClusterStagedUpdateRunList struct {
398406
// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=careq
399407
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
400408
// +kubebuilder:storageversion
409+
// +kubebuilder:printcolumn:JSONPath=`.spec.parentStageRollout`,name="Update-Run",type=string
410+
// +kubebuilder:printcolumn:JSONPath=`.spec.targetStage`,name="Stage",type=string
411+
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="Approved")].status`,name="Approved",type=string
412+
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
401413

402414
// ClusterApprovalRequest defines a request for user approval for cluster staged update run.
403415
// The request object MUST have the following labels:

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ spec:
1919
singular: clusterapprovalrequest
2020
scope: Cluster
2121
versions:
22-
- name: v1alpha1
22+
- additionalPrinterColumns:
23+
- jsonPath: .spec.parentStageRollout
24+
name: Update-Run
25+
type: string
26+
- jsonPath: .spec.targetStage
27+
name: Stage
28+
type: string
29+
- jsonPath: .status.conditions[?(@.type=="Approved")].status
30+
name: Approved
31+
type: string
32+
- jsonPath: .metadata.creationTimestamp
33+
name: Age
34+
type: date
35+
name: v1alpha1
2336
schema:
2437
openAPIV3Schema:
2538
description: |-
@@ -150,7 +163,20 @@ spec:
150163
storage: false
151164
subresources:
152165
status: {}
153-
- name: v1beta1
166+
- additionalPrinterColumns:
167+
- jsonPath: .spec.parentStageRollout
168+
name: Update-Run
169+
type: string
170+
- jsonPath: .spec.targetStage
171+
name: Stage
172+
type: string
173+
- jsonPath: .status.conditions[?(@.type=="Approved")].status
174+
name: Approved
175+
type: string
176+
- jsonPath: .metadata.creationTimestamp
177+
name: Age
178+
type: date
179+
name: v1beta1
154180
schema:
155181
openAPIV3Schema:
156182
description: |-

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

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,30 @@ spec:
1919
singular: clusterstagedupdaterun
2020
scope: Cluster
2121
versions:
22-
- name: v1alpha1
22+
- additionalPrinterColumns:
23+
- jsonPath: .spec.placementName
24+
name: Placement
25+
type: string
26+
- jsonPath: .spec.resourceSnapshotIndex
27+
name: Resource-Snapshot
28+
type: string
29+
- jsonPath: .status.policySnapshotIndexUsed
30+
name: Policy-Snapshot
31+
type: string
32+
- jsonPath: .status.conditions[?(@.type=="Initialized")].status
33+
name: Initialized
34+
type: string
35+
- jsonPath: .status.conditions[?(@.type=="Succeeded")].status
36+
name: Succeeded
37+
type: string
38+
- jsonPath: .metadata.creationTimestamp
39+
name: Age
40+
type: date
41+
- jsonPath: .spec.stagedRolloutStrategyName
42+
name: Strategy
43+
priority: 1
44+
type: string
45+
name: v1alpha1
2346
schema:
2447
openAPIV3Schema:
2548
description: |-
@@ -861,7 +884,7 @@ spec:
861884
description: The name of the stage. This MUST be unique
862885
within the same StagedUpdateStrategy.
863886
maxLength: 63
864-
pattern: '[A-Za-z0-9]+$'
887+
pattern: ^[a-z0-9]+$
865888
type: string
866889
sortingLabelKey:
867890
description: |-
@@ -1209,11 +1232,37 @@ spec:
12091232
required:
12101233
- spec
12111234
type: object
1235+
x-kubernetes-validations:
1236+
- message: metadata.name max length is 127
1237+
rule: size(self.metadata.name) < 128
12121238
served: true
12131239
storage: false
12141240
subresources:
12151241
status: {}
1216-
- name: v1beta1
1242+
- additionalPrinterColumns:
1243+
- jsonPath: .spec.placementName
1244+
name: Placement
1245+
type: string
1246+
- jsonPath: .spec.resourceSnapshotIndex
1247+
name: Resource-Snapshot
1248+
type: string
1249+
- jsonPath: .status.policySnapshotIndexUsed
1250+
name: Policy-Snapshot
1251+
type: string
1252+
- jsonPath: .status.conditions[?(@.type=="Initialized")].status
1253+
name: Initialized
1254+
type: string
1255+
- jsonPath: .status.conditions[?(@.type=="Succeeded")].status
1256+
name: Succeeded
1257+
type: string
1258+
- jsonPath: .metadata.creationTimestamp
1259+
name: Age
1260+
type: date
1261+
- jsonPath: .spec.stagedRolloutStrategyName
1262+
name: Strategy
1263+
priority: 1
1264+
type: string
1265+
name: v1beta1
12171266
schema:
12181267
openAPIV3Schema:
12191268
description: |-
@@ -2055,7 +2104,7 @@ spec:
20552104
description: The name of the stage. This MUST be unique
20562105
within the same StagedUpdateStrategy.
20572106
maxLength: 63
2058-
pattern: '[A-Za-z0-9]+$'
2107+
pattern: ^[a-z0-9]+$
20592108
type: string
20602109
sortingLabelKey:
20612110
description: |-
@@ -2403,6 +2452,9 @@ spec:
24032452
required:
24042453
- spec
24052454
type: object
2455+
x-kubernetes-validations:
2456+
- message: metadata.name max length is 127
2457+
rule: size(self.metadata.name) < 128
24062458
served: true
24072459
storage: true
24082460
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: |-

examples/stagedupdaterun/approvalRequest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ spec:
1111
targetStage: canary
1212
status:
1313
conditions:
14-
- type: Approved
15-
status: "True"
14+
- type: Approved
15+
status: "True"

0 commit comments

Comments
 (0)