Skip to content

Commit

Permalink
Restrict annotation ignores to the specific annotation Cloud Run adds (
Browse files Browse the repository at this point in the history
…hashicorp#4202) (hashicorp#7740)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 7, 2020
1 parent 9291270 commit a4fd4d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/4202.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
5 changes: 3 additions & 2 deletions google/resource_cloud_run_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"log"
"reflect"
"regexp"
"strconv"
"strings"
"time"
Expand All @@ -35,11 +36,11 @@ func revisionNameCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v i
return nil
}

const cloudRunGoogleProvidedAnnotation = "serving.knative.dev"
var cloudRunGoogleProvidedAnnotations = regexp.MustCompile("serving\\.knative\\.dev/(?:(?:creator)|(?:lastModifier))$")

func cloudrunAnnotationDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the annotations provided by Google
if strings.Contains(k, cloudRunGoogleProvidedAnnotation) && new == "" {
if cloudRunGoogleProvidedAnnotations.MatchString(k) && new == "" {
return true
}

Expand Down
5 changes: 4 additions & 1 deletion google/resource_cloud_run_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ resource "google_cloud_run_service" "default" {
location = "us-central1"
metadata {
namespace = "%s"
namespace = "%s"
annotations = {
generated-by = "magic-modules"
}
}
template {
Expand Down

0 comments on commit a4fd4d8

Please sign in to comment.