go-tfe
go-tfe copied to clipboard
Add workspace list filter by current run status
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