Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress Google labels from Cloud Run Service #4528

Merged
merged 18 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
71c3aeb
Merge pull request #1 from GoogleCloudPlatform/master
upodroid Aug 3, 2020
e1a9488
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Aug 10, 2020
51eaff6
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Aug 25, 2020
649e97c
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Sep 21, 2020
ee373cc
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Oct 3, 2020
d330773
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Oct 27, 2020
0d73e9f
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Nov 17, 2020
191a775
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Dec 15, 2020
b90d594
mark field as updatable
upodroid Jan 5, 2021
4b79149
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Jan 20, 2021
a3e1989
Merge branch 'master' of github.com:borg-land/magic-modules
upodroid Jan 26, 2021
9ffeb0b
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Jan 26, 2021
9dd54f3
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Feb 1, 2021
b917f22
Merge branch 'master' of github.com:GoogleCloudPlatform/magic-modules
upodroid Feb 15, 2021
b8159c7
supress moar diffs
upodroid Feb 24, 2021
051e7cc
tweak the right value
upodroid Feb 24, 2021
f97f374
Update mmv1/templates/terraform/constants/cloud_run_service.go.erb
upodroid Feb 26, 2021
ea4e296
Update mmv1/templates/terraform/constants/cloud_run_service.go.erb
c2thorn Feb 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mmv1/products/cloudrun/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_expand: "templates/terraform/custom_expand/default_to_project.go.erb"
metadata.labels: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
diff_suppress_func: 'cloudrunLabelDiffSuppress'
metadata.annotations: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
diff_suppress_func: 'cloudrunAnnotationDiffSuppress'
Expand Down
21 changes: 19 additions & 2 deletions mmv1/templates/terraform/constants/cloud_run_service.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func revisionNameCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v i
return nil
}

var cloudRunGoogleProvidedAnnotations = regexp.MustCompile(`serving\\.knative\\.dev/(?:(?:creator)|(?:lastModifier))$|run\\.googleapis\\.com/(?:(?:ingress-status))$`)
var cloudRunGoogleProvidedAnnotations = regexp.MustCompile(`serving\\.knative\\.dev/(?:(?:creator)|(?:lastModifier))$|run\\.googleapis\\.com/(?:(?:ingress-status))$|cloud\\.googleapis\\.com/(?:(?:location))`)
c2thorn marked this conversation as resolved.
Show resolved Hide resolved

func cloudrunAnnotationDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the annotations provided by Google
Expand All @@ -21,4 +21,21 @@ func cloudrunAnnotationDiffSuppress(k, old, new string, d *schema.ResourceData)

// For other keys, don't suppress diff.
return false
}
}

var cloudRunGoogleProvidedLabels = regexp.MustCompile(`cloud\.googleapis\.com/(?:(?:location))`)

func cloudrunLabelDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the labels provided by Google
if cloudRunGoogleProvidedLabels.MatchString(k) && new == "" {
return true
}

// Let diff be determined by labels (above)
if strings.Contains(k, "labels.%") {
return true
}

// For other keys, don't suppress diff.
return false
}