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

Workspace additions #287

Merged
merged 9 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Unreleased 0.24.1

ENANCEMENTS:
ENHANCEMENTS:
* Use Go 1.16 to provide support for Apple Silicon (darwin/arm64).
* d/tfe_workspace: Added new fields from the API ([#287](https://github.com/hashicorp/terraform-provider-tfe/pull/287))

## 0.24.0 (January 22, 2021)

Expand Down Expand Up @@ -85,7 +86,7 @@ ENHANCEMENTS:
* r/tfe_policy_set: Added a validation for the `name` attribute so that invalid policy set names are caught at plan time ([#168](https://github.com/hashicorp/terraform-provider-tfe/pull/168))

NOTES:
* This validation matches the requirements specified by the [Terraform Cloud API](https://www.terraform.io/docs/cloud/api/policy-sets.html#request-body). Policy set names can only include letters, numbers, -, and _.
* This validation matches the requirements specified by the [Terraform Cloud API](https://www.terraform.io/docs/cloud/api/policy-sets.html#request-body). Policy set names can only include letters, numbers, -, and \_.

## 0.20.0 (July 17, 2020)

Expand Down
24 changes: 24 additions & 0 deletions tfe/data_source_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ func dataSourceTFEWorkspace() *schema.Resource {
},
},

"resource_count": {
Type: schema.TypeInt,
Computed: true,
},

"policy_check_failures": {
Type: schema.TypeInt,
Computed: true,
},

"run_failures": {
Type: schema.TypeInt,
Computed: true,
},

"runs_count": {
Type: schema.TypeInt,
Computed: true,
},

"external_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -133,6 +153,10 @@ func dataSourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error
d.Set("terraform_version", workspace.TerraformVersion)
d.Set("trigger_prefixes", workspace.TriggerPrefixes)
d.Set("working_directory", workspace.WorkingDirectory)
d.Set("resource_count", workspace.ResourceCount)
d.Set("policy_check_failures", workspace.PolicyCheckFailures)
d.Set("run_failures", workspace.RunFailures)
d.Set("runs_count", workspace.RunsCount)
// TODO: remove when external_id is removed
d.Set("external_id", workspace.ID)

Expand Down
4 changes: 4 additions & 0 deletions tfe/data_source_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func TestAccTFEWorkspaceDataSource_basic(t *testing.T) {
"data.tfe_workspace.foobar", "working_directory", "terraform/test"),

resource.TestCheckResourceAttrSet("data.tfe_workspace.foobar", "external_id"),
resource.TestCheckResourceAttr("data.tfe_workspace.foobar", "resource_count", "0"),
resource.TestCheckResourceAttr("data.tfe_workspace.foobar", "policy_check_failures", "0"),
resource.TestCheckResourceAttr("data.tfe_workspace.foobar", "run_failures", "0"),
resource.TestCheckResourceAttr("data.tfe_workspace.foobar", "runs_count", "0"),
),
},
},
Expand Down
5 changes: 5 additions & 0 deletions website/docs/d/workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ In addition to all arguments above, the following attributes are exported:
* `trigger_prefixes` - List of repository-root-relative paths which describe all locations to be tracked for changes.
* `vcs_repo` - Settings for the workspace's VCS repository.
* `working_directory` - A relative path that Terraform will execute within.
* `resource_count` - The number of resources managed by the workspace.
* `policy_check_failures` - The number of policy check failures from the latest run.
* `run_failures` - The number of run failures on the workspace.
* `runs_count` - The number of runs on the workspace.


The `vcs_repo` block contains:

Expand Down