From 7bf19d6a9d4bb429463ada0e4f06b15cf5db4161 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 25 Jan 2024 18:20:44 +0800 Subject: [PATCH] fix(db): exclude unsupported pg15 patch versions from loading (#1884) --- internal/utils/config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/utils/config.go b/internal/utils/config.go index 3e2261c04..83a83ff75 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "regexp" + "strconv" "strings" "text/template" "time" @@ -524,9 +525,12 @@ func LoadConfigFS(fsys afero.Fs) error { if Config.Experimental.S3SecretKey, err = maybeLoadEnv(Config.Experimental.S3SecretKey); err != nil { return err } - } else if version, err := afero.ReadFile(fsys, PostgresVersionPath); err == nil && strings.HasPrefix(string(version), "15.") { - index := strings.IndexByte(Pg15Image, ':') - Config.Db.Image = Pg15Image[:index+1] + string(version) + } else if version, err := afero.ReadFile(fsys, PostgresVersionPath); err == nil { + parts := strings.Split(string(version), ".") + if patch, err := strconv.Atoi(parts[len(parts)-1]); err == nil && patch >= 55 && parts[0] == "15" { + index := strings.IndexByte(Pg15Image, ':') + Config.Db.Image = Pg15Image[:index+1] + string(version) + } } default: return errors.Errorf("Failed reading config: Invalid %s: %v.", Aqua("db.major_version"), Config.Db.MajorVersion)