Skip to content

Commit 1466f21

Browse files
committed
crds,udn: Allow NetworkRole Secondary only for Localnet topology
Localnet topology role should secondary only. Move the NetworkRole enum validation from shard.go to each definition that use NetworkRole, having: - Layer2Config & Layer3Config role field accepts: Secondary and Primary. - LocalnetConfig role field accepts: Secondary only. Signed-off-by: Or Mergi <[email protected]>
1 parent 53f0e16 commit 1466f21

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

dist/templates/k8s.ovn.org_clusteruserdefinednetworks.yaml.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ spec:
420420
The network will be assigned to pods that have the `k8s.v1.cni.cncf.io/networks` annotation in place pointing
421421
to subject.
422422
enum:
423-
- Primary
424423
- Secondary
425424
type: string
426425
subnets:

go-controller/pkg/crd/userdefinednetwork/v1/cudn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type LocalnetConfig struct {
9898
// The network will be assigned to pods that have the `k8s.v1.cni.cncf.io/networks` annotation in place pointing
9999
// to subject.
100100
//
101+
// +kubebuilder:validation:Enum=Secondary
101102
// +required
102103
Role NetworkRole `json:"role"`
103104

go-controller/pkg/crd/userdefinednetwork/v1/shared.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Layer3Config struct {
3232
// Primary network is automatically assigned to every pod created in the same namespace.
3333
// Secondary network is only assigned to pods that use `k8s.v1.cni.cncf.io/networks` annotation to select given network.
3434
//
35+
// +kubebuilder:validation:Enum=Primary;Secondary
3536
// +kubebuilder:validation:Required
3637
// +required
3738
Role NetworkRole `json:"role"`
@@ -96,6 +97,7 @@ type Layer2Config struct {
9697
// Allowed value is "Secondary".
9798
// Secondary network is only assigned to pods that use `k8s.v1.cni.cncf.io/networks` annotation to select given network.
9899
//
100+
// +kubebuilder:validation:Enum=Primary;Secondary
99101
// +kubebuilder:validation:Required
100102
// +required
101103
Role NetworkRole `json:"role"`
@@ -165,7 +167,6 @@ const (
165167
IPAMDisabled IPAMMode = "Disabled"
166168
)
167169

168-
// +kubebuilder:validation:Enum=Primary;Secondary
169170
type NetworkRole string
170171

171172
const (

0 commit comments

Comments
 (0)