Skip to content

Commit 461e134

Browse files
Add AgentPool to OAuthClientUpdateOptions (#1075)
This change adds an AgentPool field to the OAuthClientUpdateOptions struct, which is used to associate a VCS Provider with an AgentPool for PrivateVCS support. Co-authored-by: Rolee Sinha <[email protected]>
1 parent da71abb commit 461e134

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CHANGELOG.md

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

3+
* Adds `AgentPool` field to the OAuthClientUpdateOptions struct, which is used to associate a VCS Provider with an AgentPool for PrivateVCS support by @jpogran [#1075](https://github.com/hashicorp/go-tfe/pull/1075)
4+
35
## BREAKING CHANGES
46

57
* Updates team token `Description` to be a pointer, allowing for both nil descriptions and empty string descriptions. Team token descriptions and the ability to create multiple team tokens is in BETA, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users, by @mkam [#1088](https://github.com/hashicorp/go-tfe/pull/1088)
@@ -21,6 +23,7 @@
2123

2224
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)
2325

26+
2427
# v1.76.0
2528

2629
## Enhancements

oauth_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ type OAuthClientUpdateOptions struct {
196196
// Optional: The token string you were given by your VCS provider.
197197
OAuthToken *string `jsonapi:"attr,oauth-token-string,omitempty"`
198198

199+
// Optional: AgentPool to associate the VCS Provider with, for PrivateVCS support
200+
AgentPool *AgentPool `jsonapi:"relation,agent-pool,omitempty"`
201+
199202
// Optional: Whether the OAuthClient is available to all workspaces in the organization.
200203
// True if the oauth client is organization scoped, false otherwise.
201204
OrganizationScoped *bool `jsonapi:"attr,organization-scoped,omitempty"`

oauth_client_integration_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,36 @@ func TestOAuthClientsUpdate(t *testing.T) {
640640
assert.NotEmpty(t, oc.ID)
641641
assert.NotEqual(t, origOC.OrganizationScoped, oc.OrganizationScoped)
642642
})
643+
644+
t.Run("updates agent pool", func(t *testing.T) {
645+
testAgentPool1, agentPoolCleanup := createAgentPool(t, client, orgTest)
646+
defer agentPoolCleanup()
647+
testAgentPool2, agentPoolCleanup2 := createAgentPool(t, client, orgTest)
648+
defer agentPoolCleanup2()
649+
650+
organizationScopedTrue := true
651+
options := OAuthClientCreateOptions{
652+
APIURL: String("https://bbdc.com"),
653+
HTTPURL: String("https://bbdc.com"),
654+
ServiceProvider: ServiceProvider(ServiceProviderBitbucketDataCenter),
655+
OrganizationScoped: &organizationScopedTrue,
656+
AgentPool: testAgentPool1,
657+
}
658+
659+
origOC, err := client.OAuthClients.Create(ctx, orgTest.Name, options)
660+
661+
require.NoError(t, err)
662+
assert.NotEmpty(t, origOC.ID)
663+
664+
updateOpts := OAuthClientUpdateOptions{
665+
AgentPool: testAgentPool2,
666+
}
667+
oc, err := client.OAuthClients.Update(ctx, origOC.ID, updateOpts)
668+
require.NoError(t, err)
669+
assert.NotEmpty(t, oc.ID)
670+
assert.Equal(t, oc.AgentPool.ID, testAgentPool2.ID)
671+
assert.NotEqual(t, origOC.AgentPool.ID, oc.AgentPool.ID)
672+
})
643673
}
644674

645675
const publicKey = `

0 commit comments

Comments
 (0)