Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudbuild worker pools #3372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4877.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
google_cloudbuild_worker_pool
```
2 changes: 2 additions & 0 deletions google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ type Config struct {
// dataprocBasePath is implemented in mm
EventarcBasePath string
GkeHubBasePath string
// CloudBuild WorkerPool uses a different endpoint (v1beta1) than any other CloudBuild resources
CloudBuildWorkerPoolBasePath string
}

const AccessApprovalBasePathKey = "AccessApproval"
Expand Down
7 changes: 5 additions & 2 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,9 @@ func Provider() *schema.Provider {
BigtableAdminCustomEndpointEntryKey: BigtableAdminCustomEndpointEntry,

// dcl
EventarcEndpointEntryKey: EventarcEndpointEntry,
GkeHubFeatureCustomEndpointEntryKey: GkeHubFeatureCustomEndpointEntry,
EventarcEndpointEntryKey: EventarcEndpointEntry,
GkeHubFeatureCustomEndpointEntryKey: GkeHubFeatureCustomEndpointEntry,
CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
},

ProviderMetaSchema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1231,6 +1232,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_bigtable_instance": resourceBigtableInstance(),
"google_bigtable_table": resourceBigtableTable(),
"google_billing_subaccount": resourceBillingSubaccount(),
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
"google_cloudfunctions_function": resourceCloudFunctionsFunction(),
"google_composer_environment": resourceComposerEnvironment(),
"google_compute_attached_disk": resourceComputeAttachedDisk(),
Expand Down Expand Up @@ -1531,6 +1533,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
// dcl
config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
config.GkeHubBasePath = d.Get(GkeHubFeatureCustomEndpointEntryKey).(string)
config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)

stopCtx, ok := schema.StopContext(ctx)
if !ok {
Expand Down
27 changes: 27 additions & 0 deletions google-beta/provider_dcl_client_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,38 @@ package google
import (
dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"

cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild/beta"
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc/beta"
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc/beta"
gke_hub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
)

func NewDCLCloudBuildClient(config *Config, userAgent, billingProject string) *cloudbuild.Client {
dclClientOptions := dcl.WithHTTPClient(config.client)
dclUserAgentOptions := dcl.WithUserAgent(userAgent)
dclLoggerOptions := dcl.WithLogger(dclLogger{})
var dclConfig *dcl.Config
if config.UserProjectOverride && billingProject != "" {
dclBillingProjectHeader := dcl.WithHeader("X-Goog-User-Project", billingProject)
dclConfig = dcl.NewConfig(
dclClientOptions,
dclUserAgentOptions,
dclLoggerOptions,
dcl.WithBasePath(config.CloudBuildWorkerPoolBasePath),
dclBillingProjectHeader,
)
} else {
dclConfig = dcl.NewConfig(
dclClientOptions,
dclUserAgentOptions,
dclLoggerOptions,
dcl.WithBasePath(config.CloudBuildWorkerPoolBasePath),
)
}

return cloudbuild.NewClient(dclConfig)
}

func NewDCLDataprocClient(config *Config, userAgent, billingProject string) *dataproc.Client {
dclClientOptions := dcl.WithHTTPClient(config.client)
dclUserAgentOptions := dcl.WithUserAgent(userAgent)
Expand Down
12 changes: 12 additions & 0 deletions google-beta/provider_dcl_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import (
// empty string is passed for dcl default since dcl
// [hardcodes the values](https://github.com/GoogleCloudPlatform/declarative-resource-client-library/blob/main/services/google/eventarc/beta/trigger_internal.go#L96-L103)

var CloudBuildWorkerPoolEndpointEntryKey = "cloud_build_worker_pool_custom_endpoint"
var CloudBuildWorkerPoolEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CLOUD_BUILD_WORKER_POOL_CUSTOM_ENDPOINT",
}, ""),
}

var EventarcEndpointEntryKey = "eventarc_custom_endpoint"
var EventarcEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand All @@ -31,10 +40,13 @@ var EventarcEndpointEntry = &schema.Schema{
}

//Add new values to config.go.erb config object declaration
//CloudBuildWorkerPoolBasePath string
//EventarcBasePath string

//Add new values to provider.go.erb schema initialization
// CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
// EventarcEndpointEntryKey: EventarcEndpointEntry,

//Add new values to provider.go.erb - provider block read
// config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
Loading