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

datalist: add all and match_by attributes to filter blocks #491

Merged
merged 8 commits into from
Sep 28, 2020

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Sep 22, 2020

Several improvements to the datalist library used by some of the data sources in this provider:

  • Adds an all attribute to filter blocks. When set to true (i.e., all = true), a filter block will only match if all of the values match the given field. This is useful when matching against multi-valued fields (e.g., lists and sets).

  • Adds a match_by attribute to filter blocks to allow string-matching to use regular expressions and substring matches. Set match_by = "re" for regular expression matching and match_by = "substring" for substring matching. This makes add digitalocean_domains data source #484 actually useful because domains can then be matched by regular expressions.

  • Also refactors the filter support so that values are parsed once and not when filter blocks are applied.

Caveats:

  • The docs still need updating.

  • Is substring matching redundant with regular expression matching? I kept it in because it could be faster but maybe not worth it given regular expression matching can accomplish the same result.

Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

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

👍 Great stuff! This is really useful.

Is substring matching redundant with regular expression matching? I kept it in because it could be faster but maybe not worth it given regular expression matching can accomplish the same result.

As it's already there, I think it's worth keeping it around. Some people find regex intimidating and for simple uses-cases it's less to think about.

website/docs/d/sizes.html.md Outdated Show resolved Hide resolved
website/docs/d/spaces_buckets.html.md Outdated Show resolved Hide resolved
tdyas and others added 2 commits September 28, 2020 09:02
Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
@tdyas
Copy link
Contributor Author

tdyas commented Sep 28, 2020

Okay, I made the suggested edits again.

@andrewsomething andrewsomething merged commit c932c35 into digitalocean:master Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants