From 478e152aaa91be105e5df227f4cab7a6461c7ec5 Mon Sep 17 00:00:00 2001 From: sophieyfang Date: Wed, 3 Feb 2021 15:11:24 -0500 Subject: [PATCH] feat: Promote alpha to beta (#11) * Promote alpha to beta * Bump google-beta version to >=3.38 * Upgrade beta to 3.54.0 * Pin google-cloud-sdk version to '325.0.0' * Change dockerfile to use 0.14.9 * Update project-factory version. * More * More * Formatting --- Makefile | 2 +- build/int.cloudbuild.yaml | 2 +- build/lint.cloudbuild.yaml | 2 +- .../agent_policy_detailed_example/README.md | 8 +++++-- .../agent_policy_simple_example/README.md | 8 +++++-- .../agent_policy_update_example/README.md | 20 +++++++++------- modules/agent-policy/README.md | 24 +++++++++++-------- modules/agent-policy/main.tf | 7 +++--- modules/agent-policy/scripts/script-utils.sh | 2 +- .../agent-policy-tests/test-script-utils.bats | 18 +++++++------- .../controls/gcloud.rb | 2 +- .../controls/gcloud.rb | 2 +- .../controls/gcloud.rb | 2 +- test/setup/main.tf | 13 +++++----- test/setup/versions.tf | 4 ++-- 15 files changed, 66 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 7be14d7..d93beef 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ # Make will use bash instead of sh SHELL := /usr/bin/env bash -DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13.7 +DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.14.9 DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools REGISTRY_URL := gcr.io/cloud-foundation-cicd diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml index 20fadad..93f304e 100644 --- a/build/int.cloudbuild.yaml +++ b/build/int.cloudbuild.yaml @@ -45,4 +45,4 @@ tags: - 'bats' substitutions: _DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools' - _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13.7' + _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.14.9' diff --git a/build/lint.cloudbuild.yaml b/build/lint.cloudbuild.yaml index 3451db6..d886ffc 100644 --- a/build/lint.cloudbuild.yaml +++ b/build/lint.cloudbuild.yaml @@ -21,4 +21,4 @@ tags: - 'lint' substitutions: _DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools' - _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13.7' + _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.14.9' diff --git a/examples/agent_policy_detailed_example/README.md b/examples/agent_policy_detailed_example/README.md index d7a94b8..3e2a2ff 100644 --- a/examples/agent_policy_detailed_example/README.md +++ b/examples/agent_policy_detailed_example/README.md @@ -6,8 +6,12 @@ This example illustrates how to use the `agent-policy` module. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| project\_id | The ID of the project in which to provision resources. | string | n/a | yes | +|------|-------------|------|---------|:--------:| +| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | + +## Outputs + +No output. diff --git a/examples/agent_policy_simple_example/README.md b/examples/agent_policy_simple_example/README.md index d7a94b8..3e2a2ff 100644 --- a/examples/agent_policy_simple_example/README.md +++ b/examples/agent_policy_simple_example/README.md @@ -6,8 +6,12 @@ This example illustrates how to use the `agent-policy` module. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| project\_id | The ID of the project in which to provision resources. | string | n/a | yes | +|------|-------------|------|---------|:--------:| +| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | + +## Outputs + +No output. diff --git a/examples/agent_policy_update_example/README.md b/examples/agent_policy_update_example/README.md index d30a5c6..6b262c6 100644 --- a/examples/agent_policy_update_example/README.md +++ b/examples/agent_policy_update_example/README.md @@ -6,14 +6,18 @@ This example is specifically for testing update functionality. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| agent\_rules | A list of agent rules to be enforced by the policy. | list(any) | n/a | yes | -| description | The description of the policy. | string | `"null"` | no | -| group\_labels | A list of label maps to filter instances to apply policies on. | object | `"null"` | no | -| instances | A list of zones to filter instances to apply the policy. | list(string) | `"null"` | no | -| os\_types | A list of label maps to filter instances to apply policies on. | list(any) | n/a | yes | -| project\_id | The ID of the project in which to provision resources. | string | n/a | yes | -| zones | A list of zones to filter instances to apply the policy. | list(string) | `"null"` | no | +|------|-------------|------|---------|:--------:| +| agent\_rules | A list of agent rules to be enforced by the policy. | `list(any)` | n/a | yes | +| description | The description of the policy. | `string` | `null` | no | +| group\_labels | A list of label maps to filter instances to apply policies on. | `list(map(string))` | `null` | no | +| instances | A list of zones to filter instances to apply the policy. | `list(string)` | `null` | no | +| os\_types | A list of label maps to filter instances to apply policies on. | `list(any)` | n/a | yes | +| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | +| zones | A list of zones to filter instances to apply the policy. | `list(string)` | `null` | no | + +## Outputs + +No output. diff --git a/modules/agent-policy/README.md b/modules/agent-policy/README.md index c6ca424..5127c98 100644 --- a/modules/agent-policy/README.md +++ b/modules/agent-policy/README.md @@ -48,15 +48,19 @@ Functional examples are included in the [examples](./../../examples) directory. ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| agent\_rules | A list of agent rules to be enforced by the policy. | list(any) | n/a | yes | -| description | The description of the policy. | string | `"null"` | no | -| group\_labels | A list of label maps to filter instances to apply policies on. | list(map(string)) | `"null"` | no | -| instances | A list of instances to filter instances to apply the policy. | list(string) | `"null"` | no | -| os\_types | A list of OS types to filter instances to apply the policy. | list(any) | n/a | yes | -| policy\_id | The ID of the policy. | string | n/a | yes | -| project\_id | The ID of the project in which to provision resources. | string | n/a | yes | -| zones | A list of zones to filter instances to apply the policy. | list(string) | `"null"` | no | +|------|-------------|------|---------|:--------:| +| agent\_rules | A list of agent rules to be enforced by the policy. | `list(any)` | n/a | yes | +| description | The description of the policy. | `string` | `null` | no | +| group\_labels | A list of label maps to filter instances to apply policies on. | `list(map(string))` | `null` | no | +| instances | A list of instances to filter instances to apply the policy. | `list(string)` | `null` | no | +| os\_types | A list of OS types to filter instances to apply the policy. | `list(any)` | n/a | yes | +| policy\_id | The ID of the policy. | `string` | n/a | yes | +| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes | +| zones | A list of zones to filter instances to apply the policy. | `list(string)` | `null` | no | + +## Outputs + +No output. @@ -165,4 +169,4 @@ information on contributing to this module. [curl]: https://curl.haxx.se [google-cloud-sdk]: https://cloud.google.com/sdk/install [os-config-metadata]: https://cloud.google.com/compute/docs/manage-os#enable-metadata -[ops-agents-policy-docs]: https://cloud.google.com/sdk/gcloud/reference/alpha/compute/instances/ops-agents/policies/create +[ops-agents-policy-docs]: https://cloud.google.com/sdk/gcloud/reference/beta/compute/instances/ops-agents/policies/create diff --git a/modules/agent-policy/main.tf b/modules/agent-policy/main.tf index e6d62f1..f41f955 100644 --- a/modules/agent-policy/main.tf +++ b/modules/agent-policy/main.tf @@ -18,8 +18,8 @@ module "gcloud-upsert" { source = "terraform-google-modules/gcloud/google" platform = "linux" - additional_components = ["alpha"] - + additional_components = ["beta"] + gcloud_sdk_version = "325.0.0" create_cmd_entrypoint = abspath("${path.module}/scripts/create-update-script.sh") create_cmd_body = <<-EOT ${var.project_id} ${jsonencode(var.policy_id)} \ @@ -37,7 +37,8 @@ module "gcloud-destroy" { source = "terraform-google-modules/gcloud/google" platform = "linux" - additional_components = ["alpha"] + gcloud_sdk_version = "325.0.0" + additional_components = ["beta"] destroy_cmd_entrypoint = abspath("${path.module}/scripts/delete-script.sh") destroy_cmd_body = "${var.project_id} ${jsonencode(var.policy_id)}" diff --git a/modules/agent-policy/scripts/script-utils.sh b/modules/agent-policy/scripts/script-utils.sh index e898806..ed5d315 100644 --- a/modules/agent-policy/scripts/script-utils.sh +++ b/modules/agent-policy/scripts/script-utils.sh @@ -23,7 +23,7 @@ CREATE="create" UPDATE="update" -LAUNCH_STAGE="alpha" +LAUNCH_STAGE="beta" # Params: diff --git a/test/agent-policy-tests/test-script-utils.bats b/test/agent-policy-tests/test-script-utils.bats index e360853..8fb4445 100644 --- a/test/agent-policy-tests/test-script-utils.bats +++ b/test/agent-policy-tests/test-script-utils.bats @@ -52,7 +52,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --agent-rules='type=metrics'" expected_command="$expected_command --os-types='version=8,short-name=centos'" @@ -73,7 +73,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --description='an example test policy'" expected_command="$expected_command --agent-rules='type=metrics'" @@ -97,7 +97,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --agent-rules='version=current-major," expected_command="${expected_command}type=logging,enable-autoupgrade=true," @@ -121,7 +121,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --agent-rules='type=metrics'" expected_command="$expected_command --group-labels='product=myapp,env=prod;" @@ -144,7 +144,7 @@ setup() { local zones_json="[\"us-central1-c\",\"asia-northeast2-b\",\"europe-north1-b\"]" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --agent-rules='type=metrics'" expected_command="$expected_command --os-types='version=8,short-name=centos'" @@ -167,7 +167,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="[\"zones/us-central1-a/instances/test-instance\"]" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies create ops-agents-test-policy" expected_command="$expected_command --agent-rules='type=metrics'" expected_command="$expected_command --os-types='version=8,short-name=centos'" @@ -196,7 +196,7 @@ setup() { local zones_json="$EMPTY_LIST_JSON" local instances_json="$EMPTY_LIST_JSON" - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies update ops-agents-test-policy" expected_command="$expected_command --agent-rules='type=metrics'" expected_command="$expected_command --os-types='version=8,short-name=centos'" @@ -220,7 +220,7 @@ setup() { ############################################################## @test "Test get_describe_command" { - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies describe ops-agents-test-policy" expected_command="$expected_command --project='test-project-id' --quiet" @@ -235,7 +235,7 @@ setup() { ############################################################## @test "Test get_delete_command" { - local expected_command="gcloud alpha compute instances ops-agents" + local expected_command="gcloud beta compute instances ops-agents" expected_command="$expected_command policies delete ops-agents-test-policy" expected_command="$expected_command --project='test-project-id' --quiet" diff --git a/test/integration/agent_policy_detailed_example/controls/gcloud.rb b/test/integration/agent_policy_detailed_example/controls/gcloud.rb index daf7769..e66d5d3 100644 --- a/test/integration/agent_policy_detailed_example/controls/gcloud.rb +++ b/test/integration/agent_policy_detailed_example/controls/gcloud.rb @@ -23,7 +23,7 @@ its(:stdout) { should match "osconfig.googleapis.com" } end - describe command("gcloud alpha compute instances ops-agents policies describe " \ + describe command("gcloud beta compute instances ops-agents policies describe " \ "ops-agents-test-policy-detailed --project=#{attribute("project_id")} --quiet") do its(:exit_status) { should eq 0 } its(:stderr) { should eq "" } diff --git a/test/integration/agent_policy_simple_example/controls/gcloud.rb b/test/integration/agent_policy_simple_example/controls/gcloud.rb index a5ed2ba..826756d 100644 --- a/test/integration/agent_policy_simple_example/controls/gcloud.rb +++ b/test/integration/agent_policy_simple_example/controls/gcloud.rb @@ -23,7 +23,7 @@ its(:stdout) { should match "osconfig.googleapis.com" } end - describe command("gcloud alpha compute instances ops-agents policies describe " \ + describe command("gcloud beta compute instances ops-agents policies describe " \ "ops-agents-test-policy-simple --project=#{attribute("project_id")} --quiet") do its(:exit_status) { should eq 0 } its(:stderr) { should eq "" } diff --git a/test/integration/agent_policy_update_example/controls/gcloud.rb b/test/integration/agent_policy_update_example/controls/gcloud.rb index 9ff33fb..ec06bd2 100644 --- a/test/integration/agent_policy_update_example/controls/gcloud.rb +++ b/test/integration/agent_policy_update_example/controls/gcloud.rb @@ -23,7 +23,7 @@ control "gcloud" do title "gcloud" - describe command("gcloud alpha compute instances ops-agents policies describe " \ + describe command("gcloud beta compute instances ops-agents policies describe " \ "ops-agents-test-policy-update --project=#{attribute("project_id")} " \ "--quiet --format=json") do its(:exit_status) { should eq 0 } diff --git a/test/setup/main.tf b/test/setup/main.tf index dca97cc..21c8f93 100644 --- a/test/setup/main.tf +++ b/test/setup/main.tf @@ -16,14 +16,13 @@ module "project" { source = "terraform-google-modules/project-factory/google" - version = "~> 9.0" + version = "~> 10.0" - name = "ci-cloud-operations" - random_project_id = "true" - org_id = var.org_id - folder_id = var.folder_id - billing_account = var.billing_account - skip_gcloud_download = true + name = "ci-cloud-operations" + random_project_id = "true" + org_id = var.org_id + folder_id = var.folder_id + billing_account = var.billing_account activate_apis = [ "cloudresourcemanager.googleapis.com", diff --git a/test/setup/versions.tf b/test/setup/versions.tf index ccfe86d..5c355ee 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -19,9 +19,9 @@ terraform { } provider "google" { - version = "~> 3.25.0" + version = ">= 3.25.0" } provider "google-beta" { - version = "~> 3.25.0" + version = ">= 3.54.0" }