Skip to content

Commit c87c61c

Browse files
wj-chenniharika-98
authored andcommitted
Fix permadiff in google_bigquery_datapolicy_data_policy policy tag (GoogleCloudPlatform#11722)
1 parent 55a8e2f commit c87c61c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

mmv1/products/bigquerydatapolicy/DataPolicy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ properties:
8282
Policy tag resource name, in the format of projects/{project_number}/locations/{locationId}/taxonomies/{taxonomyId}/policyTags/{policyTag_id}.
8383
required: true
8484
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
85+
custom_flatten: 'templates/terraform/custom_flatten/bigquery_datapolicy_policy_tag_location_to_lower_case.go.erb'
8586
- !ruby/object:Api::Type::Enum
8687
name: dataPolicyType
8788
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<%- # the license inside this block applies to this file
2+
# Copyright 2024 Google Inc.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
-%>
15+
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
16+
if v == nil {
17+
return nil
18+
}
19+
20+
if _, ok := v.(string); !ok {
21+
return v
22+
}
23+
24+
re := regexp.MustCompile(`(projects/.*)(/locations/.*/)(policyTags/.*)`)
25+
result := re.ReplaceAllStringFunc(v.(string), func(match string) string {
26+
matches := re.FindStringSubmatch(match)
27+
return matches[1] + strings.ToLower(matches[2]) + matches[3]
28+
})
29+
30+
return result
31+
}

0 commit comments

Comments
 (0)