Commit fc172a9
authored
fix: missing immutable setup under type_def (#649)
This PR fixes an issue where the `is_immutable` configuration was not being applied to nested fields (e.g. `HealthCheckConfig.Type`).
Verified using `route53-controller`. The generator now correctly applies validation markers to immutable nested fields in `HealthCheckConfig`, resulting in the correct `x-kubernetes-validations` in the output CRD.
```diff
diff --git a/apis/v1alpha1/types.go b/apis/v1alpha1/types.go
index afc17d0..e25f221 100644
--- a/apis/v1alpha1/types.go
+++ b/apis/v1alpha1/types.go
@@ -148,14 +148,18 @@ type HealthCheckConfig struct {
IPAddress *string `json:"ipAddress,omitempty"`
InsufficientDataHealthStatus *string `json:"insufficientDataHealthStatus,omitempty"`
Inverted *bool `json:"inverted,omitempty"`
- MeasureLatency *bool `json:"measureLatency,omitempty"`
- Port *int64 `json:"port,omitempty"`
- Regions []*string `json:"regions,omitempty"`
- RequestInterval *int64 `json:"requestInterval,omitempty"`
- ResourcePath *string `json:"resourcePath,omitempty"`
- RoutingControlARN *string `json:"routingControlARN,omitempty"`
- SearchString *string `json:"searchString,omitempty"`
- Type *string `json:"type,omitempty"`
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+ MeasureLatency *bool `json:"measureLatency,omitempty"`
+ Port *int64 `json:"port,omitempty"`
+ Regions []*string `json:"regions,omitempty"`
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+ RequestInterval *int64 `json:"requestInterval,omitempty"`
+ ResourcePath *string `json:"resourcePath,omitempty"`
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+ RoutingControlARN *string `json:"routingControlARN,omitempty"`
+ SearchString *string `json:"searchString,omitempty"`
+ // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable once set"
+ Type *string `json:"type,omitempty"`
}
// A complex type that contains the last failure reason as reported by one Amazon
diff --git a/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml b/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
index ea5e040..d55c176 100644
--- a/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
+++ b/config/crd/bases/route53.services.k8s.aws_healthchecks.yaml
@@ -82,6 +82,9 @@ spec:
type: string
measureLatency:
type: boolean
+ x-kubernetes-validations:
+ - message: Value is immutable once set
+ rule: self == oldSelf
port:
format: int64
type: integer
@@ -92,14 +95,23 @@ spec:
requestInterval:
format: int64
type: integer
+ x-kubernetes-validations:
+ - message: Value is immutable once set
+ rule: self == oldSelf
resourcePath:
type: string
routingControlARN:
type: string
+ x-kubernetes-validations:
+ - message: Value is immutable once set
+ rule: self == oldSelf
searchString:
type: string
type:
type: string
+ x-kubernetes-validations:
+ - message: Value is immutable once set
+ rule: self == oldSelf
type: object
tags:
description: |-
```
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.1 parent e743d68 commit fc172a9
3 files changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
544 | 547 | | |
545 | 548 | | |
546 | 549 | | |
| |||
674 | 677 | | |
675 | 678 | | |
676 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
677 | 689 | | |
678 | 690 | | |
679 | 691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
0 commit comments