Skip to content

Commit

Permalink
Update datasource regex match to include dashes and numbers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jesse Pretorius committed May 22, 2018
1 parent 6f4b96c commit cf96865
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tasks/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
# 2. Non-capturing optional group matches for the ${} bits which may, or
# or may not, be there..
# 3. A case-sensitive literal match for DS .
# 4. One or more case-sensitive matches for groups of alphabetical characters
# where each group is preceded by an underscore.
# 4. A one-or-more case-sensitive match for the part that follows the
# underscore, with only A-Z, 0-9 and - or _ allowed.
#
# This regex can be tested and understood better by looking at the
# matches and non-matches in https://regex101.com/r/f4Gkvg/4
# matches and non-matches in https://regex101.com/r/f4Gkvg/6

- name: Set the correct data source name in the dashboard
become: false
replace:
dest: "/tmp/dashboards/{{ item.dashboard_id }}.json"
regexp: '"(?:\${)?DS(_([A-Z])+)+(?:})?"'
regexp: '"(?:\${)?DS_[A-Z0-9_-]+(?:})?"'
replace: '"{{ item.datasource }}"'
delegate_to: localhost
run_once: true
Expand Down

0 comments on commit cf96865

Please sign in to comment.