Skip to content

Commit d89cb15

Browse files
carlydfclaude
andauthored
Fix CEL to actually block deprecated resource create (#313)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed Without `optionalOldSelf: true`, oldSelf is either present (on update) or rule is skipped (on create). We want the rule to be enforced on create! Also, oldSelf != nil doesn't work, must be hasValue() ## Why? To behave as documented and expected after deprecating the old CRDs ## Checklist <!--- add/delete as needed ---> 1. Closes <!-- add issue number here --> 2. How was this tested: In local cluster I tested that you could update an existing object, but that you could not create one. Also tested with the old rule and saw that it did not actually block creation. Note: regardless of the CEL rule, all operations (get, delete, describe, etc) print this warning, which is nice: ``` Warning: TemporalConnection is deprecated. Use Connection instead. ``` 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bc58d64 commit d89cb15

5 files changed

Lines changed: 7 additions & 5 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Image URL to use all building/pushing image targets
22
IMG ?= temporal-worker-controller:latest
33
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
4-
ENVTEST_K8S_VERSION = 1.27.1
4+
ENVTEST_K8S_VERSION = 1.29.0
55

66
MAIN_BRANCH = main
77
ALL_TEST_TAGS = test_dep

api/v1alpha1/deprecated_temporalconnection_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type TemporalConnectionStatus struct {
5151
//+kubebuilder:resource:shortName=tconn
5252
//+kubebuilder:printcolumn:name="Host",type="string",JSONPath=".spec.hostPort",description="Temporal server endpoint"
5353
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
54-
// +kubebuilder:validation:XValidation:rule="oldSelf != null",message="TemporalConnection is deprecated and cannot be created. Use Connection instead."
54+
// +kubebuilder:validation:XValidation:rule="oldSelf.hasValue()",message="TemporalConnection is deprecated and cannot be created. Use Connection instead.",optionalOldSelf=true
5555
// +kubebuilder:deprecatedversion:warning="TemporalConnection is deprecated. Use Connection instead."
5656

5757
// TemporalConnection is the Schema for the temporalconnections API

api/v1alpha1/deprecated_temporalworkerdeployment_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type TemporalWorkerDeploymentStatus struct {
158158
//+kubebuilder:printcolumn:name="Ramp %",type="number",JSONPath=".status.targetVersion.rampPercentage",description="Ramp percentage"
159159
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
160160
// +kubebuilder:validation:XValidation:rule="size(self.metadata.name) <= 63",message="name cannot be more than 63 characters"
161-
// +kubebuilder:validation:XValidation:rule="oldSelf != null",message="TemporalWorkerDeployment is deprecated and cannot be created. Use WorkerDeployment instead."
161+
// +kubebuilder:validation:XValidation:rule="oldSelf.hasValue()",message="TemporalWorkerDeployment is deprecated and cannot be created. Use WorkerDeployment instead.",optionalOldSelf=true
162162
// +kubebuilder:deprecatedversion:warning="TemporalWorkerDeployment is deprecated. Use WorkerDeployment instead."
163163

164164
// TemporalWorkerDeployment is the Schema for the temporalworkerdeployments API

helm/temporal-worker-controller-crds/templates/temporal.io_temporalconnections.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ spec:
115115
x-kubernetes-validations:
116116
- message: TemporalConnection is deprecated and cannot be created. Use Connection
117117
instead.
118-
rule: oldSelf != null
118+
optionalOldSelf: true
119+
rule: oldSelf.hasValue()
119120
served: true
120121
storage: true
121122
subresources:

helm/temporal-worker-controller-crds/templates/temporal.io_temporalworkerdeployments.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4216,7 +4216,8 @@ spec:
42164216
rule: size(self.metadata.name) <= 63
42174217
- message: TemporalWorkerDeployment is deprecated and cannot be created. Use
42184218
WorkerDeployment instead.
4219-
rule: oldSelf != null
4219+
optionalOldSelf: true
4220+
rule: oldSelf.hasValue()
42204221
served: true
42214222
storage: true
42224223
subresources:

0 commit comments

Comments
 (0)