@@ -20,6 +20,7 @@ import (
2020 "log"
2121 "reflect"
2222 "strconv"
23+ "strings"
2324 "time"
2425
2526 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -34,6 +35,23 @@ func revisionNameCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v i
3435 return nil
3536}
3637
38+ const cloudRunGoogleProvidedAnnotation = "serving.knative.dev"
39+
40+ func cloudrunAnnotationDiffSuppress (k , old , new string , d * schema.ResourceData ) bool {
41+ // Suppress diffs for the annotations provided by Google
42+ if strings .Contains (k , cloudRunGoogleProvidedAnnotation ) && new == "" {
43+ return true
44+ }
45+
46+ // Let diff be determined by annotations (above)
47+ if strings .Contains (k , "annotations.%" ) {
48+ return true
49+ }
50+
51+ // For other keys, don't suppress diff.
52+ return false
53+ }
54+
3755func resourceCloudRunService () * schema.Resource {
3856 return & schema.Resource {
3957 Create : resourceCloudRunServiceCreate ,
@@ -485,9 +503,10 @@ and annotations.`,
485503 Elem : & schema.Resource {
486504 Schema : map [string ]* schema.Schema {
487505 "annotations" : {
488- Type : schema .TypeMap ,
489- Computed : true ,
490- Optional : true ,
506+ Type : schema .TypeMap ,
507+ Computed : true ,
508+ Optional : true ,
509+ DiffSuppressFunc : cloudrunAnnotationDiffSuppress ,
491510 Description : `Annotations is a key value map stored with a resource that
492511may be set by external tools to store and retrieve arbitrary metadata. More
493512info: http://kubernetes.io/docs/user-guide/annotations` ,
0 commit comments