From 3e0b0363d78cee82c2cd619584bf2492149e9457 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Fri, 16 Sep 2022 15:19:32 +0000 Subject: [PATCH 1/8] added changes of data source compute snapshot --- ...data_source_google_compute_snapshot.go.erb | 109 +++++++++++++ .../terraform/utils/provider.go.erb | 1 + .../docs/d/compute_snapshot.html.markdown | 145 ++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb create mode 100644 mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown diff --git a/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb b/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb new file mode 100644 index 000000000000..11c4afa1325d --- /dev/null +++ b/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb @@ -0,0 +1,109 @@ +<% autogen_exception -%> +package google + +import ( + "fmt" + "log" + "sort" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +<% if version == "ga" -%> + "google.golang.org/api/compute/v1" +<% else -%> + "google.golang.org/api/compute/v0.beta" +<% end -%> +) + +func dataSourceGoogleComputeSnapshot() *schema.Resource { + + // Generate datasource schema from resource + dsSchema := datasourceSchemaFromResourceSchema(resourceComputeSnapshot().Schema) + + dsSchema["filter"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + } + dsSchema["most_recent"] = &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + } + + // Set 'Optional' schema elements + addOptionalFieldsToSchema(dsSchema, "name", "filter", "most_recent", "project") + + dsSchema["name"].ExactlyOneOf = []string{"name", "filter"} + dsSchema["filter"].ExactlyOneOf = []string{"name", "filter"} + + return &schema.Resource{ + Read: dataSourceGoogleComputeSnapshotRead, + Schema: dsSchema, + } +} + +func dataSourceGoogleComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*Config) + + project, err := getProject(d, config) + if err != nil { + return err + } + + if v, ok := d.GetOk("name"); ok { + return retrieveSnapshot(d, meta, project, v.(string)) + } + + if v, ok := d.GetOk("filter"); ok { + + userAgent, err := generateUserAgentString(d, config.userAgent) + if err != nil { + return err + } + + if config.UserProjectOverride { + billingProject := project + + // err == nil indicates that the billing_project value was found + if bp, err := getBillingProject(d, config); err == nil { + billingProject = bp + } + projectGetCall.Header().Add("X-Goog-User-Project", billingProject) + } + + snapshots, err := config.NewComputeClient(userAgent).Snapshots.List(project).Filter(v.(string)).Do() + if err != nil { + return fmt.Errorf("error retrieving list of instance snapshots: %s", err) + } + + mostRecent := d.Get("most_recent").(bool) + if mostRecent { + sort.Sort(ByCreationTimestampOfSnapshot(snapshots.Items)) + } + + count := len(snapshots.Items) + if count == 1 || count > 1 && mostRecent { + return retrieveSnapshot(d, meta, project, snapshots.Items[0].Name) + } + + return fmt.Errorf("your filter has returned %d instance snapshot(s). Please refine your filter or set most_recent to return exactly one instance snapshot", len(snapshots.Items)) + + } + + return fmt.Errorf("one of name or filter must be set") + +} + +func retrieveSnapshot(d *schema.ResourceData, meta interface{}, project, name string) error { + d.SetId("projects/" + project + "/global/snapshots/" + name) + d.Set("name", name) + return resourceComputeSnapshotRead(d, meta) +} + +// ByCreationTimestamp implements sort.Interface for []*Snapshot based on +// the CreationTimestamp field. +type ByCreationTimestampOfSnapshot []*compute.Snapshot + +func (a ByCreationTimestampOfSnapshot) Len() int { return len(a) } +func (a ByCreationTimestampOfSnapshot) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByCreationTimestampOfSnapshot) Less(i, j int) bool { + return a[i].CreationTimestamp > a[j].CreationTimestamp +} diff --git a/mmv1/third_party/terraform/utils/provider.go.erb b/mmv1/third_party/terraform/utils/provider.go.erb index fa4f71fc1934..8c97e4a1ede0 100644 --- a/mmv1/third_party/terraform/utils/provider.go.erb +++ b/mmv1/third_party/terraform/utils/provider.go.erb @@ -232,6 +232,7 @@ func Provider() *schema.Provider { "google_compute_resource_policy": dataSourceGoogleComputeResourcePolicy(), "google_compute_router": dataSourceGoogleComputeRouter(), "google_compute_router_status": dataSourceGoogleComputeRouterStatus(), + "google_compute_snapshot": dataSourceGoogleComputeSnapshot(), "google_compute_ssl_certificate": dataSourceGoogleComputeSslCertificate(), "google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(), "google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(), diff --git a/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown b/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown new file mode 100644 index 000000000000..2775f0f06bbe --- /dev/null +++ b/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown @@ -0,0 +1,145 @@ +--- +subcategory: "Compute Engine" +page_title: "Google: google_compute_snapshot" +description: |- + Get information about a Google Compute Snapshot. +--- + +# google\_compute\_snapshot + +To get more information about Snapshot, see: + +* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/snapshots) +* How-to Guides + * [Official Documentation](https://cloud.google.com/compute/docs/disks/create-snapshots) + +## Example Usage + +```hcl +#by name +data "google_compute_snapshot" "snapshot" { + name = "my-snapshot" +} + +# using a filter +data "google_compute_snapshot" "latest-snapshot" { + filter = "name != my-snapshot" + most_recent = true +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Optional) The name of the instance template. One of `name` or `filter` must be provided. + +* `filter` - (Optional) A filter to retrieve the instance templates. + See [gcloud topic filters](https://cloud.google.com/sdk/gcloud/reference/topic/filters) for reference. + If multiple instance templates match, either adjust the filter or specify `most_recent`. One of `name` or `filter` must be provided. + +* `most_recent` - (Optional) If `filter` is provided, ensures the most recent template is returned when multiple instance templates match. One of `name` or `filter` must be provided. + +- - - + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `description` - + + An optional description of this resource. + +* `storage_locations` - + + Cloud Storage bucket storage location of the snapshot (regional or multi-regional). + +* `labels` - + + Labels to apply to this Snapshot. + +* `zone` - + + A reference to the zone where the disk is hosted. + +* `snapshot_encryption_key` - + + The customer-supplied encryption key of the snapshot. Required if the + source snapshot is protected by a customer-supplied encryption key. + Structure is [documented below](#nested_snapshot_encryption_key). + +* `source_disk_encryption_key` - + + The customer-supplied encryption key of the source snapshot. Required + if the source snapshot is protected by a customer-supplied encryption + key. + Structure is [documented below](#nested_source_disk_encryption_key). + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + +The `snapshot_encryption_key` block supports: + +* `raw_key` - + + Specifies a 256-bit customer-supplied encryption key, encoded in + RFC 4648 base64 to either encrypt or decrypt this resource. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `sha256` - + The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + +* `kms_key_self_link` - + + The name of the encryption key that is stored in Google Cloud KMS. + +* `kms_key_service_account` - + + The service account used for the encryption request for the given KMS key. + If absent, the Compute Engine Service Agent service account is used. + +The `source_disk_encryption_key` block supports: + +* `raw_key` - + + Specifies a 256-bit customer-supplied encryption key, encoded in + RFC 4648 base64 to either encrypt or decrypt this resource. + **Note**: This property is sensitive and will not be displayed in the plan. + +* `kms_key_service_account` - + + The service account used for the encryption request for the given KMS key. + If absent, the Compute Engine Service Agent service account is used. +--- + +* `id` - an identifier for the resource with format `projects/{{project}}/global/snapshots/{{name}}` + +* `creation_timestamp` - + Creation timestamp in RFC3339 text format. + +* `snapshot_id` - + The unique identifier for the resource. + +* `disk_size_gb` - + Size of the snapshot, specified in GB. + +* `storage_bytes` - + A size of the storage used by the snapshot. As snapshots share + storage, this number is expected to change with snapshot + creation/deletion. + +* `licenses` - + A list of public visible licenses that apply to this snapshot. This + can be because the original image had licenses attached (such as a + Windows image). snapshotEncryptionKey nested object Encrypts the + snapshot using a customer-supplied encryption key. + +* `label_fingerprint` - + The fingerprint used for optimistic locking of this resource. Used + internally during updates. +* `self_link` - The URI of the created resource. From 1c02046a61fb0e229d3427f44a22e6589a6ae405 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Fri, 16 Sep 2022 17:13:32 +0000 Subject: [PATCH 2/8] reintroduce a deprecated attribute labels --- ...data_source_google_compute_snapshot.go.erb | 109 ------------- ...resource_dataflow_flex_template_job.go.erb | 15 +- .../terraform/utils/provider.go.erb | 1 - .../docs/d/compute_snapshot.html.markdown | 145 ------------------ 4 files changed, 13 insertions(+), 257 deletions(-) delete mode 100644 mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb delete mode 100644 mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown diff --git a/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb b/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb deleted file mode 100644 index 11c4afa1325d..000000000000 --- a/mmv1/third_party/terraform/data_sources/data_source_google_compute_snapshot.go.erb +++ /dev/null @@ -1,109 +0,0 @@ -<% autogen_exception -%> -package google - -import ( - "fmt" - "log" - "sort" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -<% if version == "ga" -%> - "google.golang.org/api/compute/v1" -<% else -%> - "google.golang.org/api/compute/v0.beta" -<% end -%> -) - -func dataSourceGoogleComputeSnapshot() *schema.Resource { - - // Generate datasource schema from resource - dsSchema := datasourceSchemaFromResourceSchema(resourceComputeSnapshot().Schema) - - dsSchema["filter"] = &schema.Schema{ - Type: schema.TypeString, - Optional: true, - } - dsSchema["most_recent"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - } - - // Set 'Optional' schema elements - addOptionalFieldsToSchema(dsSchema, "name", "filter", "most_recent", "project") - - dsSchema["name"].ExactlyOneOf = []string{"name", "filter"} - dsSchema["filter"].ExactlyOneOf = []string{"name", "filter"} - - return &schema.Resource{ - Read: dataSourceGoogleComputeSnapshotRead, - Schema: dsSchema, - } -} - -func dataSourceGoogleComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*Config) - - project, err := getProject(d, config) - if err != nil { - return err - } - - if v, ok := d.GetOk("name"); ok { - return retrieveSnapshot(d, meta, project, v.(string)) - } - - if v, ok := d.GetOk("filter"); ok { - - userAgent, err := generateUserAgentString(d, config.userAgent) - if err != nil { - return err - } - - if config.UserProjectOverride { - billingProject := project - - // err == nil indicates that the billing_project value was found - if bp, err := getBillingProject(d, config); err == nil { - billingProject = bp - } - projectGetCall.Header().Add("X-Goog-User-Project", billingProject) - } - - snapshots, err := config.NewComputeClient(userAgent).Snapshots.List(project).Filter(v.(string)).Do() - if err != nil { - return fmt.Errorf("error retrieving list of instance snapshots: %s", err) - } - - mostRecent := d.Get("most_recent").(bool) - if mostRecent { - sort.Sort(ByCreationTimestampOfSnapshot(snapshots.Items)) - } - - count := len(snapshots.Items) - if count == 1 || count > 1 && mostRecent { - return retrieveSnapshot(d, meta, project, snapshots.Items[0].Name) - } - - return fmt.Errorf("your filter has returned %d instance snapshot(s). Please refine your filter or set most_recent to return exactly one instance snapshot", len(snapshots.Items)) - - } - - return fmt.Errorf("one of name or filter must be set") - -} - -func retrieveSnapshot(d *schema.ResourceData, meta interface{}, project, name string) error { - d.SetId("projects/" + project + "/global/snapshots/" + name) - d.Set("name", name) - return resourceComputeSnapshotRead(d, meta) -} - -// ByCreationTimestamp implements sort.Interface for []*Snapshot based on -// the CreationTimestamp field. -type ByCreationTimestampOfSnapshot []*compute.Snapshot - -func (a ByCreationTimestampOfSnapshot) Len() int { return len(a) } -func (a ByCreationTimestampOfSnapshot) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a ByCreationTimestampOfSnapshot) Less(i, j int) bool { - return a[i].CreationTimestamp > a[j].CreationTimestamp -} diff --git a/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb b/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb index 0a3f79324966..f845aec7ec5a 100644 --- a/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb +++ b/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb @@ -59,8 +59,6 @@ func resourceDataflowFlexTemplateJob() *schema.Resource { Type: schema.TypeMap, Optional: true, DiffSuppressFunc: resourceDataflowJobLabelDiffSuppress, - // TODO add support for labels when the API supports it - Deprecated: "Deprecated until the API supports this field", }, "parameters": { @@ -119,6 +117,9 @@ func resourceDataflowFlexTemplateJobCreate(d *schema.ResourceData, meta interfac ContainerSpecGcsPath: d.Get("container_spec_gcs_path").(string), JobName: d.Get("name").(string), Parameters: expandStringMap(d, "parameters"), + Environment: &dataflow.FlexTemplateRuntimeEnvironment{ + AdditionalUserLabels: expandStringMap(d, "labels"), + }, }, } @@ -128,6 +129,13 @@ func resourceDataflowFlexTemplateJobCreate(d *schema.ResourceData, meta interfac } job := response.Job + + //adding wait time for setting all the parameters into state file + err = waitForDataflowJobState(d, config, job.Id, userAgent, d.Timeout(schema.TimeoutUpdate), "JOB_STATE_RUNNING") + if err != nil { + return fmt.Errorf("Error waiting for job with job ID %q to be running: %s", d.Id(), err) + } + d.SetId(job.Id) if err := d.Set("job_id", job.Id); err != nil { return fmt.Errorf("Error setting job_id: %s", err) @@ -255,6 +263,9 @@ func resourceDataflowFlexTemplateJobUpdate(d *schema.ResourceData, meta interfac ContainerSpecGcsPath: d.Get("container_spec_gcs_path").(string), JobName: d.Get("name").(string), Parameters: expandStringMap(d, "parameters"), + Environment: &dataflow.FlexTemplateRuntimeEnvironment{ + AdditionalUserLabels: expandStringMap(d, "labels"), + }, Update: true, }, } diff --git a/mmv1/third_party/terraform/utils/provider.go.erb b/mmv1/third_party/terraform/utils/provider.go.erb index 8c97e4a1ede0..fa4f71fc1934 100644 --- a/mmv1/third_party/terraform/utils/provider.go.erb +++ b/mmv1/third_party/terraform/utils/provider.go.erb @@ -232,7 +232,6 @@ func Provider() *schema.Provider { "google_compute_resource_policy": dataSourceGoogleComputeResourcePolicy(), "google_compute_router": dataSourceGoogleComputeRouter(), "google_compute_router_status": dataSourceGoogleComputeRouterStatus(), - "google_compute_snapshot": dataSourceGoogleComputeSnapshot(), "google_compute_ssl_certificate": dataSourceGoogleComputeSslCertificate(), "google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(), "google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(), diff --git a/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown b/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown deleted file mode 100644 index 2775f0f06bbe..000000000000 --- a/mmv1/third_party/terraform/website/docs/d/compute_snapshot.html.markdown +++ /dev/null @@ -1,145 +0,0 @@ ---- -subcategory: "Compute Engine" -page_title: "Google: google_compute_snapshot" -description: |- - Get information about a Google Compute Snapshot. ---- - -# google\_compute\_snapshot - -To get more information about Snapshot, see: - -* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/snapshots) -* How-to Guides - * [Official Documentation](https://cloud.google.com/compute/docs/disks/create-snapshots) - -## Example Usage - -```hcl -#by name -data "google_compute_snapshot" "snapshot" { - name = "my-snapshot" -} - -# using a filter -data "google_compute_snapshot" "latest-snapshot" { - filter = "name != my-snapshot" - most_recent = true -} -``` - -## Argument Reference - -The following arguments are supported: - -* `name` - (Optional) The name of the instance template. One of `name` or `filter` must be provided. - -* `filter` - (Optional) A filter to retrieve the instance templates. - See [gcloud topic filters](https://cloud.google.com/sdk/gcloud/reference/topic/filters) for reference. - If multiple instance templates match, either adjust the filter or specify `most_recent`. One of `name` or `filter` must be provided. - -* `most_recent` - (Optional) If `filter` is provided, ensures the most recent template is returned when multiple instance templates match. One of `name` or `filter` must be provided. - -- - - - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - -## Attributes Reference - -In addition to the arguments listed above, the following computed attributes are exported: - -* `description` - - - An optional description of this resource. - -* `storage_locations` - - - Cloud Storage bucket storage location of the snapshot (regional or multi-regional). - -* `labels` - - - Labels to apply to this Snapshot. - -* `zone` - - - A reference to the zone where the disk is hosted. - -* `snapshot_encryption_key` - - - The customer-supplied encryption key of the snapshot. Required if the - source snapshot is protected by a customer-supplied encryption key. - Structure is [documented below](#nested_snapshot_encryption_key). - -* `source_disk_encryption_key` - - - The customer-supplied encryption key of the source snapshot. Required - if the source snapshot is protected by a customer-supplied encryption - key. - Structure is [documented below](#nested_source_disk_encryption_key). - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - - -The `snapshot_encryption_key` block supports: - -* `raw_key` - - - Specifies a 256-bit customer-supplied encryption key, encoded in - RFC 4648 base64 to either encrypt or decrypt this resource. - **Note**: This property is sensitive and will not be displayed in the plan. - -* `sha256` - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied - encryption key that protects this resource. - -* `kms_key_self_link` - - - The name of the encryption key that is stored in Google Cloud KMS. - -* `kms_key_service_account` - - - The service account used for the encryption request for the given KMS key. - If absent, the Compute Engine Service Agent service account is used. - -The `source_disk_encryption_key` block supports: - -* `raw_key` - - - Specifies a 256-bit customer-supplied encryption key, encoded in - RFC 4648 base64 to either encrypt or decrypt this resource. - **Note**: This property is sensitive and will not be displayed in the plan. - -* `kms_key_service_account` - - - The service account used for the encryption request for the given KMS key. - If absent, the Compute Engine Service Agent service account is used. ---- - -* `id` - an identifier for the resource with format `projects/{{project}}/global/snapshots/{{name}}` - -* `creation_timestamp` - - Creation timestamp in RFC3339 text format. - -* `snapshot_id` - - The unique identifier for the resource. - -* `disk_size_gb` - - Size of the snapshot, specified in GB. - -* `storage_bytes` - - A size of the storage used by the snapshot. As snapshots share - storage, this number is expected to change with snapshot - creation/deletion. - -* `licenses` - - A list of public visible licenses that apply to this snapshot. This - can be because the original image had licenses attached (such as a - Windows image). snapshotEncryptionKey nested object Encrypts the - snapshot using a customer-supplied encryption key. - -* `label_fingerprint` - - The fingerprint used for optimistic locking of this resource. Used - internally during updates. -* `self_link` - The URI of the created resource. From 5eb033a1e2cb3db491bc7453d6d40e9c0e31b48a Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Fri, 16 Sep 2022 17:15:48 +0000 Subject: [PATCH 3/8] changed docs for flex template job labels by removing deprecation note --- .../website/docs/r/dataflow_flex_template_job.html.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown b/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown index 49c1db9ea76a..69bde966b1df 100644 --- a/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/dataflow_flex_template_job.html.markdown @@ -95,8 +95,7 @@ such as `serviceAccount`, `workerMachineType`, etc can be specified here. * `labels` - (Optional) User labels to be specified for the job. Keys and values should follow the restrictions specified in the [labeling restrictions](https://cloud.google.com/compute/docs/labeling-resources#restrictions) -page. **Note**: This field is marked as deprecated in Terraform as the API does not currently -support adding labels. +page. **NOTE**: Google-provided Dataflow templates often provide default labels that begin with `goog-dataflow-provided`. Unless explicitly set in config, these labels will be ignored to prevent diffs on re-apply. From 20a9d7a654ee649de64f0ab63898c13555ef4356 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Mon, 19 Sep 2022 06:49:13 +0000 Subject: [PATCH 4/8] updated the test file --- .../tests/resource_dataflow_flex_template_job_test.go.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb index 3212225a1e56..7e7ac2eab754 100644 --- a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb @@ -210,6 +210,9 @@ resource "google_dataflow_flex_template_job" "job" { qps = "1" %s } + labels = { + "my_labels" = "value" + } } `, job, topicField) } @@ -243,6 +246,9 @@ resource "google_dataflow_flex_template_job" "job" { serviceAccount = google_service_account.dataflow-sa.email zone = "%s" } + labels = { + "my_labels" = "value" + } } `, accountId, job, zone) } From d1acd4d82088834bd1abde1eb4fc98e239ac14f6 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Fri, 30 Sep 2022 10:20:12 +0000 Subject: [PATCH 5/8] remove skipIfVcr func in tests and change job.Id in error of waiting time in create function --- .../resources/resource_dataflow_flex_template_job.go.erb | 2 +- .../tests/resource_dataflow_flex_template_job_test.go.erb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb b/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb index f845aec7ec5a..e09f44e26b17 100644 --- a/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb +++ b/mmv1/third_party/terraform/resources/resource_dataflow_flex_template_job.go.erb @@ -133,7 +133,7 @@ func resourceDataflowFlexTemplateJobCreate(d *schema.ResourceData, meta interfac //adding wait time for setting all the parameters into state file err = waitForDataflowJobState(d, config, job.Id, userAgent, d.Timeout(schema.TimeoutUpdate), "JOB_STATE_RUNNING") if err != nil { - return fmt.Errorf("Error waiting for job with job ID %q to be running: %s", d.Id(), err) + return fmt.Errorf("Error waiting for job with job ID %q to be running: %s", job.Id, err) } d.SetId(job.Id) diff --git a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb index 7e7ac2eab754..0f8efe72623c 100644 --- a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb @@ -22,7 +22,7 @@ import ( func TestAccDataflowFlexTemplateJob_basic(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - skipIfVcr(t) + // skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -46,7 +46,7 @@ func TestAccDataflowFlexTemplateJob_basic(t *testing.T) { func TestAccDataflowFlexTemplateJob_streamUpdate(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - skipIfVcr(t) + // skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -76,7 +76,7 @@ func TestAccDataflowFlexTemplateJob_streamUpdate(t *testing.T) { func TestAccDataflowFlexTemplateJob_streamUpdateFail(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - skipIfVcr(t) + // skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -107,7 +107,7 @@ func TestAccDataflowFlexTemplateJob_streamUpdateFail(t *testing.T) { func TestAccDataflowFlexTemplateJob_withServiceAccount(t *testing.T) { // Dataflow responses include serialized java classes and bash commands // This makes body comparison infeasible - skipIfVcr(t) + // skipIfVcr(t) t.Parallel() randStr := randString(t, 10) From b2fa740c52f9dd27a2dbea388f5dea5195f35cc5 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Mon, 3 Oct 2022 05:22:22 +0000 Subject: [PATCH 6/8] added skipIfVcr func in resource_dataflow_flex_template_job_test --- mmv1/products/compute/terraform.yaml | 2 +- .../tests/resource_dataflow_flex_template_job_test.go.erb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 87c63342a578..44980e4e0d3a 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -735,7 +735,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_name: "fmt.Sprintf(\"tf-test-test-disk%s\", context[\"random_suffix\"])" vars: disk_name: "test-disk" - iam_policy: !ruby/object:Api::Resource::IamPolicy + iam_policy: !auby/object:Api::Resource::IamPolicy method_name_separator: '/' fetch_iam_policy_verb: :GET parent_resource_attribute: 'name' diff --git a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb index 0f8efe72623c..7e7ac2eab754 100644 --- a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb @@ -22,7 +22,7 @@ import ( func TestAccDataflowFlexTemplateJob_basic(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - // skipIfVcr(t) + skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -46,7 +46,7 @@ func TestAccDataflowFlexTemplateJob_basic(t *testing.T) { func TestAccDataflowFlexTemplateJob_streamUpdate(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - // skipIfVcr(t) + skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -76,7 +76,7 @@ func TestAccDataflowFlexTemplateJob_streamUpdate(t *testing.T) { func TestAccDataflowFlexTemplateJob_streamUpdateFail(t *testing.T) { // This resource uses custom retry logic that cannot be sped up without // modifying the actual resource - // skipIfVcr(t) + skipIfVcr(t) t.Parallel() randStr := randString(t, 10) @@ -107,7 +107,7 @@ func TestAccDataflowFlexTemplateJob_streamUpdateFail(t *testing.T) { func TestAccDataflowFlexTemplateJob_withServiceAccount(t *testing.T) { // Dataflow responses include serialized java classes and bash commands // This makes body comparison infeasible - // skipIfVcr(t) + skipIfVcr(t) t.Parallel() randStr := randString(t, 10) From cc2dca8cda9613d740e8ff46f96df1cb029e02ac Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Mon, 3 Oct 2022 06:25:15 +0000 Subject: [PATCH 7/8] commit for testing --- .../tests/resource_dataflow_flex_template_job_test.go.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb index 7e7ac2eab754..39f26b539b28 100644 --- a/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_dataflow_flex_template_job_test.go.erb @@ -104,6 +104,7 @@ func TestAccDataflowFlexTemplateJob_streamUpdateFail(t *testing.T) { }) } + func TestAccDataflowFlexTemplateJob_withServiceAccount(t *testing.T) { // Dataflow responses include serialized java classes and bash commands // This makes body comparison infeasible From fbce49784e99771e1a7a0718e5f8689703c17112 Mon Sep 17 00:00:00 2001 From: Aarsh Dhokai Date: Mon, 3 Oct 2022 06:39:16 +0000 Subject: [PATCH 8/8] fixing typo --- mmv1/products/compute/terraform.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 44980e4e0d3a..87c63342a578 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -735,7 +735,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_name: "fmt.Sprintf(\"tf-test-test-disk%s\", context[\"random_suffix\"])" vars: disk_name: "test-disk" - iam_policy: !auby/object:Api::Resource::IamPolicy + iam_policy: !ruby/object:Api::Resource::IamPolicy method_name_separator: '/' fetch_iam_policy_verb: :GET parent_resource_attribute: 'name'