From 569c2ea3ecbdcef674ef36ac3649713f94748c86 Mon Sep 17 00:00:00 2001 From: Surya Kant Date: Sun, 30 Jan 2022 20:12:22 +0530 Subject: [PATCH] fix: pull specific postgres version image --- api/create.go | 23 +++++++++++-------- api/helpers.go | 4 ++++ .../templates/docker-compose-template.yml | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/api/create.go b/api/create.go index b5ccfaf..0cf6619 100644 --- a/api/create.go +++ b/api/create.go @@ -33,20 +33,22 @@ type service struct { //Port uint Db dbCluster DockerNetwork string - + Version version BackupEnabled bool Backup backupConfig } - +type version struct { + Maj uint + Min uint +} type dbCluster struct { - Name string - ID string - Type string - Port int - Username string - Password string - MajVersion uint - MinVersion uint + Name string + ID string + Type string + Port int + Username string + Password string + Memory string Storage string Monitoring string @@ -97,6 +99,7 @@ func CreateService(w http.ResponseWriter, req *http.Request) { } err = json.Unmarshal(byteArray, &s) + log.Printf("%d %d", s.Version.Maj, s.Version.Min) if s.UserID == "" && apiKeyHeader != "" { s.UserID = "testuser" } diff --git a/api/helpers.go b/api/helpers.go index d4f64d9..6f609bf 100644 --- a/api/helpers.go +++ b/api/helpers.go @@ -54,6 +54,8 @@ func CreateDockerComposeFile(absolutepath string, s service) error { Architecture string Type string Port int + MajVersion uint + MinVersion uint PostgresUsername string PostgresPassword string }{ @@ -61,6 +63,8 @@ func CreateDockerComposeFile(absolutepath string, s service) error { s.Architecture, s.Db.Type, s.Db.Port, + s.Version.Maj, + s.Version.Min, s.Db.Username, s.Db.Password, } diff --git a/templates/templates/docker-compose-template.yml b/templates/templates/docker-compose-template.yml index b3c8eb1..50dc658 100644 --- a/templates/templates/docker-compose-template.yml +++ b/templates/templates/docker-compose-template.yml @@ -2,7 +2,7 @@ version: "3.9" services: postgres: - image: {{ .Architecture }}/{{ .Type }} + image: {{ .Architecture }}/{{ .Type }}:{{.MajVersion}}.{{.MinVersion}} restart: unless-stopped ports: - "{{ .Port }}:5432"