Skip to content

Commit

Permalink
containerattached: Add deletion policy. (GoogleCloudPlatform#7134)
Browse files Browse the repository at this point in the history
  • Loading branch information
hankfreund authored and ericayyliu committed Jul 26, 2023
1 parent 18db94e commit b73db30
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mmv1/products/containerattached/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides
primary_resource_id: "primary"
vars:
name: "basic"
- !ruby/object:Provider::Terraform::Examples
name: "container_attached_cluster_ignore_errors"
primary_resource_name: "fmt.Sprintf(\"basic%s\", context[\"random_suffix\"])"
primary_resource_id: "primary"
vars:
name: "basic"
ignore_read_extra:
- "deletion_policy"
properties:
# The proto format of the authorization field is cumbersome to express in TF, so use a custom expander
# and flattener to massage the data.
Expand Down Expand Up @@ -59,6 +67,15 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: templates/terraform/constants/containerattached_cluster_diff.go
pre_update: templates/terraform/pre_update/containerattached_update.go.erb
pre_delete: templates/terraform/pre_delete/container_attached_deletion_policy.go.erb
virtual_fields:
- !ruby/object:Api::Type::Enum
name: 'deletion_policy'
description: 'Policy to determine what flags to send on delete.'
values:
- :DELETE
- :DELETE_IGNORE_ERRORS
default_value: :DELETE
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data "google_project" "project" {
}

data "google_container_attached_versions" "versions" {
location = "us-west1"
project = data.google_project.project.project_id
}

resource "google_container_attached_cluster" "primary" {
name = "<%= ctx[:vars]['name'] %>"
location = "us-west1"
project = data.google_project.project.project_id
description = "Test cluster"
distribution = "aks"
oidc_config {
issuer_url = "https://oidc.issuer.url"
}
platform_version = data.google_container_attached_versions.versions.valid_versions[0]
fleet {
project = "projects/${data.google_project.project.number}"
}

deletion_policy = "DELETE_IGNORE_ERRORS"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if v, ok := d.GetOk("deletion_policy"); ok {
if v == "DELETE_IGNORE_ERRORS" {
url, err = addQueryParams(url, map[string]string{"ignore_errors": "true"})
if err != nil {
return err
}
}
}

0 comments on commit b73db30

Please sign in to comment.