@@ -78,6 +78,20 @@ func IsDiskShrinkage(_ context.Context, old, new, _ interface{}) bool {
78
78
return new .(int ) < old .(int )
79
79
}
80
80
81
+ func matchImageLink (old string ) (string , string , bool ) {
82
+ // 'old' is read from the API.
83
+ // In GCP It has the format 'https://www.googleapis.com/compute/v1/projects/(%s)/global/images/(%s)'
84
+ matches := resolveImageLink .FindStringSubmatch (old )
85
+ if matches == nil {
86
+ // In alternate universes, it has the format https://compute.%s/compute/[a-z0-9]+/projects/(%s)/global/images/(%s)
87
+ matches = resolveImageUniverseLink .FindStringSubmatch (old )
88
+ if matches == nil {
89
+ return "" , "" , false
90
+ }
91
+ }
92
+ return matches [1 ], matches [2 ], true
93
+ }
94
+
81
95
// We cannot suppress the diff for the case when family name is not part of the image name since we can't
82
96
// make a network call in a DiffSuppressFunc.
83
97
func DiskImageDiffSuppress (_ , old , new string , _ * schema.ResourceData ) bool {
@@ -88,15 +102,10 @@ func DiskImageDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
88
102
// In order to keep this maintainable, we need to ensure that the positive and negative examples
89
103
// in resource_compute_disk_test.go are as complete as possible.
90
104
91
- // 'old' is read from the API.
92
- // It always has the format 'https://www.googleapis.com/compute/v1/projects/(%s)/global/images/(%s)'
93
- matches := resolveImageLink .FindStringSubmatch (old )
94
- if matches == nil {
95
- // Image read from the API doesn't have the expected format. In practice, it should never happen
105
+ oldProject , oldName , matched := matchImageLink (old )
106
+ if matched == false {
96
107
return false
97
108
}
98
- oldProject := matches [1 ]
99
- oldName := matches [2 ]
100
109
101
110
// Partial or full self link family
102
111
if resolveImageProjectFamily .MatchString (new ) {
0 commit comments