github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/storage/config.go (about) 1 package storage 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 const ( 9 connectionURLFormat = "host=%s port=%s user=%s password=%s dbname=%s sslmode=%s sslrootcert=%s" 10 ) 11 12 type Config struct { 13 User string `envconfig:"default=postgres"` 14 Password string `envconfig:"default=password"` 15 Host string `envconfig:"default=localhost"` 16 Port string `envconfig:"default=5432"` 17 Name string `envconfig:"default=broker"` 18 SSLMode string `envconfig:"default=disable"` 19 SSLRootCert string `envconfig:"optional"` 20 21 SecretKey string `envconfig:"optional"` 22 23 MaxOpenConns int `envconfig:"default=8"` 24 MaxIdleConns int `envconfig:"default=2"` 25 ConnMaxLifetime time.Duration `envconfig:"default=30m"` 26 } 27 28 func (cfg *Config) ConnectionURL() string { 29 return fmt.Sprintf(connectionURLFormat, cfg.Host, cfg.Port, cfg.User, 30 cfg.Password, cfg.Name, cfg.SSLMode, cfg.SSLRootCert) 31 }