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
Add exclude_tags to data_source_workspace_ids #523
Conversation
b1ae554
to
71302cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, unfortunately, some versions of TFE that we support will not have the "exclude_tags" field for awhile, so we have to provide a fallback as well. That means excluding workspaces if they contain excluded tags when building up the list of ids.
My feedback was addressed but I didn't have a chance to smoke test this PR
I reached out to @sudomateo about testing this PR with the last TFE. Maybe we could do that tomorrow? cc @sebasslash |
7075dce
to
f0730fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smoke tested ✅ Overall code changes look 🔥 with some really minor things below ⬇️
tfe/data_source_workspace_ids.go
Outdated
@@ -26,6 +26,12 @@ func dataSourceTFEWorkspaceIDs() *schema.Resource { | |||
Optional: true, | |||
}, | |||
|
|||
"exclude_tags": { | |||
Type: schema.TypeList, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exclude_tags
should be Type: schema.TypeSet
since the order of the tags to exclude does not matter.
// Create a search string with all the tag names we are looking for. | ||
var tagSearchParts []string | ||
for _, tagName := range d.Get("tag_names").([]interface{}) { | ||
name := tagName.(string) | ||
if len(strings.TrimSpace(name)) != 0 { | ||
if name, ok := tagName.(string); ok && len(strings.TrimSpace(name)) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
|
||
data "tfe_workspace_ids" "good" { | ||
tag_names = ["good"] | ||
exclude_tags = ["happy"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's some extra spaces here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f0730fa
to
631f35f
Compare
bf5e957
to
5e0f62a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕺
Description
Currently the list of Workspaces within an Organization can be filtered with
tag_names
to include. This PR adds the ability to exclude workspaces by tags using theexclude_tags
parameter.See usecase here: #393
Remember to:
Update the Change Log
Update the Documentation
Testing plan
exclude_tags
options, should list all matching workspaces excluding those with the excluded tags.External links
Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.
Output from acceptance tests
Please run applicable acceptance tests locally and include the output here. See TESTS.md to learn how to run acceptance tests.
If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.