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 filtering option to list workspaces of a particular project #671

Merged

Conversation

hs26gill
Copy link
Contributor

Description

This add the support for users to list all the workspaces associated to a particular project in an organization by providing project_id filter option. API docs: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#list-workspaces

Testing plan

Integration tests have been added to cover this. You can run them using the below command:

go test -run TestWorkspacesList  -v ./... -tags=integration

External links

@hs26gill hs26gill requested a review from a team as a code owner March 30, 2023 17:35
@hs26gill hs26gill force-pushed the hs26gill/TF-5351-add-filter-by-project-id-for-listing-workspaces branch from a8272c4 to 3e8876c Compare March 30, 2023 17:41
@hs26gill hs26gill force-pushed the hs26gill/TF-5351-add-filter-by-project-id-for-listing-workspaces branch from 3e8876c to b30078d Compare March 30, 2023 17:46
Copy link
Member

@nfagerlund nfagerlund left a comment

Choose a reason for hiding this comment

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

Nice and straightforward! I did some interactive testing on it and it works perfectly. 🙌🏼

I'd like a tiny bit more robustness in the tests, and there's one glitchy comment needs removing; otherwise this is good.

@hs26gill hs26gill force-pushed the hs26gill/TF-5351-add-filter-by-project-id-for-listing-workspaces branch from 27120cb to 1b01657 Compare March 30, 2023 20:04
nfagerlund
nfagerlund previously approved these changes Mar 30, 2023
Copy link
Member

@nfagerlund nfagerlund left a comment

Choose a reason for hiding this comment

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

Thank you, sorry I got confused about the test setup 😅

One of these tests was flaking on this PR, probably because it was tacitly
expecting that fewer than 20 workspaces ever exist at once on the CI TFC
instance. The more tests we add that create temporary workspaces (like the ones
in this PR), the more likely that test was to flake.

Testing shared global state is always nasty and error-prone, but this commit
adjusts a couple tests to make less precise assertions that hopefully still test
the behavior of interest.
@hs26gill hs26gill merged commit e330540 into main Mar 31, 2023
@hs26gill hs26gill deleted the hs26gill/TF-5351-add-filter-by-project-id-for-listing-workspaces branch March 31, 2023 17:58
@github-actions
Copy link

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 CHANGELOG.md with a note on your changes.

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.

3 participants