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

Cloudrun v2 job #13154

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6852.txt
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_cloud_run_v2_job`
```
75 changes: 75 additions & 0 deletions google/cloud_run_v2_operation.go
@@ -0,0 +1,75 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package google

import (
"encoding/json"
"fmt"
"time"
)

type CloudRunV2OperationWaiter struct {
Config *Config
UserAgent string
Project string
CommonOperationWaiter
}

func (w *CloudRunV2OperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.CloudRunV2BasePath, w.CommonOperationWaiter.Op.Name)

return sendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
}

func createCloudRunV2Waiter(config *Config, op map[string]interface{}, project, activity, userAgent string) (*CloudRunV2OperationWaiter, error) {
w := &CloudRunV2OperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func cloudRunV2OperationWaitTimeWithResponse(config *Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createCloudRunV2Waiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
return json.Unmarshal([]byte(w.CommonOperationWaiter.Op.Response), response)
}

func cloudRunV2OperationWaitTime(config *Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createCloudRunV2Waiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return OperationWait(w, activity, timeout, config.PollInterval)
}
4 changes: 4 additions & 0 deletions google/config.go
Expand Up @@ -195,6 +195,7 @@ type Config struct {
CloudIdsBasePath string
CloudIotBasePath string
CloudRunBasePath string
CloudRunV2BasePath string
CloudSchedulerBasePath string
CloudTasksBasePath string
ComputeBasePath string
Expand Down Expand Up @@ -293,6 +294,7 @@ const CloudIdentityBasePathKey = "CloudIdentity"
const CloudIdsBasePathKey = "CloudIds"
const CloudIotBasePathKey = "CloudIot"
const CloudRunBasePathKey = "CloudRun"
const CloudRunV2BasePathKey = "CloudRunV2"
const CloudSchedulerBasePathKey = "CloudScheduler"
const CloudTasksBasePathKey = "CloudTasks"
const ComputeBasePathKey = "Compute"
Expand Down Expand Up @@ -385,6 +387,7 @@ var DefaultBasePaths = map[string]string{
CloudIdsBasePathKey: "https://ids.googleapis.com/v1/",
CloudIotBasePathKey: "https://cloudiot.googleapis.com/v1/",
CloudRunBasePathKey: "https://{{location}}-run.googleapis.com/",
CloudRunV2BasePathKey: "https://run.googleapis.com/v2/",
CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/",
CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/",
ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/",
Expand Down Expand Up @@ -1239,6 +1242,7 @@ func ConfigureBasePaths(c *Config) {
c.CloudIdsBasePath = DefaultBasePaths[CloudIdsBasePathKey]
c.CloudIotBasePath = DefaultBasePaths[CloudIotBasePathKey]
c.CloudRunBasePath = DefaultBasePaths[CloudRunBasePathKey]
c.CloudRunV2BasePath = DefaultBasePaths[CloudRunV2BasePathKey]
c.CloudSchedulerBasePath = DefaultBasePaths[CloudSchedulerBasePathKey]
c.CloudTasksBasePath = DefaultBasePaths[CloudTasksBasePathKey]
c.ComputeBasePath = DefaultBasePaths[ComputeBasePathKey]
Expand Down
1 change: 1 addition & 0 deletions google/config_test_utils.go
Expand Up @@ -42,6 +42,7 @@ func configureTestBasePaths(c *Config, url string) {
c.CloudIdsBasePath = url
c.CloudIotBasePath = url
c.CloudRunBasePath = url
c.CloudRunV2BasePath = url
c.CloudSchedulerBasePath = url
c.CloudTasksBasePath = url
c.ComputeBasePath = url
Expand Down
14 changes: 12 additions & 2 deletions google/provider.go
Expand Up @@ -341,6 +341,14 @@ func Provider() *schema.Provider {
"GOOGLE_CLOUD_RUN_CUSTOM_ENDPOINT",
}, DefaultBasePaths[CloudRunBasePathKey]),
},
"cloud_run_v2_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CLOUD_RUN_V2_CUSTOM_ENDPOINT",
}, DefaultBasePaths[CloudRunV2BasePathKey]),
},
"cloud_scheduler_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -926,9 +934,9 @@ func Provider() *schema.Provider {
return provider
}

// Generated resources: 248
// Generated resources: 249
// Generated IAM resources: 156
// Total generated resources: 404
// Total generated resources: 405
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -1033,6 +1041,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_cloud_run_service_iam_binding": ResourceIamBinding(CloudRunServiceIamSchema, CloudRunServiceIamUpdaterProducer, CloudRunServiceIdParseFunc),
"google_cloud_run_service_iam_member": ResourceIamMember(CloudRunServiceIamSchema, CloudRunServiceIamUpdaterProducer, CloudRunServiceIdParseFunc),
"google_cloud_run_service_iam_policy": ResourceIamPolicy(CloudRunServiceIamSchema, CloudRunServiceIamUpdaterProducer, CloudRunServiceIdParseFunc),
"google_cloud_run_v2_job": resourceCloudRunV2Job(),
"google_cloud_scheduler_job": resourceCloudSchedulerJob(),
"google_cloud_tasks_queue": resourceCloudTasksQueue(),
"google_cloud_tasks_queue_iam_binding": ResourceIamBinding(CloudTasksQueueIamSchema, CloudTasksQueueIamUpdaterProducer, CloudTasksQueueIdParseFunc),
Expand Down Expand Up @@ -1575,6 +1584,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.CloudIdsBasePath = d.Get("cloud_ids_custom_endpoint").(string)
config.CloudIotBasePath = d.Get("cloud_iot_custom_endpoint").(string)
config.CloudRunBasePath = d.Get("cloud_run_custom_endpoint").(string)
config.CloudRunV2BasePath = d.Get("cloud_run_v2_custom_endpoint").(string)
config.CloudSchedulerBasePath = d.Get("cloud_scheduler_custom_endpoint").(string)
config.CloudTasksBasePath = d.Get("cloud_tasks_custom_endpoint").(string)
config.ComputeBasePath = d.Get("compute_custom_endpoint").(string)
Expand Down