Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lowercase regex validation for vpc, vpcsubnet and loadbalancer names #1715

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -382,9 +382,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