Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SpeculativePlanManagementEnabled organization setting #983

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading