Skip to content

Commit

Permalink
Add lowercase regex validation for vpc, vpcsubnet and loadbalancer na…
Browse files Browse the repository at this point in the history
…mes (#1715)

* Add lowercase regex validation for vpc, vpcsubnet and loadbalancer names

* Add validation for dhcp, serviceinstance, cos and transitgateway

* Revert the regex validation for tg,serviceinstance etc
  • Loading branch information
Shilpa-Gokul committed Apr 11, 2024
1 parent 537e648 commit f40ea71
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 3 deletions.
7 changes: 7 additions & 0 deletions api/v1beta2/ibmpowervscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ type IBMPowerVSClusterList struct {
// TransitGateway holds the TransitGateway information.
type TransitGateway struct {
// name of resource.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^([a-zA-Z]|[a-zA-Z][-_a-zA-Z0-9]*[a-zA-Z0-9])$`
// +optional
Name *string `json:"name,omitempty"`
// id of resource.
Expand All @@ -256,11 +259,15 @@ type TransitGateway struct {
type VPCResourceReference struct {
// id of resource.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=64
// +kubebuilder:validation:Pattern=`^[-0-9a-z_]+$`
// +optional
ID *string `json:"id,omitempty"`

// name of resource.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
// +optional
Name *string `json:"name,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions api/v1beta2/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ type IBMVPCClusterSpec struct {
// VPCLoadBalancerSpec defines the desired state of an VPC load balancer.
type VPCLoadBalancerSpec struct {
// Name sets the name of the VPC load balancer.
// +kubebuilder:validation:MinLength:=1
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
// +optional
Name string `json:"name,omitempty"`

// id of the loadbalancer
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=64
// +kubebuilder:validation:Pattern=`^[-0-9a-z_]+$`
// +optional
ID *string `json:"id,omitempty"`

Expand Down
12 changes: 9 additions & 3 deletions api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,15 @@ type SecurityGroupRulePrototype struct {
// Subnet describes a subnet.
type Subnet struct {
Ipv4CidrBlock *string `json:"cidr,omitempty"`
Name *string `json:"name,omitempty"`
ID *string `json:"id,omitempty"`
Zone *string `json:"zone,omitempty"`
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
Name *string `json:"name,omitempty"`
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=64
// +kubebuilder:validation:Pattern=`^[-0-9a-z_]+$`
ID *string `json:"id,omitempty"`
Zone *string `json:"zone,omitempty"`
}

// VPCEndpoint describes a VPCEndpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,15 @@ spec:
x-kubernetes-list-type: map
id:
description: id of the loadbalancer
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: Name sets the name of the VPC load balancer.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
public:
default: true
Expand Down Expand Up @@ -396,6 +401,9 @@ spec:
type: string
name:
description: name of resource.
maxLength: 63
minLength: 1
pattern: ^([a-zA-Z]|[a-zA-Z][-_a-zA-Z0-9]*[a-zA-Z0-9])$
type: string
type: object
vpc:
Expand All @@ -409,11 +417,15 @@ spec:
properties:
id:
description: id of resource.
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: name of resource.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
region:
description: |-
Expand All @@ -437,8 +449,14 @@ spec:
cidr:
type: string
id:
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
zone:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,15 @@ spec:
x-kubernetes-list-type: map
id:
description: id of the loadbalancer
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: Name sets the name of the VPC load balancer.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
public:
default: true
Expand Down Expand Up @@ -427,6 +432,9 @@ spec:
type: string
name:
description: name of resource.
maxLength: 63
minLength: 1
pattern: ^([a-zA-Z]|[a-zA-Z][-_a-zA-Z0-9]*[a-zA-Z0-9])$
type: string
type: object
vpc:
Expand All @@ -440,11 +448,15 @@ spec:
properties:
id:
description: id of resource.
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: name of resource.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
region:
description: |-
Expand All @@ -468,8 +480,14 @@ spec:
cidr:
type: string
id:
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
zone:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,15 @@ spec:
x-kubernetes-list-type: map
id:
description: id of the loadbalancer
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: Name sets the name of the VPC load balancer.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
public:
default: true
Expand Down Expand Up @@ -364,8 +369,14 @@ spec:
cidr:
type: string
id:
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
zone:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,15 @@ spec:
x-kubernetes-list-type: map
id:
description: id of the loadbalancer
maxLength: 64
minLength: 1
pattern: ^[-0-9a-z_]+$
type: string
name:
description: Name sets the name of the VPC load balancer.
maxLength: 63
minLength: 1
pattern: ^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$
type: string
public:
default: true
Expand Down

0 comments on commit f40ea71

Please sign in to comment.