Skip to content

Commit 8e555e2

Browse files
Move Cloud Build Worker Pool to GA. (#5356) (#10617)
* Move Cloud Build Worker Pool to GA. Note: this includes some unusual changes due to deviations between the beta and GA APIs. * upgrade dcl. * finish removing version gate. * Use new GA / Beta versions, neither of which is ACL'd. Signed-off-by: Modular Magician <[email protected]>
1 parent dfec078 commit 8e555e2

10 files changed

+759
-1
lines changed

.changelog/5356.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:new-resource
2+
google_cloudbuild_worker_pool in GA.
3+
```
4+
```release-note:enhancement
5+
cloudbuild: added display_name and annotations to google_cloudbuild_worker_pool for compatibility with new GA.
6+
```

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/hashicorp/terraform-provider-google
22
require (
33
cloud.google.com/go/bigtable v1.10.1
4-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211027225138-ef28ca390518
4+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211117235310-d31aef517fa2
55
github.com/apparentlymart/go-cidr v1.1.0
66
github.com/client9/misspell v0.3.4
77
github.com/davecgh/go-spew v1.1.1

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,10 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
14301430
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
14311431
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
14321432
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
1433+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211109205522-6cd3cdca0637 h1:sFNz5neMQaa4CIRE2D35t5A84lps/ylOlAXE+ByRKho=
1434+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211109205522-6cd3cdca0637/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
1435+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211117235310-d31aef517fa2 h1:nEyJ0Cm2OP/ZVYBYRzatAvXeXAaUc3VLkWixaIqI034=
1436+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211117235310-d31aef517fa2/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
14331437
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211021165233-f4f2a757f9e0 h1:GQS66Qx0pa9JHrjKyI5AHesSPeFNlHebXlASOXzCJKY=
14341438
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211021165233-f4f2a757f9e0/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
14351439
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211026195335-4a6ae4ac04de h1:R7uCfI/yavqO+qK6eZRiJKjDoKJ0yIJh1ni5y933LeA=

google/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ type Config struct {
166166
EventarcBasePath string
167167
GkeHubBasePath string
168168
OrgPolicyBasePath string
169+
// CloudBuild WorkerPool uses a different endpoint (v1beta1) than any other CloudBuild resources
170+
CloudBuildWorkerPoolBasePath string
169171
}
170172

171173
const AccessApprovalBasePathKey = "AccessApproval"

google/provider.go

+4
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,8 @@ func Provider() *schema.Provider {
690690
GkeHubFeatureCustomEndpointEntryKey: GkeHubFeatureCustomEndpointEntry,
691691
OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
692692
PrivatecaCertificateTemplateEndpointEntryKey: PrivatecaCertificateTemplateCustomEndpointEntry,
693+
694+
CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
693695
},
694696

695697
ProviderMetaSchema: map[string]*schema.Schema{
@@ -1194,6 +1196,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
11941196
// resources implemented within tpgtools
11951197
map[string]*schema.Resource{
11961198
"google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(),
1199+
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
11971200
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
11981201
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
11991202
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
@@ -1435,6 +1438,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
14351438
config.GkeHubBasePath = d.Get(GkeHubFeatureCustomEndpointEntryKey).(string)
14361439
config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
14371440
config.PrivatecaBasePath = d.Get(PrivatecaCertificateTemplateEndpointEntryKey).(string)
1441+
config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
14381442

14391443
stopCtx, ok := schema.StopContext(ctx)
14401444
if !ok {

google/provider_dcl_client_creation.go

+24
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"time"
2121

2222
assuredworkloads "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads"
23+
cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild"
2324
cloudresourcemanager "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager"
2425
compute "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/compute"
2526
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc"
@@ -51,6 +52,29 @@ func NewDCLAssuredWorkloadsClient(config *Config, userAgent, billingProject stri
5152
return assuredworkloads.NewClient(dclConfig)
5253
}
5354

55+
func NewDCLcloudbuildClient(config *Config, userAgent, billingProject string, timeout time.Duration) *cloudbuild.Client {
56+
configOptions := []dcl.ConfigOption{
57+
dcl.WithHTTPClient(config.client),
58+
dcl.WithUserAgent(userAgent),
59+
dcl.WithLogger(dclLogger{}),
60+
dcl.WithBasePath(config.CloudBuildWorkerPoolBasePath),
61+
}
62+
63+
if timeout != 0 {
64+
configOptions = append(configOptions, dcl.WithTimeout(timeout))
65+
}
66+
67+
if config.UserProjectOverride {
68+
configOptions = append(configOptions, dcl.WithUserProjectOverride())
69+
if billingProject != "" {
70+
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
71+
}
72+
}
73+
74+
dclConfig := dcl.NewConfig(configOptions...)
75+
return cloudbuild.NewClient(dclConfig)
76+
}
77+
5478
func NewDCLCloudResourceManagerClient(config *Config, userAgent, billingProject string, timeout time.Duration) *cloudresourcemanager.Client {
5579
configOptions := []dcl.ConfigOption{
5680
dcl.WithHTTPClient(config.client),

google/provider_dcl_endpoints.go

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ var AssuredWorkloadsEndpointEntry = &schema.Schema{
3131
}, ""),
3232
}
3333

34+
var CloudBuildWorkerPoolEndpointEntryKey = "cloud_build_worker_pool_custom_endpoint"
35+
var CloudBuildWorkerPoolEndpointEntry = &schema.Schema{
36+
Type: schema.TypeString,
37+
Optional: true,
38+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
39+
"GOOGLE_CLOUD_BUILD_WORKER_POOL_CUSTOM_ENDPOINT",
40+
}, ""),
41+
}
42+
3443
var CloudResourceManagerEndpointEntryKey = "cloud_resource_manager_custom_endpoint"
3544
var CloudResourceManagerEndpointEntry = &schema.Schema{
3645
Type: schema.TypeString,
@@ -78,6 +87,7 @@ var PrivatecaEndpointEntry = &schema.Schema{
7887

7988
//Add new values to config.go.erb config object declaration
8089
//AssuredWorkloadsBasePath string
90+
//CloudBuildWorkerPoolBasePath string
8191
//CloudResourceManagerBasePath string
8292
//ComputeBasePath string
8393
//EventarcBasePath string
@@ -86,6 +96,7 @@ var PrivatecaEndpointEntry = &schema.Schema{
8696

8797
//Add new values to provider.go.erb schema initialization
8898
// AssuredWorkloadsEndpointEntryKey: AssuredWorkloadsEndpointEntry,
99+
// CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
89100
// CloudResourceManagerEndpointEntryKey: CloudResourceManagerEndpointEntry,
90101
// ComputeEndpointEntryKey: ComputeEndpointEntry,
91102
// EventarcEndpointEntryKey: EventarcEndpointEntry,
@@ -94,6 +105,7 @@ var PrivatecaEndpointEntry = &schema.Schema{
94105

95106
//Add new values to provider.go.erb - provider block read
96107
// config.AssuredWorkloadsBasePath = d.Get(AssuredWorkloadsEndpointEntryKey).(string)
108+
// config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
97109
// config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string)
98110
// config.ComputeBasePath = d.Get(ComputeEndpointEntryKey).(string)
99111
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)

0 commit comments

Comments
 (0)