Skip to content

Commit

Permalink
Fix permadiff in google_bigquery_datapolicy_data_policy policy tag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wj-chen authored Sep 20, 2024
1 parent 846050f commit 888ef3d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions mmv1/products/bigquerydatapolicy/DataPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ properties:
Policy tag resource name, in the format of projects/{project_number}/locations/{locationId}/taxonomies/{taxonomyId}/policyTags/{policyTag_id}.
required: true
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
custom_flatten: 'templates/terraform/custom_flatten/bigquery_datapolicy_policy_tag_location_to_lower_case.go.erb'
- !ruby/object:Api::Type::Enum
name: dataPolicyType
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<%- # the license inside this block applies to this file
# Copyright 2024 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 flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
}

if _, ok := v.(string); !ok {
return v
}

re := regexp.MustCompile(`(projects/.*)(/locations/.*/)(policyTags/.*)`)
result := re.ReplaceAllStringFunc(v.(string), func(match string) string {
matches := re.FindStringSubmatch(match)
return matches[1] + strings.ToLower(matches[2]) + matches[3]
})

return result
}

0 comments on commit 888ef3d

Please sign in to comment.