Skip to content

Commit f5d690e

Browse files
authored
Merge pull request #1214 from hashicorp/TF-25152/stack-agent-pool-support
Stack agent pool support
2 parents c75a3d1 + 3971180 commit f5d690e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
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 support for managing agent pools on `Stacks` by @maed223 [#1214](https://github.com/hashicorp/go-tfe/pull/1214)
6+
37
## Bug Fixes
48

59
* Fixes arch validation on Terraform, OPA, and Sentinel Tool Versions when providing top level `url` and `sha` with multiple `archs` by @kelsi-hoyle [#1212](https://github.com/hashicorp/go-tfe/pull/1212)

stack.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type Stack struct {
9797
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
9898

9999
// Relationships
100+
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
100101
Project *Project `jsonapi:"relation,project"`
101102
LatestStackConfiguration *StackConfiguration `jsonapi:"relation,latest-stack-configuration"`
102103
}
@@ -189,13 +190,15 @@ type StackCreateOptions struct {
189190
Description *string `jsonapi:"attr,description,omitempty"`
190191
VCSRepo *StackVCSRepoOptions `jsonapi:"attr,vcs-repo"`
191192
Project *Project `jsonapi:"relation,project"`
193+
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
192194
}
193195

194196
// StackUpdateOptions represents the options for updating a stack.
195197
type StackUpdateOptions struct {
196198
Name *string `jsonapi:"attr,name,omitempty"`
197199
Description *string `jsonapi:"attr,description,omitempty"`
198200
VCSRepo *StackVCSRepoOptions `jsonapi:"attr,vcs-repo"`
201+
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
199202
}
200203

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

stack_integration_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ func TestStackReadUpdateDelete(t *testing.T) {
141141
oauthClient, cleanup := createOAuthClient(t, client, orgTest, nil)
142142
t.Cleanup(cleanup)
143143

144+
initialPool, err := client.AgentPools.Create(ctx, orgTest.Name, AgentPoolCreateOptions{
145+
Name: String("initial-test-pool"),
146+
})
147+
require.NoError(t, err)
148+
144149
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
145150
Name: "test-stack",
146151
VCSRepo: &StackVCSRepoOptions{
@@ -151,6 +156,7 @@ func TestStackReadUpdateDelete(t *testing.T) {
151156
Project: &Project{
152157
ID: orgTest.DefaultProject.ID,
153158
},
159+
AgentPool: initialPool,
154160
})
155161

156162
require.NoError(t, err)
@@ -164,20 +170,27 @@ func TestStackReadUpdateDelete(t *testing.T) {
164170
require.Equal(t, stack.VCSRepo.Identifier, stackRead.VCSRepo.Identifier)
165171
require.Equal(t, stack.VCSRepo.OAuthTokenID, stackRead.VCSRepo.OAuthTokenID)
166172
require.Equal(t, stack.VCSRepo.Branch, stackRead.VCSRepo.Branch)
167-
173+
require.Equal(t, stack.AgentPool.ID, stackRead.AgentPool.ID)
168174
assert.Equal(t, stack, stackRead)
169175

176+
updatedPool, err := client.AgentPools.Create(ctx, orgTest.Name, AgentPoolCreateOptions{
177+
Name: String("updated-test-pool"),
178+
})
179+
require.NoError(t, err)
180+
170181
stackUpdated, err := client.Stacks.Update(ctx, stack.ID, StackUpdateOptions{
171182
Description: String("updated description"),
172183
VCSRepo: &StackVCSRepoOptions{
173184
Identifier: "brandonc/pet-nulls-stack",
174185
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
175186
Branch: "main",
176187
},
188+
AgentPool: updatedPool,
177189
})
178190

179191
require.NoError(t, err)
180192
require.Equal(t, "updated description", stackUpdated.Description)
193+
require.Equal(t, updatedPool.ID, stackUpdated.AgentPool.ID)
181194

182195
stackUpdatedConfig, err := client.Stacks.UpdateConfiguration(ctx, stack.ID)
183196
require.NoError(t, err)

0 commit comments

Comments
 (0)