File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
internal/database/postgres Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,9 @@ func (Postgres) PortDefault() uint16 { return 5432 }
6464
6565func (db Postgres ) DatabaseEnvs (conf * conftypes.Global ) kubernetes.ConfigLookups {
6666 if secret := db .cnpgSecretName (conf ); secret != "" {
67+ cluster , _ := db .cnpgClusterName (conf )
6768 return kubernetes.ConfigLookups {kubernetes.LookupNamedSecret {
68- Name : secret ,
69+ Name : cluster + "-app" , // Always use the app secret since superuser dbname is `*`
6970 Key : "dbname" ,
7071 }}
7172 }
@@ -357,8 +358,13 @@ func (Postgres) zalandoQuery() filter.Filter {
357358 return filter.Label {Name : "application" , Value : "spilo" }
358359}
359360
361+ func (Postgres ) cnpgClusterName (conf * conftypes.Global ) (string , bool ) {
362+ v , ok := conf .DBPod .Labels ["cnpg.io/cluster" ]
363+ return v , ok
364+ }
365+
360366func (db Postgres ) cnpgSecretName (conf * conftypes.Global ) string {
361- if cluster , ok := conf . DBPod . Labels [ "cnpg.io/cluster" ] ; ok {
367+ if cluster , ok := db . cnpgClusterName ( conf ) ; ok {
362368 if conf .Username == db .UserDefault () {
363369 return cluster + "-superuser"
364370 }
You can’t perform that action at this time.
0 commit comments