Skip to content

Commit de9170a

Browse files
authored
Add SpeculativePlanManagementEnabled organization setting (#983)
1 parent 588526b commit de9170a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Add support for reading a registry module by its unique identifier by @dsa0x
88
[#988](https://github.com/hashicorp/go-tfe/pull/988)
99
* 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)
10+
* Adds `SpeculativePlanManagementEnabled` field to `Organization` by @lilincmu [#983](https://github.com/hashicorp/go-tfe/pull/983)
1011

1112
# v1.68.0
1213

organization.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ type Organization struct {
115115
TwoFactorConformant bool `jsonapi:"attr,two-factor-conformant"`
116116
SendPassingStatusesForUntriggeredSpeculativePlans bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans"`
117117
RemainingTestableCount int `jsonapi:"attr,remaining-testable-count"`
118+
SpeculativePlanManagementEnabled bool `jsonapi:"attr,speculative-plan-management-enabled"`
118119
// Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false.
119120
AggregatedCommitStatusEnabled bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"`
120121
// Note: This will be false for TFE versions older than v202211, where the setting was introduced.
@@ -243,6 +244,9 @@ type OrganizationCreateOptions struct {
243244
// Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false.
244245
AggregatedCommitStatusEnabled *bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"`
245246

247+
// Optional: SpeculativePlanManagementEnabled toggles whether pending speculative plans from outdated commits will be cancelled if a newer commit is pushed to the same branch.
248+
SpeculativePlanManagementEnabled *bool `jsonapi:"attr,speculative-plan-management-enabled,omitempty"`
249+
246250
// Optional: AllowForceDeleteWorkspaces toggles behavior of allowing workspace admins to delete workspaces with resources under management.
247251
AllowForceDeleteWorkspaces *bool `jsonapi:"attr,allow-force-delete-workspaces,omitempty"`
248252

@@ -292,6 +296,9 @@ type OrganizationUpdateOptions struct {
292296
// Optional: If enabled, SendPassingStatusesForUntriggeredSpeculativePlans needs to be false.
293297
AggregatedCommitStatusEnabled *bool `jsonapi:"attr,aggregated-commit-status-enabled,omitempty"`
294298

299+
// Optional: SpeculativePlanManagementEnabled toggles whether pending speculative plans from outdated commits will be cancelled if a newer commit is pushed to the same branch.
300+
SpeculativePlanManagementEnabled *bool `jsonapi:"attr,speculative-plan-management-enabled,omitempty"`
301+
295302
// Optional: AllowForceDeleteWorkspaces toggles behavior of allowing workspace admins to delete workspaces with resources under management.
296303
AllowForceDeleteWorkspaces *bool `jsonapi:"attr,allow-force-delete-workspaces,omitempty"`
297304

organization_integration_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,24 @@ func TestOrganizationsUpdate(t *testing.T) {
275275
}
276276
})
277277

278+
t.Run("with new SpeculativePlanManagementEnabled option", func(t *testing.T) {
279+
skipIfEnterprise(t)
280+
281+
for _, testCase := range []bool{true, false} {
282+
orgTest, orgTestCleanup := createOrganization(t, client)
283+
t.Cleanup(orgTestCleanup)
284+
285+
options := OrganizationUpdateOptions{
286+
SpeculativePlanManagementEnabled: Bool(testCase),
287+
}
288+
289+
org, err := client.Organizations.Update(ctx, orgTest.Name, options)
290+
require.NoError(t, err)
291+
292+
assert.Equal(t, testCase, org.SpeculativePlanManagementEnabled)
293+
}
294+
})
295+
278296
t.Run("with valid options", func(t *testing.T) {
279297
orgTest, orgTestCleanup := createOrganization(t, client)
280298

0 commit comments

Comments
 (0)