Skip to content

Commit

Permalink
Add aggregated_commit_status_enabled attribute to org resource and…
Browse files Browse the repository at this point in the history
… data blocks (#1169)
  • Loading branch information
mjyocca authored Feb 2, 2024
1 parent b6edd1b commit e5854c7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ FEATURES:
* **New Resource**: `r/tfe_sentinel_version` adds the ability for admins to configure settings for sentinel versions ([#1202](https://github.com/hashicorp/terraform-provider-tfe/pull/1202))
* **New Resource**: `r/tfe_opa_version` adds the ability for admins to configure settings for OPA versions ([#1202](https://github.com/hashicorp/terraform-provider-tfe/pull/1202))
* `r/tfe_policy_set`: Add `agent_enabled` and `policy_tool_version` attributes to allow setting a policy runtime version to the policy set, by @mrinalirao [1234](https://github.com/hashicorp/terraform-provider-tfe/pull/1234)
* `d/tfe_policy_set`: Add `agent_enabled` and `policy_tool_version` attributes to get the policy runtime version of a policy set, by @mrinalirao [1234](https://github.com/hashicorp/terraform-provider-tfe/pull/1234)
* `d/tfe_policy_set`: Add `agent_enabled` and `policy_tool_version` attributes to get the policy runtime version of a policy set, by @mrinalirao [1234](https://github.com/hashicorp/terraform-provider-tfe/pull/1234)
* `r/tfe_organization`: Add `aggregated_commit_status_enabled` attribute, by @mjyocca [1169](https://github.com/hashicorp/terraform-provider-tfe/pull/1169)
* `d/tfe_organization`: Add `aggregated_commit_status_enabled` attribute, by @mjyocca [1169](https://github.com/hashicorp/terraform-provider-tfe/pull/1169)

BUG FIXES:

Expand Down
6 changes: 6 additions & 0 deletions internal/provider/data_source_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func dataSourceTFEOrganization() *schema.Resource {
Computed: true,
},

"aggregated_commit_status_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"assessments_enforced": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -106,6 +111,7 @@ func dataSourceTFEOrganizationRead(d *schema.ResourceData, meta interface{}) err
d.Set("owners_team_saml_role_id", org.OwnersTeamSAMLRoleID)
d.Set("two_factor_conformant", org.TwoFactorConformant)
d.Set("send_passing_statuses_for_untriggered_speculative_plans", org.SendPassingStatusesForUntriggeredSpeculativePlans)
d.Set("aggregated_commit_status_enabled", org.AggregatedCommitStatusEnabled)
d.Set("assessments_enforced", org.AssessmentsEnforced)

return nil
Expand Down
18 changes: 16 additions & 2 deletions internal/provider/resource_tfe_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func resourceTFEOrganization() *schema.Resource {
Computed: true,
},

"aggregated_commit_status_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},

"assessments_enforced": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -146,6 +152,7 @@ func resourceTFEOrganizationRead(d *schema.ResourceData, meta interface{}) error
d.Set("owners_team_saml_role_id", org.OwnersTeamSAMLRoleID)
d.Set("cost_estimation_enabled", org.CostEstimationEnabled)
d.Set("send_passing_statuses_for_untriggered_speculative_plans", org.SendPassingStatusesForUntriggeredSpeculativePlans)
d.Set("aggregated_commit_status_enabled", org.AggregatedCommitStatusEnabled)
// TFE (onprem) does not currently have this feature and this value won't be returned in those cases.
// org.AssessmentsEnforced will default to false
d.Set("assessments_enforced", org.AssessmentsEnforced)
Expand Down Expand Up @@ -193,8 +200,15 @@ func resourceTFEOrganizationUpdate(d *schema.ResourceData, meta interface{}) err
}

// If send_passing_statuses_for_untriggered_speculative_plans is supplied, set it using the options struct.
if sendPassingStatusesForUntriggeredSpeculativePlans, ok := d.GetOk("send_passing_statuses_for_untriggered_speculative_plans"); ok {
options.SendPassingStatusesForUntriggeredSpeculativePlans = tfe.Bool(sendPassingStatusesForUntriggeredSpeculativePlans.(bool))
if d.HasChange("send_passing_statuses_for_untriggered_speculative_plans") {
_, newVal := d.GetChange("send_passing_statuses_for_untriggered_speculative_plans")
options.SendPassingStatusesForUntriggeredSpeculativePlans = tfe.Bool(newVal.(bool))
}

// If aggregated_commit_status_enabled is supplied, set it using the options struct.
if d.HasChange("aggregated_commit_status_enabled") {
_, newVal := d.GetChange("aggregated_commit_status_enabled")
options.AggregatedCommitStatusEnabled = tfe.Bool(newVal.(bool))
}

// If assessments_enforced is supplied, set it using the options struct.
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/resource_tfe_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func TestAccTFEOrganization_full(t *testing.T) {
"tfe_organization.foobar", "cost_estimation_enabled", "false"),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "send_passing_statuses_for_untriggered_speculative_plans", "false"),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "aggregated_commit_status_enabled", "true"),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "assessments_enforced", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -161,6 +163,8 @@ func TestAccTFEOrganization_update_costEstimation(t *testing.T) {
"tfe_organization.foobar", "cost_estimation_enabled", strconv.FormatBool(costEstimationEnabled1)),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "send_passing_statuses_for_untriggered_speculative_plans", "false"),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "aggregated_commit_status_enabled", "true"),
resource.TestCheckResourceAttr(
"tfe_organization.foobar", "assessments_enforced", strconv.FormatBool(assessmentsEnforced1)),
resource.TestCheckResourceAttr(
Expand Down
3 changes: 2 additions & 1 deletion website/docs/d/organization.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ In addition to all arguments above, the following attributes are exported:
* `cost_estimation_enabled` - Whether or not the cost estimation feature is enabled for all workspaces in the organization. Defaults to true. In a Terraform Cloud organization which does not have Teams & Governance features, this value is always false and cannot be changed. In Terraform Enterprise, Cost Estimation must also be enabled in Site Administration.
* `owners_team_saml_role_id` - The name of the "owners" team.
* `send_passing_statuses_for_untriggered_speculative_plans` - Whether or not to send VCS status updates for untriggered speculative plans. This can be useful if large numbers of untriggered workspaces are exhausting request limits for connected version control service providers like GitHub. Defaults to true. In Terraform Enterprise, this setting has no effect and cannot be changed but is also available in Site Administration.
* `default_project_id` - ID of the organization's default project. All workspaces created without specifying a project ID are created in this project.
* `aggregated_commit_status_enabled` - Whether or not to enable Aggregated Status Checks. This can be useful for monorepo repositories with multiple workspaces receiving status checks for events such as a pull request.
* `default_project_id` - ID of the organization's default project. All workspaces created without specifying a project ID are created in this project.
1 change: 1 addition & 0 deletions website/docs/r/organization.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following arguments are supported:
* `owners_team_saml_role_id` - (Optional) The name of the "owners" team.
* `cost_estimation_enabled` - (Optional) Whether or not the cost estimation feature is enabled for all workspaces in the organization. Defaults to true. In a Terraform Cloud organization which does not have Teams & Governance features, this value is always false and cannot be changed. In Terraform Enterprise, Cost Estimation must also be enabled in Site Administration.
* `send_passing_statuses_for_untriggered_speculative_plans` - (Optional) Whether or not to send VCS status updates for untriggered speculative plans. This can be useful if large numbers of untriggered workspaces are exhausting request limits for connected version control service providers like GitHub. Defaults to false. In Terraform Enterprise, this setting has no effect and cannot be changed but is also available in Site Administration.
* `aggregated_commit_status_enabled` - (Optional) Whether or not to enable Aggregated Status Checks. This can be useful for monorepo repositories with multiple workspaces receiving status checks for events such as a pull request. If enabled, `send_passing_statuses_for_untriggered_speculative_plans` needs to be false.
* `assessments_enforced` - (Optional) (Available only in Terraform Cloud) Whether to force health assessments (drift detection) on all eligible workspaces or allow workspaces to set their own preferences.
* `allow_force_delete_workspaces` - (Optional) Whether workspace administrators are permitted to delete workspaces with resources under management. If false, only organization owners may delete these workspaces. Defaults to false.

Expand Down

0 comments on commit e5854c7

Please sign in to comment.