Skip to content

Commit

Permalink
Promote Cloud Deploy Automation to GA (GoogleCloudPlatform#10043)
Browse files Browse the repository at this point in the history
* Add Cloud Deploy Automation

* Attempt to solve the test errors based on https://yaqs.corp.google.com/eng/q/7753655943518224384

* Add update test for the new automation resource

* fix lint errors

* fix lint errors

* fix errors in GA provider test

* add the missing test

* add a full test

* Attempt to fix the acceptance test errors

* fix a lint error

* mark labels as default_from_api:true

* fix advance rollout rule definition

* Mark service_account as 'ignore_read: true'

* Fix test errors

* Resolve review comments

* Format test file

* promote google_clouddeploy_automation to GA

* promote google_clouddeploy_automation to GA

* fix lint errors
  • Loading branch information
ChrisGe4 authored and balanaguharsha committed May 2, 2024
1 parent 3989bab commit 1aa11b4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 52 deletions.
5 changes: 2 additions & 3 deletions mmv1/products/clouddeploy/Automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.automations'
base_url: 'projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations'
self_link: 'projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations/{{name}}'
min_version: beta

create_url: 'projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations?automationId={{name}}'
update_verb: :PATCH
update_mask: true
Expand Down Expand Up @@ -51,7 +51,6 @@ autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "clouddeploy_automation_basic"
min_version: beta
primary_resource_id: "b-automation"
vars:
automation: "cd-automation"
Expand All @@ -60,7 +59,7 @@ examples:
service_account: :SERVICE_ACCT
- !ruby/object:Provider::Terraform::Examples
name: "clouddeploy_automation_full"
min_version: beta

primary_resource_id: "f-automation"
vars:
automation: "cd-automation"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_clouddeploy_automation" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['automation'] %>"
project = google_clouddeploy_delivery_pipeline.pipeline.project
location = google_clouddeploy_delivery_pipeline.pipeline.location
Expand All @@ -19,7 +18,6 @@ resource "google_clouddeploy_automation" "<%= ctx[:primary_resource_id] %>" {
}

resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "<%= ctx[:vars]['delivery_pipeline'] %>"
location = "us-central1"
serial_pipeline {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_clouddeploy_automation" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['automation'] %>"
location = "us-central1"
delivery_pipeline = google_clouddeploy_delivery_pipeline.pipeline.name
Expand Down Expand Up @@ -40,7 +39,6 @@ resource "google_clouddeploy_automation" "<%= ctx[:primary_resource_id] %>" {
}

resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "<%= ctx[:vars]['delivery_pipeline'] %>"
location = "us-central1"
serial_pipeline {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,52 @@
<% autogen_exception -%>
package clouddeploy_test


<% unless version == 'ga' -%>
import (
"testing"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
)

func TestAccClouddeployAutomation_update(t *testing.T) {
t.Parallel()
t.Parallel()

context := map[string]interface{}{
"service_account": envvar.GetTestServiceAccountFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}
context := map[string]interface{}{
"service_account": envvar.GetTestServiceAccountFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
CheckDestroy: testAccCheckClouddeployAutomationDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccClouddeployAutomation_basic(context),
},
{
ResourceName: "google_clouddeploy_automation.automation",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "delivery_pipeline", "annotations", "labels", "terraform_labels"},
},
{
Config: testAccClouddeployAutomation_update(context),
},
{
ResourceName: "google_clouddeploy_automation.automation",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "delivery_pipeline", "annotations", "labels", "terraform_labels"},
},
},
})
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckClouddeployAutomationDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccClouddeployAutomation_basic(context),
},
{
ResourceName: "google_clouddeploy_automation.automation",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "delivery_pipeline", "annotations", "labels", "terraform_labels"},
},
{
Config: testAccClouddeployAutomation_update(context),
},
{
ResourceName: "google_clouddeploy_automation.automation",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "delivery_pipeline", "annotations", "labels", "terraform_labels"},
},
},
})
}

func testAccClouddeployAutomation_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
return acctest.Nprintf(`
resource "google_clouddeploy_automation" "automation" {
provider = google-beta
name = "tf-test-cd-automation%{random_suffix}"
location = "us-central1"
delivery_pipeline = google_clouddeploy_delivery_pipeline.pipeline.name
Expand All @@ -71,7 +67,6 @@ resource "google_clouddeploy_automation" "automation" {
}
resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "tf-test-cd-pipeline%{random_suffix}"
location = "us-central1"
serial_pipeline {
Expand All @@ -85,10 +80,9 @@ resource "google_clouddeploy_delivery_pipeline" "pipeline" {
}

func testAccClouddeployAutomation_update(context map[string]interface{}) string {
return acctest.Nprintf(`
return acctest.Nprintf(`
resource "google_clouddeploy_automation" "automation" {
provider = google-beta
name = "tf-test-cd-automation%{random_suffix}"
location = "us-central1"
delivery_pipeline = google_clouddeploy_delivery_pipeline.pipeline.name
Expand Down Expand Up @@ -129,7 +123,6 @@ resource "google_clouddeploy_automation" "automation" {
}
resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "tf-test-cd-pipeline%{random_suffix}"
location = "us-central1"
serial_pipeline {
Expand All @@ -141,5 +134,3 @@ resource "google_clouddeploy_delivery_pipeline" "pipeline" {
}
`, context)
}
<% end -%>

0 comments on commit 1aa11b4

Please sign in to comment.