kube: standardize convention for passing postgres options

Declare options when creating postgres {}, then pass env by taking from postgres's cfg and svc. This is both to reduce chance of making a mistake, and to improve copy-pasteability of jsonnets

Change-Id: Ief16a6825af64795f3b10e1e617b96c3d1c2a578
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1807
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/app/inventory/prod.jsonnet b/app/inventory/prod.jsonnet
index 67c3583..0389223 100644
--- a/app/inventory/prod.jsonnet
+++ b/app/inventory/prod.jsonnet
@@ -11,10 +11,6 @@
     domain: 'inventory.hackerspace.pl',
 
     image: 'registry.k0.hswaw.net/palid/spejstore:1694280421',
-    db: {
-      name: 'inventory',
-      username: 'inventory',
-    },
     oauthClientId: '82fffb65-0bbd-4d18-becd-0ce0b31373cf',
     storageClassName: 'waw-hdd-redundant-3',
 
@@ -43,11 +39,11 @@
               },
               env_: {
                 SPEJSTORE_ENV: 'prod',
-                SPEJSTORE_DB_NAME: cfg.db.name,
-                SPEJSTORE_DB_USER: cfg.db.username,
-                SPEJSTORE_DB_PASSWORD: top.secretRefs.postgres,
-                SPEJSTORE_DB_HOST: top.psql.svc.host,
-                SPEJSTORE_DB_PORT: top.psql.svc.port,
+                SPEJSTORE_DB_NAME: top.postgres.cfg.database,
+                SPEJSTORE_DB_USER: top.postgres.cfg.username,
+                SPEJSTORE_DB_PASSWORD: top.postgres.cfg.password,
+                SPEJSTORE_DB_HOST: top.postgres.svc.host,
+                SPEJSTORE_DB_PORT: top.postgres.svc.port,
                 SPEJSTORE_ALLOWED_HOSTS: cfg.domain,
                 SPEJSTORE_CLIENT_ID: cfg.oauthClientId,
                 SPEJSTORE_SECRET: top.secretRefs.oauth,
@@ -70,15 +66,15 @@
     storageClass:: cfg.storageClassName,
   },
 
-  psql: postgres {
+  postgres: postgres {
     cfg+: {
       namespace: cfg.namespace,
       appName: cfg.name,
       storageClassName: cfg.storageClassName,
       version: '15.4',
 
-      database: cfg.db.name,
-      username: cfg.db.username,
+      database: 'inventory',
+      username: 'inventory',
       password: top.secretRefs.postgres,
     },
     bouncer: {},