From c82da4ceceaadb013a42f5d12634a35ed0ed337a Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Thu, 25 Jun 2026 08:29:39 +0000 Subject: [PATCH 1/4] remove value in admission cache policy --- mmv1/products/storage/AnywhereCache.yaml | 8 +++++-- ...ge_anywhere_cache_admission_policy.go.tmpl | 22 +++++++++++++++++++ .../tpgresource/common_diff_suppress.go | 11 ++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 mmv1/templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl diff --git a/mmv1/products/storage/AnywhereCache.yaml b/mmv1/products/storage/AnywhereCache.yaml index 0f1f6bc20429..f1b0baa02ce5 100644 --- a/mmv1/products/storage/AnywhereCache.yaml +++ b/mmv1/products/storage/AnywhereCache.yaml @@ -71,11 +71,15 @@ properties: description: The zone in which the cache instance needs to be created. For example, `us-central1-a.` - name: admissionPolicy type: Enum + default_value: admit-on-first-miss + description: | + The cache admission policy dictates whether a block should be inserted upon a cache miss. + Note: "admit-on-second-miss" is deprecated and will fallback to "admit-on-first-miss". enum_values: - admit-on-first-miss - admit-on-second-miss - default_value: admit-on-first-miss - description: The cache admission policy dictates whether a block should be inserted upon a cache miss. + diff_suppress_func: tpgresource.StorageAnywhereCacheAdmissionPolicyDiffSuppress + custom_expand: templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl - name: ttl type: String default_value: 86400s diff --git a/mmv1/templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl b/mmv1/templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl new file mode 100644 index 000000000000..623ddc93edfb --- /dev/null +++ b/mmv1/templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl @@ -0,0 +1,22 @@ +{{/* + The license inside this block applies to this file + Copyright 2026 Google Inc. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ -}} +func expand{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + if v == nil { + return nil, nil + } + s := v.(string) + if s == "admit-on-second-miss" { + return "admit-on-first-miss", nil + } + return s, nil +} diff --git a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go index 43975b4c007b..18d2bc8532fd 100644 --- a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go +++ b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go @@ -161,3 +161,14 @@ func Base64DiffSuppress(_, old, new string, _ *schema.ResourceData) bool { func CaseInsensitiveHash(v interface{}) int { return Hashcode(strings.ToLower(v.(string))) } + +// Suppresses diffs for Anywhere Cache admission policy where "admit-on-second-miss" +// is deprecated and falls back to "admit-on-first-miss". +func StorageAnywhereCacheAdmissionPolicyDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { + if old == new { + return true + } + return (old == "admit-on-first-miss" && new == "admit-on-second-miss") || + (old == "admit-on-second-miss" && new == "admit-on-first-miss") +} + From 383351d1a6f86e8328d4b6c368373defe4941d60 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Thu, 25 Jun 2026 08:54:35 +0000 Subject: [PATCH 2/4] update --- mmv1/products/storage/AnywhereCache.yaml | 4 +++- .../constants/storage_anywhere_cache.go.tmpl | 21 +++++++++++++++++++ .../tpgresource/common_diff_suppress.go | 10 --------- 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 mmv1/templates/terraform/constants/storage_anywhere_cache.go.tmpl diff --git a/mmv1/products/storage/AnywhereCache.yaml b/mmv1/products/storage/AnywhereCache.yaml index f1b0baa02ce5..7e66d629b299 100644 --- a/mmv1/products/storage/AnywhereCache.yaml +++ b/mmv1/products/storage/AnywhereCache.yaml @@ -43,6 +43,7 @@ async: resource_inside_response: true autogen_async: false custom_code: + constants: templates/terraform/constants/storage_anywhere_cache.go.tmpl custom_create: templates/terraform/custom_create/storage_anywhere_cache.go.tmpl custom_update: templates/terraform/custom_update/storage_anywhere_cache.go.tmpl samples: @@ -72,13 +73,14 @@ properties: - name: admissionPolicy type: Enum default_value: admit-on-first-miss + deprecation_message: '`admission_policy` is deprecated and will be removed in a future major release. The backend will ignore this attribute and treat it as `admit-on-first-miss`.' description: | The cache admission policy dictates whether a block should be inserted upon a cache miss. Note: "admit-on-second-miss" is deprecated and will fallback to "admit-on-first-miss". enum_values: - admit-on-first-miss - admit-on-second-miss - diff_suppress_func: tpgresource.StorageAnywhereCacheAdmissionPolicyDiffSuppress + diff_suppress_func: StorageAnywhereCacheAdmissionPolicyDiffSuppress custom_expand: templates/terraform/custom_expand/storage_anywhere_cache_admission_policy.go.tmpl - name: ttl type: String diff --git a/mmv1/templates/terraform/constants/storage_anywhere_cache.go.tmpl b/mmv1/templates/terraform/constants/storage_anywhere_cache.go.tmpl new file mode 100644 index 000000000000..a1907c17b391 --- /dev/null +++ b/mmv1/templates/terraform/constants/storage_anywhere_cache.go.tmpl @@ -0,0 +1,21 @@ +{{/* + The license inside this block applies to this file + Copyright 2026 Google Inc. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ -}} +// Suppresses diffs for Anywhere Cache admission policy where "admit-on-second-miss" +// is deprecated and falls back to "admit-on-first-miss". +func StorageAnywhereCacheAdmissionPolicyDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { + if old == new { + return true + } + return (old == "admit-on-first-miss" && new == "admit-on-second-miss") || + (old == "admit-on-second-miss" && new == "admit-on-first-miss") +} diff --git a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go index 18d2bc8532fd..138b5e13b374 100644 --- a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go +++ b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go @@ -162,13 +162,3 @@ func CaseInsensitiveHash(v interface{}) int { return Hashcode(strings.ToLower(v.(string))) } -// Suppresses diffs for Anywhere Cache admission policy where "admit-on-second-miss" -// is deprecated and falls back to "admit-on-first-miss". -func StorageAnywhereCacheAdmissionPolicyDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { - if old == new { - return true - } - return (old == "admit-on-first-miss" && new == "admit-on-second-miss") || - (old == "admit-on-second-miss" && new == "admit-on-first-miss") -} - From 4ff0e36e6ac483ea94b7075262aaf2e24eb26b47 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Thu, 25 Jun 2026 09:56:08 +0000 Subject: [PATCH 3/4] update --- mmv1/products/storage/AnywhereCache.yaml | 2 +- mmv1/third_party/terraform/tpgresource/common_diff_suppress.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/mmv1/products/storage/AnywhereCache.yaml b/mmv1/products/storage/AnywhereCache.yaml index 7e66d629b299..e6030b42d6d0 100644 --- a/mmv1/products/storage/AnywhereCache.yaml +++ b/mmv1/products/storage/AnywhereCache.yaml @@ -73,7 +73,7 @@ properties: - name: admissionPolicy type: Enum default_value: admit-on-first-miss - deprecation_message: '`admission_policy` is deprecated and will be removed in a future major release. The backend will ignore this attribute and treat it as `admit-on-first-miss`.' + deprecation_message: '`admit-on-second-miss` is deprecated and will be removed in a future major release. The backend will ignore this attribute and treat it as `admit-on-first-miss`.' description: | The cache admission policy dictates whether a block should be inserted upon a cache miss. Note: "admit-on-second-miss" is deprecated and will fallback to "admit-on-first-miss". diff --git a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go index 138b5e13b374..43975b4c007b 100644 --- a/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go +++ b/mmv1/third_party/terraform/tpgresource/common_diff_suppress.go @@ -161,4 +161,3 @@ func Base64DiffSuppress(_, old, new string, _ *schema.ResourceData) bool { func CaseInsensitiveHash(v interface{}) int { return Hashcode(strings.ToLower(v.(string))) } - From 8b2da770d9c0e6abbec3f2dd3cae787c675aaa06 Mon Sep 17 00:00:00 2001 From: gurusai-voleti Date: Mon, 29 Jun 2026 05:36:54 +0000 Subject: [PATCH 4/4] update --- .../services/storage/resource_storage_anywhere_cache_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mmv1/third_party/terraform/services/storage/resource_storage_anywhere_cache_test.go b/mmv1/third_party/terraform/services/storage/resource_storage_anywhere_cache_test.go index ede31a228673..d37d046f4301 100644 --- a/mmv1/third_party/terraform/services/storage/resource_storage_anywhere_cache_test.go +++ b/mmv1/third_party/terraform/services/storage/resource_storage_anywhere_cache_test.go @@ -39,6 +39,9 @@ func TestAccStorageAnywhereCache_update(t *testing.T) { plancheck.ExpectResourceAction("google_storage_anywhere_cache.cache", plancheck.ResourceActionUpdate), }, }, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_storage_anywhere_cache.cache", "admission_policy", "admit-on-first-miss"), + ), }, { ResourceName: "google_storage_anywhere_cache.cache",