Skip to content

Commit 8ecb40c

Browse files
authored
Merge pull request #1131 from hashicorp/remove-omission-of-vcs_repo-in-stack-update
Remove omission of vcs_repo in stack update
2 parents 3613591 + 3adb691 commit 8ecb40c

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Unreleased
2-
* Add support for HCP Terraform `/api/v2/workspaces/{external_id}/all-vars` API endpoint to fetch the list of all variables available to a workspace (include inherited variables from varsets) by @debrin-hc [#1105](https://github.com/hashicorp/go-tfe/pull/1105)
32

3+
## Enhancements
4+
5+
* Add support for HCP Terraform `/api/v2/workspaces/{external_id}/all-vars` API endpoint to fetch the list of all variables available to a workspace (include inherited variables from varsets) by @debrin-hc [#1105](https://github.com/hashicorp/go-tfe/pull/1105)
46
* Adds BETA support for listing `StackDeploymentGroups`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @hwatkins05-hashicorp [#1128](https://github.com/hashicorp/go-tfe/pull/1128)
7+
* Adds BETA support for removing/adding VCS backing for a Stack, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @Maed223 [#1131](https://github.com/hashicorp/go-tfe/pull/1131)
58

69
# v1.82.0
710

stack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ type StackCreateOptions struct {
191191
type StackUpdateOptions struct {
192192
Name *string `jsonapi:"attr,name,omitempty"`
193193
Description *string `jsonapi:"attr,description,omitempty"`
194-
VCSRepo *StackVCSRepoOptions `jsonapi:"attr,vcs-repo,omitempty"`
194+
VCSRepo *StackVCSRepoOptions `jsonapi:"attr,vcs-repo"`
195195
}
196196

197197
// WaitForStatusResult is the data structure that is sent over the channel

stack_integration_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ func TestStackReadUpdateDelete(t *testing.T) {
169169

170170
stackUpdated, err := client.Stacks.Update(ctx, stack.ID, StackUpdateOptions{
171171
Description: String("updated description"),
172+
VCSRepo: &StackVCSRepoOptions{
173+
Identifier: "brandonc/pet-nulls-stack",
174+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
175+
Branch: "main",
176+
},
172177
})
173178

174179
require.NoError(t, err)
@@ -186,6 +191,52 @@ func TestStackReadUpdateDelete(t *testing.T) {
186191
require.Nil(t, stackReadAfterDelete)
187192
}
188193

194+
func TestStackRemoveVCSBacking(t *testing.T) {
195+
skipUnlessBeta(t)
196+
197+
client := testClient(t)
198+
ctx := context.Background()
199+
200+
orgTest, orgTestCleanup := createOrganization(t, client)
201+
t.Cleanup(orgTestCleanup)
202+
203+
oauthClient, cleanup := createOAuthClient(t, client, orgTest, nil)
204+
t.Cleanup(cleanup)
205+
206+
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
207+
Name: "test-stack",
208+
VCSRepo: &StackVCSRepoOptions{
209+
Identifier: "brandonc/pet-nulls-stack",
210+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
211+
Branch: "main",
212+
},
213+
Project: &Project{
214+
ID: orgTest.DefaultProject.ID,
215+
},
216+
})
217+
218+
require.NoError(t, err)
219+
require.NotNil(t, stack)
220+
require.NotEmpty(t, stack.VCSRepo.Identifier)
221+
require.NotEmpty(t, stack.VCSRepo.OAuthTokenID)
222+
require.NotEmpty(t, stack.VCSRepo.Branch)
223+
224+
stackRead, err := client.Stacks.Read(ctx, stack.ID, nil)
225+
require.NoError(t, err)
226+
require.Equal(t, stack.VCSRepo.Identifier, stackRead.VCSRepo.Identifier)
227+
require.Equal(t, stack.VCSRepo.OAuthTokenID, stackRead.VCSRepo.OAuthTokenID)
228+
require.Equal(t, stack.VCSRepo.Branch, stackRead.VCSRepo.Branch)
229+
230+
assert.Equal(t, stack, stackRead)
231+
232+
stackUpdated, err := client.Stacks.Update(ctx, stack.ID, StackUpdateOptions{
233+
VCSRepo: nil,
234+
})
235+
236+
require.NoError(t, err)
237+
require.Nil(t, stackUpdated.VCSRepo)
238+
}
239+
189240
func TestStackReadUpdateForceDelete(t *testing.T) {
190241
skipUnlessBeta(t)
191242

@@ -226,6 +277,11 @@ func TestStackReadUpdateForceDelete(t *testing.T) {
226277

227278
stackUpdated, err := client.Stacks.Update(ctx, stack.ID, StackUpdateOptions{
228279
Description: String("updated description"),
280+
VCSRepo: &StackVCSRepoOptions{
281+
Identifier: "brandonc/pet-nulls-stack",
282+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
283+
Branch: "main",
284+
},
229285
})
230286

231287
require.NoError(t, err)

0 commit comments

Comments
 (0)