diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ccc263d5..ff20c4cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Add support for reading a registry module by its unique identifier by @dsa0x [#988](https://github.com/hashicorp/go-tfe/pull/988) * Adds BETA support for a variable set `Parent` relation, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @jbonhag [#992](https://github.com/hashicorp/go-tfe/pull/992) +* Adds `SpeculativePlanManagementEnabled` field to `Organization` by @lilincmu [#983](https://github.com/hashicorp/go-tfe/pull/983) # v1.68.0 diff --git a/organization.go b/organization.go index 3bafae55c..5c0c9e004 100644 --- a/organization.go +++ b/organization.go @@ -115,6 +115,7 @@ type Organization struct { TwoFactorConformant bool `jsonapi:"attr,two-factor-conformant"` SendPassingStatusesForUntriggeredSpeculativePlans bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans"` RemainingTestableCount int `jsonapi:"attr,remaining-testable-count"` + SpeculativePlanManagementEnabled bool `jsonapi:"attr,speculative-plan-management-enabled"` // Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false. AggregatedCommitStatusEnabled bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"` // Note: This will be false for TFE versions older than v202211, where the setting was introduced. @@ -243,6 +244,9 @@ type OrganizationCreateOptions struct { // Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false. AggregatedCommitStatusEnabled *bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"` + // Optional: SpeculativePlanManagementEnabled toggles whether pending speculative plans from outdated commits will be cancelled if a newer commit is pushed to the same branch. + SpeculativePlanManagementEnabled *bool `jsonapi:"attr,speculative-plan-management-enabled,omitempty"` + // Optional: AllowForceDeleteWorkspaces toggles behavior of allowing workspace admins to delete workspaces with resources under management. AllowForceDeleteWorkspaces *bool `jsonapi:"attr,allow-force-delete-workspaces,omitempty"` @@ -292,6 +296,9 @@ type OrganizationUpdateOptions struct { // Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false. AggregatedCommitStatusEnabled *bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"` + // Optional: SpeculativePlanManagementEnabled toggles whether pending speculative plans from outdated commits will be cancelled if a newer commit is pushed to the same branch. + SpeculativePlanManagementEnabled *bool `jsonapi:"attr,speculative-plan-management-enabled,omitempty"` + // Optional: AllowForceDeleteWorkspaces toggles behavior of allowing workspace admins to delete workspaces with resources under management. AllowForceDeleteWorkspaces *bool `jsonapi:"attr,allow-force-delete-workspaces,omitempty"` diff --git a/organization_integration_test.go b/organization_integration_test.go index 5649278e1..76b29d7f7 100644 --- a/organization_integration_test.go +++ b/organization_integration_test.go @@ -275,6 +275,24 @@ func TestOrganizationsUpdate(t *testing.T) { } }) + t.Run("with new SpeculativePlanManagementEnabled option", func(t *testing.T) { + skipIfEnterprise(t) + + for _, testCase := range []bool{true, false} { + orgTest, orgTestCleanup := createOrganization(t, client) + t.Cleanup(orgTestCleanup) + + options := OrganizationUpdateOptions{ + SpeculativePlanManagementEnabled: Bool(testCase), + } + + org, err := client.Organizations.Update(ctx, orgTest.Name, options) + require.NoError(t, err) + + assert.Equal(t, testCase, org.SpeculativePlanManagementEnabled) + } + }) + t.Run("with valid options", func(t *testing.T) { orgTest, orgTestCleanup := createOrganization(t, client)