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

Conversation

Shilpa-Gokul
Copy link
Contributor

@Shilpa-Gokul Shilpa-Gokul commented Apr 8, 2024

What this PR does / why we need it:
vpc, vpcSubnets, loadbalancer, cosInstance names doesn't seem to support camelCase, so added kubebuilder tag to validate if it contains only lowercase alphanumeric characters. Added validation to check if transitgateway names supports camelCase.
Validation output is as follows.

cluster.cluster.x-k8s.io/capi-powervs unchanged
The IBMPowerVSCluster "capi-powervs" is invalid:
* spec.transitGateway.name: Invalid value: "capi-powervs-Transitgateway#": spec.transitGateway.name in body should match '^([a-zA-Z]|[a-zA-Z][-_a-zA-Z0-9]*[a-zA-Z0-9])$'
* spec.vpcSubnets[0].name: Too long: may not be longer than 63
* spec.cosInstance.name: Invalid value: "cos-Instance": spec.cosInstance.name in body should match '^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$'
* spec.vpc.name: Invalid value: "capi-Vpc": spec.vpc.name in body should match '^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$'
* spec.loadBalancers[0].name: Invalid value: "capi-Lb": spec.loadBalancers[0].name in body should match '^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$'
shilpagokul@Shilpas-MacBook-Pro cluster-api-provider-ibmcloud %

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1659

Special notes for your reviewer:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 8, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Shilpa-Gokul. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 8, 2024
Copy link

netlify bot commented Apr 8, 2024

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit 4a6868b
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/66163390a0d9c8000829f3d4
😎 Deploy Preview https://deploy-preview-1715--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Karthik-K-N
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 8, 2024
Copy link
Contributor

@Karthik-K-N Karthik-K-N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes LGTM,
If possible it would be great if you can cover other services as well including PowerVS

  1. Workspace name
    2.DHCP Server name
  2. Cos Instance name
    4.Transitgateway name

otherwise we can merge this. After @Prajyot-Parab review.

@Prajyot-Parab
Copy link
Contributor

These changes LGTM, If possible it would be great if you can cover other services as well including PowerVS

  1. Workspace name
    2.DHCP Server name
  2. Cos Instance name
    4.Transitgateway name

otherwise we can merge this. After @Prajyot-Parab review.

@Shilpa-Gokul lets take care of other services as well, as suggested by karthik.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 8, 2024
@Shilpa-Gokul
Copy link
Contributor Author

These changes LGTM, If possible it would be great if you can cover other services as well including PowerVS

  1. Workspace name
    2.DHCP Server name
  2. Cos Instance name
    4.Transitgateway name

otherwise we can merge this. After @Prajyot-Parab review.

@Shilpa-Gokul lets take care of other services as well, as suggested by karthik.

@Karthik-K-N @Prajyot-Parab Done, I have added the check for other services as well, PTAL

@@ -243,6 +245,8 @@ type IBMPowerVSClusterList struct {
// TransitGateway holds the TransitGateway information.
type TransitGateway struct {
// name of resource.
// +kubebuilder:validation:MaxLength:=63
// +kubebuilder:validation:Pattern=`^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually verified from UI this before adding the check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the reference https://cloud.ibm.com/apidocs/transit-gateway#create-transit-gateway, It does support capital letters

@@ -146,6 +146,8 @@ type IBMPowerVSResourceReference struct {

// Name of resource
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength:=63
Copy link
Contributor

@Amulyam24 Amulyam24 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shilpa-Gokul, can you share why pattern validation was added to IBMPowerVSResourceReference? ResourceGroup is of type IBMPowerVSResourceReference and I see that is supports camel case and capital letters in case user specifies it.
Would it maybe be possible to add to the specific resource than adding it here?

@Shilpa-Gokul
Copy link
Contributor Author

Shilpa-Gokul commented Apr 10, 2024

Validations added are as mentioned below

  1. TransitGateway- Length and regex validation added to support camelcase alphanumeric [doc]
  2. vpc, vpcSubnet and Loadbalancers- Length and regex validation added to support lowercase alphanumeric [doc]
  3. cosInstance already has validation in place to allow only lowercase alphanumeric
  4. serviceInstance, Network and DHCPserver supports all. No content found in apidocs on supported values for these services so avoided adding validation

@Karthik-K-N / @Amulyam24 could you please review this once?

@Karthik-K-N
Copy link
Contributor

Thank you
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@Amulyam24
Copy link
Contributor

Amulyam24 commented Apr 11, 2024

Validations added are as mentioned below

  1. TransitGateway- Length and regex validation added to support camelcase alphanumeric [doc]
  2. vpc, vpcSubnet and Loadbalancers- Length and regex validation added to support lowercase alphanumeric [doc]
  3. cosInstance already has validation in place to allow only lowercase alphanumeric
  4. serviceInstance, Network and DHCPserver supports all. No content found in apidocs on supported values for these services so avoided adding validation

@Karthik-K-N / @Amulyam24 could you please review this once?

Thank you for verifying @Shilpa-Gokul!

/lgtm

/cc @Prajyot-Parab

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Prajyot-Parab, Shilpa-Gokul

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit f40ea71 into kubernetes-sigs:main Apr 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attaching listerner to Loadbalancer failed.
5 participants