From f0f670735f581250052de51aad85a3f6a5760c7e Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 4 Mar 2021 00:09:04 +0000 Subject: [PATCH] Suppress diff for COS images (#4562) Co-authored-by: Marius Kintel Signed-off-by: Modular Magician --- google/compute_disk.go | 17 +++++++++++++++++ google/image.go | 1 + 2 files changed, 18 insertions(+) diff --git a/google/compute_disk.go b/google/compute_disk.go index bfe433803..a76dfad2a 100644 --- a/google/compute_disk.go +++ b/google/compute_disk.go @@ -146,6 +146,10 @@ func diskImageFamilyEquals(imageName, familyName string) bool { return true } + if suppressCosFamilyDiff(imageName, familyName) { + return true + } + if suppressWindowsSqlFamilyDiff(imageName, familyName) { return true } @@ -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 { diff --git a/google/image.go b/google/image.go index 61ac117dc..ad90c55ce 100644 --- a/google/image.go +++ b/google/image.go @@ -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