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 workspace list filter by current run status #899

Merged
merged 6 commits into from
Jun 4, 2024

Conversation

arybolovlev
Copy link
Contributor

Description

This PR adds a new filter option CurrentRunStatus to WorkspaceListOptions, allowing a list of Workspaces to be filtered by current run status.

Here is an example of listing workspaces with the current run status set to planned.

$ curl -s \
  --header "Authorization: Bearer $TFE_TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request GET \
"https://app.terraform.io/api/v2/organizations/XXX/workspaces?filter%5Bcurrent-run%5D%5Bstatus%5D=planned"

If this change is accepted, then I will raise a new PR to update the docs: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#query-parameters.

Testing plan

N/A.

External links

N/A.

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://app.terraform.io/" TFE_TOKEN="X.atlasv1.X" go test ./... -v -run TestWorkspacesList
...
--- PASS: TestWorkspacesList (69.91s)
    --- PASS: TestWorkspacesList/without_list_options (0.21s)
    --- PASS: TestWorkspacesList/with_list_options (0.43s)
    --- PASS: TestWorkspacesList/when_sorting_by_workspace_names (0.34s)
    --- PASS: TestWorkspacesList/when_sorting_workspaces_on_current-run.created-at (26.03s)
    --- PASS: TestWorkspacesList/when_searching_a_known_workspace (0.20s)
    --- PASS: TestWorkspacesList/when_searching_using_a_tag (0.47s)
    --- PASS: TestWorkspacesList/when_searching_using_exclude-tags (0.73s)
    --- PASS: TestWorkspacesList/when_searching_an_unknown_workspace (0.17s)
    --- PASS: TestWorkspacesList/without_a_valid_organization (0.00s)
    --- PASS: TestWorkspacesList/with_organization_included (0.45s)
    --- PASS: TestWorkspacesList/with_current-state-version,current-run_included (18.81s)
    --- PASS: TestWorkspacesList/when_searching_a_known_substring (0.59s)
    --- PASS: TestWorkspacesList/when_wildcard_match_does_not_exist (0.57s)
    --- PASS: TestWorkspacesList/when_using_project_id_filter_and_project_contains_workspaces (1.12s)
    --- PASS: TestWorkspacesList/when_using_project_id_filter_but_project_contains_no_workspaces (0.46s)
    --- PASS: TestWorkspacesList/when_filter_workspaces_by_current_run_status (12.65s)
PASS
ok  	github.com/hashicorp/go-tfe	70.207s

@arybolovlev arybolovlev changed the title Add workspace list filter current run Add workspace list filter by current run status May 13, 2024
@arybolovlev arybolovlev marked this pull request as ready for review May 13, 2024 13:01
@arybolovlev arybolovlev requested a review from a team as a code owner May 13, 2024 13:01
Uk1288
Uk1288 previously approved these changes May 13, 2024
Copy link
Contributor

@Uk1288 Uk1288 left a comment

Choose a reason for hiding this comment

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

Works as expected, looks good to me 🎉

@arybolovlev arybolovlev force-pushed the add-workspace-list-filter-current-run branch from efc01cc to bf3fd29 Compare May 23, 2024 11:14
Uk1288
Uk1288 previously approved these changes May 28, 2024
@arybolovlev arybolovlev force-pushed the add-workspace-list-filter-current-run branch 3 times, most recently from 4c3f906 to 1198074 Compare June 3, 2024 14:12
Uk1288
Uk1288 previously approved these changes Jun 3, 2024
@arybolovlev arybolovlev force-pushed the add-workspace-list-filter-current-run branch from 1198074 to 182db79 Compare June 3, 2024 14:53
@arybolovlev arybolovlev force-pushed the add-workspace-list-filter-current-run branch from 182db79 to 6e68b63 Compare June 3, 2024 14:55
@arybolovlev arybolovlev merged commit 77cd185 into main Jun 4, 2024
7 checks passed
@arybolovlev arybolovlev deleted the add-workspace-list-filter-current-run branch June 4, 2024 06:53
Copy link

github-actions bot commented Jun 4, 2024

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.

2 participants