Skip to content

Conversation

jgbernalp
Copy link
Contributor

If a matcher value is changed manually into a regex, do not alter the operator so the query results filter as expected by the user

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 16, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 16, 2023

@jgbernalp: This pull request references LOG-4810 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.15.0" version, but no target version was set.

In response to this:

If a matcher value is changed manually into a regex, do not alter the operator so the query results filter as expected by the user

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.

@jgbernalp
Copy link
Contributor Author

/cherry-pick release-5.8

@openshift-cherrypick-robot

@jgbernalp: once the present PR merges, I will cherry-pick it on top of release-5.8 in a new PR and assign it to you.

In response to this:

/cherry-pick release-5.8

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.

@jgbernalp
Copy link
Contributor Author

/cherry-pick release-5.7

@openshift-cherrypick-robot

@jgbernalp: once the present PR merges, I will cherry-pick it on top of release-5.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-5.7

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.

@openshift-ci openshift-ci bot requested review from kyoto and zhuje November 16, 2023 13:37
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2023
Comment on lines 277 to 279
const testRegex = /\\|\[|\{|\(|\)|\^|\$|\.|\*|\?|\||\+|\/|\]/;
return testRegex.test(value);
Copy link
Member

Choose a reason for hiding this comment

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

This looks like it will return true for a string that contains any one of the special characters (\, [, {, (, ), ^, $, ., *, ?, |, +, /, ]), but don't we need to support exact matching against string values that contain these characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case we are only matching k8s names which exclude these characters as they are DNS names. The only exception is dot '.'. I adjusted the code to consider this case and added some tests and comments for clarity.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation!

If we use a character class (square brackets), I think only the \ and ] need to be escaped. So like [{}()[\]^$*+?|/\\]|\.[*+?], which I think is at least a bit easier to read.

Note that I also added the } character in that regex, which I guess should be included for completeness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thnx I changed the regex with your suggestion and is more readable now

if (isValueARegex(value)) {
return {
label,
operator: '=~',
Copy link
Member

Choose a reason for hiding this comment

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

Nit: How about operator: isValueARegex(value) ? '=~' : '=', to reduce noise and make it clearer that only the operator depends on whether the value is a regex.

Copy link
Member

@kyoto kyoto left a comment

Choose a reason for hiding this comment

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

Just one small suggestion about the regex escaping, but LGTM.

Copy link
Contributor

openshift-ci bot commented Nov 27, 2023

@jgbernalp: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@kyoto
Copy link
Member

kyoto commented Nov 27, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 27, 2023
Copy link
Contributor

openshift-ci bot commented Nov 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jgbernalp, kyoto

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

@openshift-merge-bot openshift-merge-bot bot merged commit 4b39cfb into openshift:main Nov 27, 2023
@openshift-cherrypick-robot

@jgbernalp: new pull request created: #159

In response to this:

/cherry-pick release-5.8

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.

@openshift-cherrypick-robot

@jgbernalp: new pull request created: #160

In response to this:

/cherry-pick release-5.7

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.

Copy link
Contributor

@zhuje zhuje left a comment

Choose a reason for hiding this comment

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

/lgtm

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants