feat: Add SSL mode
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
8709ee542b
commit
572a87a736
2 changed files with 5 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue