Skip to content

Commit a87cccf

Browse files
committed
Cherry pick: Restrict annotation ignores to the specific annotation Cloud Run adds
1 parent b0562cf commit a87cccf

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.changelog/4202.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/resource_cloud_run_service.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"fmt"
2020
"log"
2121
"reflect"
22+
"regexp"
2223
"strconv"
2324
"strings"
2425
"time"
@@ -35,11 +36,11 @@ func revisionNameCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v i
3536
return nil
3637
}
3738

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

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

google-beta/resource_cloud_run_service_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ resource "google_cloud_run_service" "default" {
4646
location = "us-central1"
4747
4848
metadata {
49-
namespace = "%s"
49+
namespace = "%s"
50+
annotations = {
51+
generated-by = "magic-modules"
52+
}
5053
}
5154
5255
template {

0 commit comments

Comments
 (0)