From 572a87a736475e2336a58d48f6b414e8b708cd30 Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Sat, 14 Jan 2023 15:52:03 +0100 Subject: [PATCH] feat: Add SSL mode Signed-off-by: Julien Riou --- base/config.go | 4 ++++ cmd/pgterminate/main.go | 1 + 2 files changed, 5 insertions(+) diff --git a/base/config.go b/base/config.go index f9ff9c3..7019078 100644 --- a/base/config.go +++ b/base/config.go @@ -24,6 +24,7 @@ type Config struct { User string `yaml:"user"` Password string `yaml:"password"` Database string `yaml:"database"` + SSLMode string `yaml:"sslmode"` Interval float64 `yaml:"interval"` ConnectTimeout int `yaml:"connect-timeout"` IdleTimeout float64 `yaml:"idle-timeout"` @@ -117,6 +118,9 @@ func (c *Config) Dsn() string { if c.ConnectTimeout != 0 { parameters = append(parameters, fmt.Sprintf("connect_timeout=%d", c.ConnectTimeout)) } + if c.SSLMode != "" { + parameters = append(parameters, fmt.Sprintf("sslmode=%s", c.SSLMode)) + } if AppName != "" { parameters = append(parameters, fmt.Sprintf("application_name=%s", AppName)) } diff --git a/cmd/pgterminate/main.go b/cmd/pgterminate/main.go index e88be55..9375b3b 100644 --- a/cmd/pgterminate/main.go +++ b/cmd/pgterminate/main.go @@ -43,6 +43,7 @@ func main() { flag.StringVar(&config.User, "user", "", "Instance username") flag.StringVar(&config.Password, "password", "", "Instance password") flag.StringVar(&config.Database, "database", "", "Instance database") + flag.StringVar(&config.SSLMode, "sslmode", "", "SSL mode (see https://www.postgresql.org/docs/current/libpq-ssl.html)") prompt := flag.Bool("prompt-password", false, "Prompt for password") flag.Float64Var(&config.Interval, "interval", 1, "Time to sleep between iterations in seconds") flag.IntVar(&config.ConnectTimeout, "connect-timeout", 3, "Connection timeout in seconds")