Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

extending regex to match multiple subsequent words in datasource placeholder #53

Merged

Conversation

aman0019
Copy link

It was discovered that some grafana dashboards use a datasource
placeholder which is slightly more complex than what the regex
currently supports. As such we are extending the regex to
allow more than just one word following the "DS_" prefix.
We do this by following the following rules:

  • Literal boundaries for " on either side of the match.
  • Non-capturing optional group matches for the ${} bits which may, or
    may not, be there..
  • A case-sensitive literal match for DS .
  • One or more case-sensitive matches for groups of alphabetical characters
    where each group is preceded by an underscore.

Copy link
Collaborator

@odyssey4me odyssey4me left a comment

Choose a reason for hiding this comment

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

LGTM

# 4. A one-or-more case-sensitive match for the part that follows the
# underscore, with no characters allowed except alphabetical.
# 3. A case-sensitive literal match for DS .
# 4. One or more case-sensitive matches for groups of alphabetical characters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the trailing whitespace here.

Copy link
Collaborator

@odyssey4me odyssey4me left a comment

Choose a reason for hiding this comment

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

Remove the trailing whitespace and the test should pass. Otherwise this LGTM.

Copy link
Collaborator

@odyssey4me odyssey4me left a comment

Choose a reason for hiding this comment

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

Given the two commits are a single change, could you squash and force push up. With that done I think we're good to go here.

placeholder which is slightly more complex than what the regex
currently supports. As such we are extending the regex to
allow more than just one word following the "DS_" prefix.
We do this by following the following rules:

- Literal boundaries for " on either side of the match.
- Non-capturing optional group matches for the ${} bits which may, or
    may not, be there..
- A case-sensitive literal match for DS .
- One or more case-sensitive matches for groups of alphabetical characters
    where each group is preceded by an underscore.
@aman0019 aman0019 force-pushed the extend-dashboard-regex-patterns branch from 5fd90d7 to 23f78f5 Compare April 26, 2018 12:41
Copy link
Member

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

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

LGTM

@odyssey4me odyssey4me merged commit 57a102c into cloudalchemy:master Apr 27, 2018
@aman0019 aman0019 deleted the extend-dashboard-regex-patterns branch April 27, 2018 09:06
@aman0019
Copy link
Author

thanks :)

odyssey4me pushed a commit to odyssey4me/ansible-grafana that referenced this pull request May 22, 2018
In order to match datasources like "DS_DML-PROM0" which include dashes
and numbers, we open the match to include them. We also remove the
capture groups implemented in [1] as they're not required and their
inclusion makes things more difficult to understand. Instead, we provide
the same function by simply also allowing underscores in the match.

[1] cloudalchemy#53
odyssey4me pushed a commit to odyssey4me/ansible-grafana that referenced this pull request May 22, 2018
In order to match datasources like "DS_DML-PROM0" which include dashes
and numbers, we open the match to include them. We also remove the
capture groups implemented in [1] as they're not required and their
inclusion makes things more difficult to understand. Instead, we provide
the same function by simply also allowing underscores in the match.

[1] cloudalchemy#53

Fixes cloudalchemy#59
@lock
Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants