Skip to content

Commit

Permalink
Suppress diff for COS images (#4562) (#647)
Browse files Browse the repository at this point in the history
Co-authored-by: Marius Kintel <[email protected]>
Signed-off-by: Modular Magician <[email protected]>

Co-authored-by: Marius Kintel <[email protected]>
  • Loading branch information
modular-magician and kintel authored Mar 4, 2021
1 parent 866d0fa commit d81e162
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions google/compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ func diskImageFamilyEquals(imageName, familyName string) bool {
return true
}

if suppressCosFamilyDiff(imageName, familyName) {
return true
}

if suppressWindowsSqlFamilyDiff(imageName, familyName) {
return true
}
Expand All @@ -170,6 +174,19 @@ func suppressCanonicalFamilyDiff(imageName, familyName string) bool {
return false
}

// e.g. image: cos-NN-*, family: cos-NN-lts
func suppressCosFamilyDiff(imageName, familyName string) bool {
parts := cosLtsImage.FindStringSubmatch(imageName)
if len(parts) == 2 {
f := fmt.Sprintf("cos-%s-lts", parts[1])
if f == familyName {
return true
}
}

return false
}

// e.g. image: sql-2017-standard-windows-2016-dc-v20180109, family: sql-std-2017-win-2016
// e.g. image: sql-2017-express-windows-2012-r2-dc-v20180109, family: sql-exp-2017-win-2012-r2
func suppressWindowsSqlFamilyDiff(imageName, familyName string) bool {
Expand Down
1 change: 1 addition & 0 deletions google/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (

windowsSqlImage = regexp.MustCompile("^sql-(?:server-)?([0-9]{4})-([a-z]+)-windows-(?:server-)?([0-9]{4})(?:-r([0-9]+))?-dc-v[0-9]+$")
canonicalUbuntuLtsImage = regexp.MustCompile("^ubuntu-(minimal-)?([0-9]+)-")
cosLtsImage = regexp.MustCompile("^cos-([0-9]+)-")
)

// built-in projects to look for images/families containing the string
Expand Down

0 comments on commit d81e162

Please sign in to comment.