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

fix:port name cant have consecutive hyphens #3976

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhaohuiweixiao
Copy link
Contributor

Signed-off-by: zhaohuihui zhaohuihui_yewu@cmss.chinamobile.com

What type of PR is this?

/kind bug

What this PR does / why we need it:

the port name can not have consecutive hyphens in k8s.
portnameconsecutivepng

Special notes for reviewers:

/assign harrisonliu5

Does this PR introduced a user-facing change?

fix: port name add consecutive hyphens validation

@ks-ci-bot ks-ci-bot added release-note kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 14, 2022
@ks-ci-bot
Copy link
Collaborator

Hi @zhaohuiweixiao. Thanks for your PR.

I'm waiting for a kubesphere 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.

src/utils/constants.js Fixed Show fixed Hide fixed
Signed-off-by: zhaohuihui <zhaohuihui_yewu@cmss.chinamobile.com>
@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zhaohuiweixiao
To complete the pull request process, please ask for approval from harrisonliu5 after the PR has been reviewed.

The full list of commands accepted by this bot can be found 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

@@ -592,7 +592,7 @@
export const PATTERN_TAG = /^[A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])?$/
export const PATTERN_PASSWORD = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,64}$/
export const PATTERN_IMAGE = /^\S+$/
export const PATTERN_PORT_NAME = /^[a-z]([-a-z0-9]*[a-z0-9])?$/
export const PATTERN_PORT_NAME = /^[a-z](?:-?[a-z0-9]+)*$/

Check failure

Code scanning / CodeQL

Inefficient regular expression

This part of the regular expression may cause exponential backtracking on strings starting with 'a' and containing many repetitions of '0'.
@zhaohuiweixiao
Copy link
Contributor Author

How can I verify that my expression is efficient offline? i test the regular express no problem on https://regex101.com/.
@harrisonliu5 @patrickluoyu

@harrisonliu5
Copy link
Collaborator

This part of the regular expression may cause exponential backtracking on strings starting with 'a' and containing many repetitions of '0'.

you should resolve this error first.

@@ -35,7 +35,7 @@ module.exports = {
ENVIRONMENT_INVALID_TIP: 'The key of an environment variable can contain only letters, numbers, underscores (_), hyphens (-), and periods (.), and must not start with a number.',
ENVIRONMENT_CANNOT_BE_EMPTY: 'Please set a key for the environment variable.',
// List > Create > Pod Settings > Port Settings
WORKLOAD_PORT_NAME_DESC: 'The port name can contain only lowercase letters, numbers and hyphens (-), and must start with a lowercase letter and end with a lowercase letter or number. The maximum length is 15 characters.',
WORKLOAD_PORT_NAME_DESC: 'The port name can contain only lowercase letters, numbers and hyphens (-), and must start with a lowercase letter and end with a lowercase letter or number, and cannot have consecutive hyphens. The maximum length is 15 characters.',
Copy link
Contributor

Choose a reason for hiding this comment

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

The port name can contain only lowercase letters, numbers and hyphens (-), and must start with a lowercase letter and end with a lowercase letter or number. Avoid using consecutive hyphens. The maximum length is 15 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test release-note size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants