Skip to content

Commit

Permalink
Add SpeculativePlanManagementEnabled organization setting
Browse files Browse the repository at this point in the history
  • Loading branch information
lilincmu committed Oct 22, 2024
1 parent fc80091 commit 1a4e26d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

## Features
* Adds `SpeculativePlanManagementEnabled` field to `Organization` by @lilincmu [#983](https://github.com/hashicorp/go-tfe/pull/983)

## Enhancements

* Add support for enabling Stacks on an organization by @brandonc [#987](https://github.com/hashicorp/go-tfe/pull/987)
Expand Down
7 changes: 7 additions & 0 deletions organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 older commits would 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"`

Expand Down Expand Up @@ -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 older commits would 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"`

Expand Down
18 changes: 18 additions & 0 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1a4e26d

Please sign in to comment.