Skip to content

Commit d114b5d

Browse files
authored
Merge pull request #1056 from hashicorp/mkam/TF-14883/org-default-project
Add support to update an organization’s default project
2 parents 6361be9 + 972b81c commit d114b5d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
## Enhancements
4+
5+
* 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)
6+
37
## Bug fixes
48

59
* 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)

organization.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ type OrganizationUpdateOptions struct {
311311
// Optional: StacksEnabled toggles whether stacks are enabled for the organization. This setting
312312
// is considered BETA, SUBJECT TO CHANGE, and likely unavailable to most users.
313313
StacksEnabled *bool `jsonapi:"attr,stacks-enabled,omitempty"`
314+
315+
// Optional: DefaultProject is the default project that workspaces are created in when no project is specified.
316+
// This setting is considered BETA, SUBJECT TO CHANGE, and likely unavailable to most users.
317+
DefaultProject *Project `jsonapi:"relation,default-project,omitempty"`
314318
}
315319

316320
// ReadRunQueueOptions represents the options for showing the queue.

organization_integration_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,27 @@ func TestOrganizationsUpdate(t *testing.T) {
388388

389389
t.Cleanup(orgAgentTestCleanup)
390390
})
391+
392+
t.Run("with different default project", func(t *testing.T) {
393+
skipUnlessBeta(t)
394+
395+
// Create an organization and a second project in the organization
396+
org, orgCleanup := createOrganization(t, client)
397+
t.Cleanup(orgCleanup)
398+
399+
proj, _ := createProject(t, client, org) // skip cleanup because default project cannot be deleted
400+
401+
// Update the default project and verify the change
402+
updated, err := client.Organizations.Update(ctx, org.Name, OrganizationUpdateOptions{
403+
DefaultProject: proj,
404+
})
405+
require.NoError(t, err)
406+
require.Equal(t, proj.ID, updated.DefaultProject.ID)
407+
408+
fetched, err := client.Organizations.Read(ctx, org.Name)
409+
require.NoError(t, err)
410+
require.Equal(t, proj.ID, fetched.DefaultProject.ID)
411+
})
391412
}
392413

393414
func TestOrganizationsDelete(t *testing.T) {

0 commit comments

Comments
 (0)