From 8effbb87d1325e7e934771907878abdb5dc2314b Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Fri, 16 Sep 2022 16:10:39 +0000 Subject: [PATCH] Use string type for VLANID: This allows a default value of "" to be used instead of 0 when the VLANID type is int. As 0 is a valid vlan id, we dont want that to be the default as it would make it impossible for the VLANID to be "unset" and therefore not added to DHCP requests, etc. Signed-off-by: Jacob Weinstock --- config/crd/bases/tinkerbell.org_hardware.yaml | 6 +++++- pkg/apis/core/v1alpha1/hardware_types.go | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/crd/bases/tinkerbell.org_hardware.yaml b/config/crd/bases/tinkerbell.org_hardware.yaml index 11f17c416..3cf890ee9 100644 --- a/config/crd/bases/tinkerbell.org_hardware.yaml +++ b/config/crd/bases/tinkerbell.org_hardware.yaml @@ -121,7 +121,11 @@ spec: uefi: type: boolean vlan_id: - type: integer + description: + validation pattern for VLANDID is a string + number between 0-4096 + pattern: ^(([0-9][0-9]{0,2}|[1-3][0-9][0-9][0-9]|40([0-8][0-9]|9[0-6]))(,[1-9][0-9]{0,2}|[1-3][0-9][0-9][0-9]|40([0-8][0-9]|9[0-6]))*)$ + type: string type: object netboot: description: Netboot configuration. diff --git a/pkg/apis/core/v1alpha1/hardware_types.go b/pkg/apis/core/v1alpha1/hardware_types.go index 98084feac..5f4cf0b92 100644 --- a/pkg/apis/core/v1alpha1/hardware_types.go +++ b/pkg/apis/core/v1alpha1/hardware_types.go @@ -129,7 +129,9 @@ type DHCP struct { UEFI bool `json:"uefi,omitempty"` IfaceName string `json:"iface_name,omitempty"` IP *IP `json:"ip,omitempty"` - VLANID uint `json:"vlan_id,omitempty"` + // validation pattern for VLANDID is a string number between 0-4096 + // +kubebuilder:validation:Pattern="^(([0-9][0-9]{0,2}|[1-3][0-9][0-9][0-9]|40([0-8][0-9]|9[0-6]))(,[1-9][0-9]{0,2}|[1-3][0-9][0-9][0-9]|40([0-8][0-9]|9[0-6]))*)$" + VLANID string `json:"vlan_id,omitempty"` } // IP configuration.