Update kit with new pg config
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -81,13 +81,16 @@ func (b *Builder) Build() (*probod.FullConfig, error) {
|
||||
ExtraHeaderFields: make(map[string]string),
|
||||
},
|
||||
Pg: probod.PgConfig{
|
||||
Addr: b.getEnvOrDefault("PG_ADDR", "localhost:5432"),
|
||||
Username: b.getEnvOrDefault("PG_USERNAME", "postgres"),
|
||||
Password: b.getEnvOrDefault("PG_PASSWORD", "postgres"),
|
||||
Database: b.getEnvOrDefault("PG_DATABASE", "probod"),
|
||||
PoolSize: int32(b.getEnvIntOrDefault("PG_POOL_SIZE", 100)),
|
||||
CACertBundle: pgCACertBundle,
|
||||
Debug: b.getEnvBoolOrDefault("PG_DEBUG", false),
|
||||
Addr: b.getEnvOrDefault("PG_ADDR", "localhost:5432"),
|
||||
Username: b.getEnvOrDefault("PG_USERNAME", "postgres"),
|
||||
Password: b.getEnvOrDefault("PG_PASSWORD", "postgres"),
|
||||
Database: b.getEnvOrDefault("PG_DATABASE", "probod"),
|
||||
PoolSize: int32(b.getEnvIntOrDefault("PG_POOL_SIZE", 100)),
|
||||
MinPoolSize: int32(b.getEnvIntOrDefault("PG_MIN_POOL_SIZE", 10)),
|
||||
MaxConnIdleTimeSeconds: b.getEnvIntOrDefault("PG_MAX_CONN_IDLE_TIME_SECONDS", 1800),
|
||||
MaxConnLifetimeSeconds: b.getEnvIntOrDefault("PG_MAX_CONN_LIFETIME_SECONDS", 3600),
|
||||
CACertBundle: pgCACertBundle,
|
||||
Debug: b.getEnvBoolOrDefault("PG_DEBUG", false),
|
||||
},
|
||||
Auth: probod.AuthConfig{
|
||||
DisableSignup: b.getEnvBoolOrDefault("AUTH_DISABLE_SIGNUP", false),
|
||||
|
||||
@@ -131,6 +131,9 @@ func TestBuilder_Build_Defaults(t *testing.T) {
|
||||
assert.Equal(t, "postgres", cfg.Probod.Pg.Password)
|
||||
assert.Equal(t, "probod", cfg.Probod.Pg.Database)
|
||||
assert.Equal(t, int32(100), cfg.Probod.Pg.PoolSize)
|
||||
assert.Equal(t, int32(10), cfg.Probod.Pg.MinPoolSize)
|
||||
assert.Equal(t, 1800, cfg.Probod.Pg.MaxConnIdleTimeSeconds)
|
||||
assert.Equal(t, 3600, cfg.Probod.Pg.MaxConnLifetimeSeconds)
|
||||
assert.False(t, cfg.Probod.Pg.Debug)
|
||||
|
||||
// Auth config
|
||||
@@ -233,6 +236,9 @@ func TestBuilder_Build_CustomValues(t *testing.T) {
|
||||
env["PG_PASSWORD"] = "secret123"
|
||||
env["PG_DATABASE"] = "probo_prod"
|
||||
env["PG_POOL_SIZE"] = "200"
|
||||
env["PG_MIN_POOL_SIZE"] = "25"
|
||||
env["PG_MAX_CONN_IDLE_TIME_SECONDS"] = "900"
|
||||
env["PG_MAX_CONN_LIFETIME_SECONDS"] = "7200"
|
||||
env["PG_DEBUG"] = "true"
|
||||
// Auth
|
||||
env["AUTH_DISABLE_SIGNUP"] = "true"
|
||||
@@ -310,6 +316,9 @@ func TestBuilder_Build_CustomValues(t *testing.T) {
|
||||
assert.Equal(t, "secret123", cfg.Probod.Pg.Password)
|
||||
assert.Equal(t, "probo_prod", cfg.Probod.Pg.Database)
|
||||
assert.Equal(t, int32(200), cfg.Probod.Pg.PoolSize)
|
||||
assert.Equal(t, int32(25), cfg.Probod.Pg.MinPoolSize)
|
||||
assert.Equal(t, 900, cfg.Probod.Pg.MaxConnIdleTimeSeconds)
|
||||
assert.Equal(t, 7200, cfg.Probod.Pg.MaxConnLifetimeSeconds)
|
||||
assert.True(t, cfg.Probod.Pg.Debug)
|
||||
// Auth
|
||||
assert.True(t, cfg.Probod.Auth.DisableSignup)
|
||||
|
||||
@@ -111,11 +111,14 @@ func TestWriteConfig_CompleteConfig(t *testing.T) {
|
||||
ExtraHeaderFields: map[string]string{},
|
||||
},
|
||||
Pg: probod.PgConfig{
|
||||
Addr: "localhost:5432",
|
||||
Username: "postgres",
|
||||
Password: "postgres",
|
||||
Database: "probod",
|
||||
PoolSize: 100,
|
||||
Addr: "localhost:5432",
|
||||
Username: "postgres",
|
||||
Password: "postgres",
|
||||
Database: "probod",
|
||||
PoolSize: 100,
|
||||
MinPoolSize: 10,
|
||||
MaxConnIdleTimeSeconds: 1800,
|
||||
MaxConnLifetimeSeconds: 3600,
|
||||
},
|
||||
Connectors: []probod.ConnectorConfig{
|
||||
{
|
||||
@@ -147,6 +150,9 @@ func TestWriteConfig_CompleteConfig(t *testing.T) {
|
||||
assert.Equal(t, cfg.Unit.Tracing.MaxBatchSize, loaded.Unit.Tracing.MaxBatchSize)
|
||||
assert.Equal(t, cfg.Probod.Api.Cors.AllowedOrigins, loaded.Probod.Api.Cors.AllowedOrigins)
|
||||
assert.Equal(t, cfg.Probod.Pg.PoolSize, loaded.Probod.Pg.PoolSize)
|
||||
assert.Equal(t, cfg.Probod.Pg.MinPoolSize, loaded.Probod.Pg.MinPoolSize)
|
||||
assert.Equal(t, cfg.Probod.Pg.MaxConnIdleTimeSeconds, loaded.Probod.Pg.MaxConnIdleTimeSeconds)
|
||||
assert.Equal(t, cfg.Probod.Pg.MaxConnLifetimeSeconds, loaded.Probod.Pg.MaxConnLifetimeSeconds)
|
||||
require.Len(t, loaded.Probod.Connectors, 1)
|
||||
assert.Equal(t, "SLACK", loaded.Probod.Connectors[0].Provider)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user