Skip to content

Commit

Permalink
Adding Cloud Build Connection and Repository resources to beta provid…
Browse files Browse the repository at this point in the history
…er. (#7157) (#5140)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Jan 27, 2023
1 parent 38006e7 commit c18e05e
Show file tree
Hide file tree
Showing 11 changed files with 2,016 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changelog/7157.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:new-resource
`google_cloudbuildv2_connection` (beta)
```
```release-note:new-resource
`google_cloudbuildv2_repository` (beta)
```
24 changes: 24 additions & 0 deletions google-beta/provider_dcl_client_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
assuredworkloads "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads/beta"
bigqueryreservation "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/beta"
cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild/beta"
cloudbuildv2 "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuildv2/beta"
clouddeploy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/clouddeploy/beta"
cloudresourcemanager "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager/beta"
compute "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/compute/beta"
Expand Down Expand Up @@ -134,6 +135,29 @@ func NewDCLCloudbuildClient(config *Config, userAgent, billingProject string, ti
return cloudbuild.NewClient(dclConfig)
}

func NewDCLCloudbuildv2Client(config *Config, userAgent, billingProject string, timeout time.Duration) *cloudbuildv2.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
dcl.WithUserAgent(userAgent),
dcl.WithLogger(dclLogger{}),
dcl.WithBasePath(config.Cloudbuildv2BasePath),
}

if timeout != 0 {
configOptions = append(configOptions, dcl.WithTimeout(timeout))
}

if config.UserProjectOverride {
configOptions = append(configOptions, dcl.WithUserProjectOverride())
if billingProject != "" {
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
}
}

dclConfig := dcl.NewConfig(configOptions...)
return cloudbuildv2.NewClient(dclConfig)
}

func NewDCLClouddeployClient(config *Config, userAgent, billingProject string, timeout time.Duration) *clouddeploy.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
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 @@ -49,6 +49,15 @@ var CloudBuildWorkerPoolEndpointEntry = &schema.Schema{
}, ""),
}

var Cloudbuildv2EndpointEntryKey = "cloudbuildv2_custom_endpoint"
var Cloudbuildv2EndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CLOUDBUILDV2_CUSTOM_ENDPOINT",
}, ""),
}

var ClouddeployEndpointEntryKey = "clouddeploy_custom_endpoint"
var ClouddeployEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -125,6 +134,7 @@ type DCLConfig struct {
ApikeysBasePath string
AssuredWorkloadsBasePath string
CloudBuildWorkerPoolBasePath string
Cloudbuildv2BasePath string
ClouddeployBasePath string
CloudResourceManagerBasePath string
DataplexBasePath string
Expand All @@ -139,6 +149,7 @@ func configureDCLProvider(provider *schema.Provider) {
provider.Schema[ApikeysEndpointEntryKey] = ApikeysEndpointEntry
provider.Schema[AssuredWorkloadsEndpointEntryKey] = AssuredWorkloadsEndpointEntry
provider.Schema[CloudBuildWorkerPoolEndpointEntryKey] = CloudBuildWorkerPoolEndpointEntry
provider.Schema[Cloudbuildv2EndpointEntryKey] = Cloudbuildv2EndpointEntry
provider.Schema[ClouddeployEndpointEntryKey] = ClouddeployEndpointEntry
provider.Schema[CloudResourceManagerEndpointEntryKey] = CloudResourceManagerEndpointEntry
provider.Schema[DataplexEndpointEntryKey] = DataplexEndpointEntry
Expand All @@ -153,6 +164,7 @@ func providerDCLConfigure(d *schema.ResourceData, config *Config) interface{} {
config.ApikeysBasePath = d.Get(ApikeysEndpointEntryKey).(string)
config.AssuredWorkloadsBasePath = d.Get(AssuredWorkloadsEndpointEntryKey).(string)
config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
config.Cloudbuildv2BasePath = d.Get(Cloudbuildv2EndpointEntryKey).(string)
config.ClouddeployBasePath = d.Get(ClouddeployEndpointEntryKey).(string)
config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string)
config.DataplexBasePath = d.Get(DataplexEndpointEntryKey).(string)
Expand Down
2 changes: 2 additions & 0 deletions google-beta/provider_dcl_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var dclResources = map[string]*schema.Resource{
"google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(),
"google_bigquery_reservation_assignment": resourceBigqueryReservationAssignment(),
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
"google_cloudbuildv2_connection": resourceCloudbuildv2Connection(),
"google_cloudbuildv2_repository": resourceCloudbuildv2Repository(),
"google_clouddeploy_delivery_pipeline": resourceClouddeployDeliveryPipeline(),
"google_clouddeploy_target": resourceClouddeployTarget(),
"google_compute_firewall_policy": resourceComputeFirewallPolicy(),
Expand Down
Loading

0 comments on commit c18e05e

Please sign in to comment.