Skip to content

Commit

Permalink
Add SpeculativePlanManagementEnabled organization setting (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilincmu authored Oct 25, 2024
1 parent 588526b commit de9170a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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 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"`

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 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"`

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 de9170a

Please sign in to comment.