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

add exclude tags to workspace list options #438

merged 1 commit into from Jun 29, 2022


Copy link

@Uk1288 Uk1288 commented Jun 20, 2022


Currently the list of Workspaces within an Organization can be filtered with Tags string to include. This PR adds the ability to exclude workspaces by tags using the ExcludeTags option.

For example, given workspace1 with tag one and workspace2 with tag two, invoking

client.Workspaces.List(ctx, orgName, &WorkspaceListOptions{
			ExcludeTags: "two",

should only return workspace1.

Testing plan

  • Create an organization
  • Create workspaces with tags in that organization
  • List workspaces using the ExcludeTags options, should list all workspaces excluding ones with the excluded tags.

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" TF_ACC="1" go test ./... -v -tags=integration -run TestWorkspacesList

=== RUN   TestWorkspacesList
=== RUN   TestWorkspacesList/without_list_options
=== RUN   TestWorkspacesList/with_list_options
=== RUN   TestWorkspacesList/when_searching_a_known_workspace
=== RUN   TestWorkspacesList/when_searching_using_a_tag
=== RUN   TestWorkspacesList/when_searching_using_exclude-tags
=== RUN   TestWorkspacesList/when_searching_an_unknown_workspace
=== RUN   TestWorkspacesList/without_a_valid_organization
=== RUN   TestWorkspacesList/with_organization_included
=== RUN   TestWorkspacesList/with_current-state-version,current-run_included
--- PASS: TestWorkspacesList (80.58s)
    --- PASS: TestWorkspacesList/without_list_options (0.29s)
    --- PASS: TestWorkspacesList/with_list_options (0.22s)
    --- PASS: TestWorkspacesList/when_searching_a_known_workspace (0.25s)
    --- PASS: TestWorkspacesList/when_searching_using_a_tag (0.55s)
    --- PASS: TestWorkspacesList/when_searching_using_exclude-tags (0.70s)
    --- PASS: TestWorkspacesList/when_searching_an_unknown_workspace (0.23s)
    --- PASS: TestWorkspacesList/without_a_valid_organization (0.00s)
    --- PASS: TestWorkspacesList/with_organization_included (0.33s)
    --- PASS: TestWorkspacesList/with_current-state-version,current-run_included (75.02s)

Copy link

@annawinkler annawinkler left a comment

🌟 Thanks for opening this PR! It looks like you need to complete the contributor agreement for this repo. I took a quick look at the test failures, and one might be failing because of this change. Maybe take a look?

sebasslash previously approved these changes Jun 22, 2022
Copy link

@sebasslash sebasslash left a comment

Tests are failing since it's not available in tflocal yet. Code changes look good to me 🔥

brandonc previously approved these changes Jun 23, 2022
Copy link

@brandonc brandonc left a comment

👍 once API & docs are merged

@Uk1288 Uk1288 dismissed stale reviews from brandonc and sebasslash via 5ff2232 Jun 24, 2022
@Uk1288 Uk1288 force-pushed the uk1288-add-exclude-tags-to-workspace-list-options branch from 8a4ff98 to 5ff2232 Compare Jun 24, 2022
Copy link

@sebasslash sebasslash left a comment

Woohoo! 🔥

@Uk1288 Uk1288 merged commit efab77c into main Jun 29, 2022
6 checks passed
@Uk1288 Uk1288 deleted the uk1288-add-exclude-tags-to-workspace-list-options branch Jun 29, 2022
Copy link

github-actions bot commented Jun 29, 2022

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants