Skip to content

Commit c1268c5

Browse files
committed
feat: make extensionIPRange field immutable
1 parent 423a1c7 commit c1268c5

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

crd/overlayextensionconfig/api/v1alpha1/overlayextensionconfig_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ type OverlayExtensionConfigList struct {
3131
}
3232

3333
// OverlayExtensionConfigSpec defines the desired state of OverlayExtensionConfig.
34+
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.extensionIPRange) || has(self.extensionIPRange)", message="ExtensionIPRange is required once set"
3435
type OverlayExtensionConfigSpec struct {
3536
// ExtensionIPRange field defines a CIDR that should be able to reach routing domain ip addresses.
3637
// +kubebuilder:validation:Optional
38+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
39+
// +kubebuilder:validation:MaxLength=43
40+
// 43 is max length of IPv6 CIDR string
3741
ExtensionIPRange string `json:"extensionIPRange,omitempty"`
3842
}
3943

crd/overlayextensionconfig/manifests/acn.azure.com_overlayextensionconfigs.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.3
6+
controller-gen.kubebuilder.io/version: v0.13.0
77
name: overlayextensionconfigs.acn.azure.com
88
spec:
99
group: acn.azure.com
@@ -28,19 +28,14 @@ spec:
2828
API
2929
properties:
3030
apiVersion:
31-
description: |-
32-
APIVersion defines the versioned schema of this representation of an object.
33-
Servers should convert recognized schemas to the latest internal value, and
34-
may reject unrecognized values.
35-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
31+
description: 'APIVersion defines the versioned schema of this representation
32+
of an object. Servers should convert recognized schemas to the latest
33+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
3634
type: string
3735
kind:
38-
description: |-
39-
Kind is a string value representing the REST resource this object represents.
40-
Servers may infer this from the endpoint the client submits requests to.
41-
Cannot be updated.
42-
In CamelCase.
43-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
description: 'Kind is a string value representing the REST resource this
37+
object represents. Servers may infer this from the endpoint the client
38+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
4439
type: string
4540
metadata:
4641
type: object
@@ -49,9 +44,17 @@ spec:
4944
properties:
5045
extensionIPRange:
5146
description: ExtensionIPRange field defines a CIDR that should be
52-
able to reach routing domain ip addresses.
47+
able to reach routing domain ip addresses. 43 is max length of IPv6
48+
CIDR string
49+
maxLength: 43
5350
type: string
51+
x-kubernetes-validations:
52+
- message: Value is immutable
53+
rule: self == oldSelf
5454
type: object
55+
x-kubernetes-validations:
56+
- message: ExtensionIPRange is required once set
57+
rule: '!has(oldSelf.extensionIPRange) || has(self.extensionIPRange)'
5558
status:
5659
description: OverlayExtensionConfigStatus defines the observed state of
5760
OverlayExtensionConfig

0 commit comments

Comments
 (0)