Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

## Enhancements

* Remove `DefaultProject` from `OrganizationUpdateOptions` to prevent updating an organization's default project, by @netramali [#1078](https://github.com/hashicorp/go-tfe/pull/1078)

## BREAKING CHANGES

In the last release, Runs interface method `ListForOrganization` included pagination fields `TotalCount` and `TotalPages`, but these are being removed as this feature approaches general availablity by @brandonc [#1074](https://github.com/hashicorp/go-tfe/pull/1074)
Expand Down
6 changes: 0 additions & 6 deletions organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"fmt"
"net/url"
"time"

"github.com/hashicorp/jsonapi"
)

// Compile-time proof of interface implementation.
Expand Down Expand Up @@ -313,10 +311,6 @@ type OrganizationUpdateOptions struct {
// Optional: StacksEnabled toggles whether stacks are enabled for the organization. This setting
// is considered BETA, SUBJECT TO CHANGE, and likely unavailable to most users.
StacksEnabled *bool `jsonapi:"attr,stacks-enabled,omitempty"`

// Optional: DefaultProject is the default project that workspaces are created in when no project is specified.
// This setting is considered BETA, SUBJECT TO CHANGE, and likely unavailable to most users.
DefaultProject jsonapi.NullableRelationship[*Project] `jsonapi:"relation,default-project,omitempty"`
}

// ReadRunQueueOptions represents the options for showing the queue.
Expand Down
42 changes: 0 additions & 42 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"testing"
"time"

"github.com/hashicorp/jsonapi"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -389,47 +388,6 @@ func TestOrganizationsUpdate(t *testing.T) {

t.Cleanup(orgAgentTestCleanup)
})

t.Run("with different default project", func(t *testing.T) {
skipUnlessBeta(t)

// Create an organization and a second project in the organization
org, orgCleanup := createOrganization(t, client)
t.Cleanup(orgCleanup)

proj, _ := createProject(t, client, org) // skip cleanup because default project cannot be deleted

// Update the default project and verify the change
updated, err := client.Organizations.Update(ctx, org.Name, OrganizationUpdateOptions{
DefaultProject: jsonapi.NewNullableRelationshipWithValue[*Project](proj),
})
require.NoError(t, err)
require.Equal(t, proj.ID, updated.DefaultProject.ID)

fetched, err := client.Organizations.Read(ctx, org.Name)
require.NoError(t, err)
require.Equal(t, proj.ID, fetched.DefaultProject.ID)

// Update without setting default project and verify no changes
updated, err = client.Organizations.Update(ctx, org.Name, OrganizationUpdateOptions{})
require.NoError(t, err)
require.Equal(t, proj.ID, updated.DefaultProject.ID)

fetched, err = client.Organizations.Read(ctx, org.Name)
require.NoError(t, err)
require.Equal(t, proj.ID, fetched.DefaultProject.ID)

// Update the setting to an explicit null value and verify it is unset
deleted, err := client.Organizations.Update(ctx, org.Name, OrganizationUpdateOptions{
DefaultProject: jsonapi.NewNullNullableRelationship[*Project](),
})
require.NoError(t, err)
require.Nil(t, deleted.DefaultProject)

fetched, err = client.Organizations.Read(ctx, org.Name)
require.NoError(t, err)
require.Nil(t, fetched.DefaultProject)
})
}

func TestOrganizationsDelete(t *testing.T) {
Expand Down
Loading