Skip to content

Commit

Permalink
Support to update an org's default project
Browse files Browse the repository at this point in the history
  • Loading branch information
mkam committed Feb 7, 2025
1 parent 6361be9 commit 972b81c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

## Enhancements

* Adds `DefaultProject` to `OrganizationUpdateOptions` to support updating an organization's default project. This provides BETA support, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users, by @mkam [#1056](https://github.com/hashicorp/go-tfe/pull/1056)

## Bug fixes

* Adds `ToolVersionArchitecture` to `AdminTerraformVersionUpdateOptions` and `AdminTerraformVersion`. This provides BETA support, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @kelsi-hoyle [#1047](https://github.com/hashicorp/go-tfe/pull/1047)
Expand Down
4 changes: 4 additions & 0 deletions organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ 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 *Project `jsonapi:"relation,default-project,omitempty"`
}

// ReadRunQueueOptions represents the options for showing the queue.
Expand Down
21 changes: 21 additions & 0 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,27 @@ 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: 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)
})
}

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

0 comments on commit 972b81c

Please sign in to comment.