diff --git a/mmv1/products/networksecurity/AddressGroup.yaml b/mmv1/products/networksecurity/AddressGroup.yaml index 87d2b9a19951..9eb537c19f39 100644 --- a/mmv1/products/networksecurity/AddressGroup.yaml +++ b/mmv1/products/networksecurity/AddressGroup.yaml @@ -26,8 +26,28 @@ references: guides: "Use AddressGroups": "https://cloud.google.com/vpc/docs/use-address-groups-firewall-policies" api: "https://cloud.google.com/traffic-director/docs/reference/network-security/rest/v1beta1/organizations.locations.addressGroups" -# Prevent the operation from being generated so we can call the custom one. -autogen_async: false +autogen_async: true +async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 20 + update_minutes: 20 + delete_minutes: 20 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: true + allowed: + - true + - false + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + include_project: true import_format: ["{{%parent}}/locations/{{location}}/addressGroups/{{name}}"] examples: - !ruby/object:Provider::Terraform::Examples @@ -53,9 +73,9 @@ examples: project: :PROJECT_NAME custom_code: !ruby/object:Provider::Terraform::CustomCode # Calling custom operation that are different from other network security resources. - post_create: templates/terraform/post_create/network_security_address_group_operation.go.erb - post_update: templates/terraform/post_update/network_security_address_group_operation.go.erb - post_delete: templates/terraform/post_delete/network_security_address_group_operation.go.erb + pre_create: templates/terraform/pre_create/network_security_address_group_operation.go.erb + pre_update: templates/terraform/pre_update/network_security_address_group_operation.go.erb + pre_delete: templates/terraform/pre_delete/network_security_address_group_operation.go.erb parameters: - !ruby/object:Api::Type::String name: parent diff --git a/mmv1/templates/terraform/post_create/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/post_create/network_security_address_group_operation.go.erb deleted file mode 100644 index 00856471f3f0..000000000000 --- a/mmv1/templates/terraform/post_create/network_security_address_group_operation.go.erb +++ /dev/null @@ -1,9 +0,0 @@ -err = NetworkSecurityAddressGroupOperationWaitTime( - config, res, "Creating AddressGroup", userAgent, - d.Timeout(schema.TimeoutCreate)) - -if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create AddressGroup: %s", err) -} \ No newline at end of file diff --git a/mmv1/templates/terraform/post_delete/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/post_delete/network_security_address_group_operation.go.erb deleted file mode 100644 index fd92b7a9c63f..000000000000 --- a/mmv1/templates/terraform/post_delete/network_security_address_group_operation.go.erb +++ /dev/null @@ -1,7 +0,0 @@ -err = NetworkSecurityAddressGroupOperationWaitTime( - config, res, "Deleting AddressGroup", userAgent, - d.Timeout(schema.TimeoutDelete)) - -if err != nil { - return err -} \ No newline at end of file diff --git a/mmv1/templates/terraform/post_update/cloudbuild_bitbucketserver_config.go.erb b/mmv1/templates/terraform/post_update/cloudbuild_bitbucketserver_config.go.erb index ea7bf250862a..c8368000fbed 100644 --- a/mmv1/templates/terraform/post_update/cloudbuild_bitbucketserver_config.go.erb +++ b/mmv1/templates/terraform/post_update/cloudbuild_bitbucketserver_config.go.erb @@ -21,7 +21,7 @@ if d.HasChange("connected_repositories") { for _, repo := range removeRepos { obj := make(map[string]interface{}) obj["connectedRepository"] = repo - res, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, @@ -61,7 +61,7 @@ if d.HasChange("connected_repositories") { return err } - res, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, diff --git a/mmv1/templates/terraform/post_update/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/post_update/network_security_address_group_operation.go.erb deleted file mode 100644 index cea6431f3fd2..000000000000 --- a/mmv1/templates/terraform/post_update/network_security_address_group_operation.go.erb +++ /dev/null @@ -1,7 +0,0 @@ -err = NetworkSecurityAddressGroupOperationWaitTime( - config, res, "Updating AddressGroup", userAgent, - d.Timeout(schema.TimeoutUpdate)) - -if err != nil { - return err -} \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_create/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/pre_create/network_security_address_group_operation.go.erb new file mode 100644 index 000000000000..e06fc5dfb184 --- /dev/null +++ b/mmv1/templates/terraform/pre_create/network_security_address_group_operation.go.erb @@ -0,0 +1 @@ +project = "" \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_delete/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/pre_delete/network_security_address_group_operation.go.erb new file mode 100644 index 000000000000..e06fc5dfb184 --- /dev/null +++ b/mmv1/templates/terraform/pre_delete/network_security_address_group_operation.go.erb @@ -0,0 +1 @@ +project = "" \ No newline at end of file diff --git a/mmv1/templates/terraform/pre_update/network_security_address_group_operation.go.erb b/mmv1/templates/terraform/pre_update/network_security_address_group_operation.go.erb new file mode 100644 index 000000000000..e06fc5dfb184 --- /dev/null +++ b/mmv1/templates/terraform/pre_update/network_security_address_group_operation.go.erb @@ -0,0 +1 @@ +project = "" \ No newline at end of file diff --git a/mmv1/templates/terraform/resource.erb b/mmv1/templates/terraform/resource.erb index 38461737ca95..bdc6c65af96e 100644 --- a/mmv1/templates/terraform/resource.erb +++ b/mmv1/templates/terraform/resource.erb @@ -792,7 +792,7 @@ func resource<%= resource_name -%>Update(d *schema.ResourceData, meta interface{ billingProject = bp } -<% if object.update_mask && field_specific_update_methods(object.root_properties) -%> +<% if object.update_mask -%> // if updateMask is empty we are not updating anything so skip the post if len(updateMask) > 0 { <% end -%> @@ -838,7 +838,7 @@ if len(updateMask) > 0 { } <% end -%> <% end -%> -<% if object.update_mask && field_specific_update_methods(object.root_properties) -%> +<% if object.update_mask -%> } <% end -%> <% end # if !object.immutable -%> diff --git a/mmv1/third_party/terraform/services/networksecurity/network_security_address_group_operation.go.erb b/mmv1/third_party/terraform/services/networksecurity/network_security_address_group_operation.go.erb deleted file mode 100644 index 2f98e9be1803..000000000000 --- a/mmv1/third_party/terraform/services/networksecurity/network_security_address_group_operation.go.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% autogen_exception -%> -package networksecurity - -import ( - "time" - - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -// NetworkSecurityAddressGroupOperationWaitTime is specific for address group resource because the only difference is that it does not need project param. -func NetworkSecurityAddressGroupOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string, timeout time.Duration) error { - // project is not necessary for this operation. - return NetworkSecurityOperationWaitTime(config, op, "", activity, userAgent, timeout) -} diff --git a/mmv1/third_party/terraform/services/pubsub/resource_pubsub_topic_test.go b/mmv1/third_party/terraform/services/pubsub/resource_pubsub_topic_test.go index 41d8e7a58182..b5f13d882c1f 100644 --- a/mmv1/third_party/terraform/services/pubsub/resource_pubsub_topic_test.go +++ b/mmv1/third_party/terraform/services/pubsub/resource_pubsub_topic_test.go @@ -103,6 +103,43 @@ func TestAccPubsubTopic_schema(t *testing.T) { }) } +func TestAccPubsubTopic_migration(t *testing.T) { + acctest.SkipIfVcr(t) + t.Parallel() + + topic := fmt.Sprintf("tf-test-topic-%s", acctest.RandString(t, 10)) + + oldVersion := map[string]resource.ExternalProvider{ + "google": { + VersionConstraint: "4.84.0", // a version that doesn't separate user defined labels and system labels + Source: "registry.terraform.io/hashicorp/google", + }, + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + CheckDestroy: testAccCheckPubsubTopicDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccPubsubTopic_update(topic, "foo", "bar"), + ExternalProviders: oldVersion, + }, + { + Config: testAccPubsubTopic_update(topic, "foo", "bar"), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + }, + { + ResourceName: "google_pubsub_topic.foo", + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + ImportStateId: topic, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, + }, + }, + }) +} + func testAccPubsubTopic_update(topic, key, value string) string { return fmt.Sprintf(` resource "google_pubsub_topic" "foo" {