@geekmidas/cli 10.0.0-alpha.170 → 10.0.0-alpha.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GoDaddyProvider-DK9_Jw9d.cjs → GoDaddyProvider-BLCCgWNA.cjs} +2 -2
- package/dist/{GoDaddyProvider-DK9_Jw9d.cjs.map → GoDaddyProvider-BLCCgWNA.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-Cf4MIuaD.mjs → GoDaddyProvider-CIhg_ymt.mjs} +2 -2
- package/dist/{GoDaddyProvider-Cf4MIuaD.mjs.map → GoDaddyProvider-CIhg_ymt.mjs.map} +1 -1
- package/dist/{HostingerProvider-CQebZrz3.mjs → HostingerProvider-BOFzH5JM.mjs} +2 -2
- package/dist/{HostingerProvider-CQebZrz3.mjs.map → HostingerProvider-BOFzH5JM.mjs.map} +1 -1
- package/dist/{HostingerProvider-qQzo4MYp.cjs → HostingerProvider-BUBeLZFT.cjs} +2 -2
- package/dist/{HostingerProvider-qQzo4MYp.cjs.map → HostingerProvider-BUBeLZFT.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BeMRGXRi.cjs → LegacyStateStore-CLuyua0d.cjs} +2 -2
- package/dist/{LegacyStateStore-BeMRGXRi.cjs.map → LegacyStateStore-CLuyua0d.cjs.map} +1 -1
- package/dist/{LegacyStateStore-DXPHKdMk.mjs → LegacyStateStore-CrkjCaSU.mjs} +2 -2
- package/dist/{LegacyStateStore-DXPHKdMk.mjs.map → LegacyStateStore-CrkjCaSU.mjs.map} +1 -1
- package/dist/{LocalStateStore-E_sa5GR2.cjs → LocalStateStore-Bu1mGMUv.cjs} +2 -2
- package/dist/{LocalStateStore-E_sa5GR2.cjs.map → LocalStateStore-Bu1mGMUv.cjs.map} +1 -1
- package/dist/{LocalStateStore-BYQ9lPje.mjs → LocalStateStore-DV4jBo8p.mjs} +2 -2
- package/dist/{LocalStateStore-BYQ9lPje.mjs.map → LocalStateStore-DV4jBo8p.mjs.map} +1 -1
- package/dist/{S3StateStore-BQaGVNRf.mjs → S3StateStore-B4FDrGY1.mjs} +4 -4
- package/dist/{S3StateStore-BQaGVNRf.mjs.map → S3StateStore-B4FDrGY1.mjs.map} +1 -1
- package/dist/{S3StateStore-Cjr4Rtsf.cjs → S3StateStore-kbkBod12.cjs} +4 -4
- package/dist/{S3StateStore-Cjr4Rtsf.cjs.map → S3StateStore-kbkBod12.cjs.map} +1 -1
- package/dist/{SSMStateStore-Bq_S7x5_.mjs → SSMStateStore-5MSu94ua.mjs} +2 -2
- package/dist/{SSMStateStore-Bq_S7x5_.mjs.map → SSMStateStore-5MSu94ua.mjs.map} +1 -1
- package/dist/{SSMStateStore-Cnfwdlme.cjs → SSMStateStore-DbsAcN97.cjs} +2 -2
- package/dist/{SSMStateStore-Cnfwdlme.cjs.map → SSMStateStore-DbsAcN97.cjs.map} +1 -1
- package/dist/{add-3_IHpF5F.cjs → add-CB1o52l-.cjs} +5 -5
- package/dist/{add-3_IHpF5F.cjs.map → add-CB1o52l-.cjs.map} +1 -1
- package/dist/{add-CNQFnG0C.mjs → add-CLEIQtcF.mjs} +5 -5
- package/dist/{add-CNQFnG0C.mjs.map → add-CLEIQtcF.mjs.map} +1 -1
- package/dist/{apps-DGod3aS9.mjs → apps-B4qOLFEC.mjs} +16 -795
- package/dist/apps-B4qOLFEC.mjs.map +1 -0
- package/dist/{apps-BGu47YRF.cjs → apps-CTyacCpW.cjs} +28 -897
- package/dist/apps-CTyacCpW.cjs.map +1 -0
- package/dist/{bundler-DWGxNGSB.cjs → bundler-Bma2_DTI.cjs} +6 -6
- package/dist/{bundler-DWGxNGSB.cjs.map → bundler-Bma2_DTI.cjs.map} +1 -1
- package/dist/{bundler-Dm0mB7EK.mjs → bundler-CSSYSsl8.mjs} +6 -6
- package/dist/{bundler-Dm0mB7EK.mjs.map → bundler-CSSYSsl8.mjs.map} +1 -1
- package/dist/{cli-Qm-8tG46.mjs → cli-BFEuBKiU.mjs} +4 -4
- package/dist/{cli-Qm-8tG46.mjs.map → cli-BFEuBKiU.mjs.map} +1 -1
- package/dist/{cli-CYeZF85I.cjs → cli-DXGl3fsc.cjs} +4 -4
- package/dist/{cli-CYeZF85I.cjs.map → cli-DXGl3fsc.cjs.map} +1 -1
- package/dist/{compose-IsvqY6iX.cjs → compose-BNWFrHHE.cjs} +64 -11
- package/dist/compose-BNWFrHHE.cjs.map +1 -0
- package/dist/{compose-CXgwCuqv.mjs → compose-CANkT9bL.mjs} +923 -25
- package/dist/compose-CANkT9bL.mjs.map +1 -0
- package/dist/{compose-CshnO-Th.cjs → compose-DpDrZwZS.cjs} +1063 -27
- package/dist/compose-DpDrZwZS.cjs.map +1 -0
- package/dist/{compose-BVeevJO_.mjs → compose-SSYHdZMN.mjs} +63 -10
- package/dist/compose-SSYHdZMN.mjs.map +1 -0
- package/dist/{config-u5XdE1Cq.d.cts → config-CsCYzlVO.d.mts} +3 -3
- package/dist/{config-B8gSu59v.d.mts.map → config-CsCYzlVO.d.mts.map} +1 -1
- package/dist/{config-B8gSu59v.d.mts → config-D-gHQXhi.d.cts} +3 -3
- package/dist/{config-u5XdE1Cq.d.cts.map → config-D-gHQXhi.d.cts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{credentials-DzR2j8h1.cjs → credentials-BAeWfaj3.cjs} +6 -6
- package/dist/{credentials-DzR2j8h1.cjs.map → credentials-BAeWfaj3.cjs.map} +1 -1
- package/dist/{credentials-CKIeLL7T.mjs → credentials-DmNpxlFO.mjs} +6 -6
- package/dist/{credentials-CKIeLL7T.mjs.map → credentials-DmNpxlFO.mjs.map} +1 -1
- package/dist/deploy/public.cjs +11 -11
- package/dist/deploy/public.d.cts +4 -4
- package/dist/deploy/public.d.mts +4 -4
- package/dist/deploy/public.mjs +11 -11
- package/dist/{deploy-DQjEjUfB.cjs → deploy-DHrbzHxT.cjs} +25 -27
- package/dist/deploy-DHrbzHxT.cjs.map +1 -0
- package/dist/{deploy-CjubyZlP.mjs → deploy-Qa7wXYS4.mjs} +24 -26
- package/dist/deploy-Qa7wXYS4.mjs.map +1 -0
- package/dist/{destroy-D1375m8C.cjs → destroy-CJ6wwQRQ.cjs} +9 -9
- package/dist/{destroy-D1375m8C.cjs.map → destroy-CJ6wwQRQ.cjs.map} +1 -1
- package/dist/{destroy-D4m5aO9k.mjs → destroy-CKuYg9JQ.mjs} +9 -9
- package/dist/{destroy-D4m5aO9k.mjs.map → destroy-CKuYg9JQ.mjs.map} +1 -1
- package/dist/{docker-CSEAKwFr.cjs → docker-C9ObsT80.cjs} +9 -9
- package/dist/{docker-CSEAKwFr.cjs.map → docker-C9ObsT80.cjs.map} +1 -1
- package/dist/{docker-C27YUUMQ.mjs → docker-CrNWM0jN.mjs} +5 -5
- package/dist/{docker-C27YUUMQ.mjs.map → docker-CrNWM0jN.mjs.map} +1 -1
- package/dist/{dokploy-DJDdiFz6.cjs → dokploy-C6KfcyOG.cjs} +2 -2
- package/dist/{dokploy-DJDdiFz6.cjs.map → dokploy-C6KfcyOG.cjs.map} +1 -1
- package/dist/{dokploy-CSqDsvY-.mjs → dokploy-DITW2LHL.mjs} +2 -2
- package/dist/{dokploy-CSqDsvY-.mjs.map → dokploy-DITW2LHL.mjs.map} +1 -1
- package/dist/{eas-DryGYjFk.cjs → eas-BBwlSGd8.cjs} +3 -3
- package/dist/{eas-DryGYjFk.cjs.map → eas-BBwlSGd8.cjs.map} +1 -1
- package/dist/{eas-DC3F8cy0.mjs → eas-BE7tu9eH.mjs} +3 -3
- package/dist/{eas-DC3F8cy0.mjs.map → eas-BE7tu9eH.mjs.map} +1 -1
- package/dist/{encryption-C8Y8Ly6n.mjs → encryption-Bn_pIrIe.mjs} +3 -3
- package/dist/{encryption-C8Y8Ly6n.mjs.map → encryption-Bn_pIrIe.mjs.map} +1 -1
- package/dist/{encryption-8qZGm15p.cjs → encryption-D0jmwRdU.cjs} +3 -3
- package/dist/{encryption-8qZGm15p.cjs.map → encryption-D0jmwRdU.cjs.map} +1 -1
- package/dist/{engine-DI7JAyiD.cjs → engine-BDqBychY.cjs} +19 -19
- package/dist/{engine-DI7JAyiD.cjs.map → engine-BDqBychY.cjs.map} +1 -1
- package/dist/{engine-C9E0MeLm.mjs → engine-Dv4SfML2.mjs} +9 -9
- package/dist/{engine-C9E0MeLm.mjs.map → engine-Dv4SfML2.mjs.map} +1 -1
- package/dist/{github-DdaV-Gll.mjs → github-7vONG88-.mjs} +7 -7
- package/dist/{github-DdaV-Gll.mjs.map → github-7vONG88-.mjs.map} +1 -1
- package/dist/{github-g3nRZlli.cjs → github-orgDU5Ta.cjs} +7 -7
- package/dist/{github-g3nRZlli.cjs.map → github-orgDU5Ta.cjs.map} +1 -1
- package/dist/{googlePlay-BmeR1kY4.mjs → googlePlay-DOPEv_Uu.mjs} +4 -4
- package/dist/{googlePlay-BmeR1kY4.mjs.map → googlePlay-DOPEv_Uu.mjs.map} +1 -1
- package/dist/{googlePlay-BHJ_iThq.cjs → googlePlay-DWiYD2Up.cjs} +4 -4
- package/dist/{googlePlay-BHJ_iThq.cjs.map → googlePlay-DWiYD2Up.cjs.map} +1 -1
- package/dist/{iam-ra1_Y405.mjs → iam-BE0qX5Lb.mjs} +2 -2
- package/dist/{iam-ra1_Y405.mjs.map → iam-BE0qX5Lb.mjs.map} +1 -1
- package/dist/{iam-BoYPPNdM.cjs → iam-FA95ku7l.cjs} +2 -2
- package/dist/{iam-BoYPPNdM.cjs.map → iam-FA95ku7l.cjs.map} +1 -1
- package/dist/{index-DFZ0SMwN.d.mts → index-QxGYzGEN.d.mts} +2 -2
- package/dist/{index-1H93w_H6.d.cts.map → index-QxGYzGEN.d.mts.map} +1 -1
- package/dist/{index-1H93w_H6.d.cts → index-tFzoro1V.d.cts} +2 -2
- package/dist/{index-DFZ0SMwN.d.mts.map → index-tFzoro1V.d.cts.map} +1 -1
- package/dist/index.cjs +72 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +63 -63
- package/dist/index.mjs.map +1 -1
- package/dist/{local-DTidpa-a.cjs → local-Dx_1DLrj.cjs} +2 -2
- package/dist/{local-DTidpa-a.cjs.map → local-Dx_1DLrj.cjs.map} +1 -1
- package/dist/{local-Bkv-e8uM.mjs → local-s-ReaV9D.mjs} +2 -2
- package/dist/{local-Bkv-e8uM.mjs.map → local-s-ReaV9D.mjs.map} +1 -1
- package/dist/{migrate-BZRsJwni.mjs → migrate-83OqvIDr.mjs} +3 -3
- package/dist/{migrate-BZRsJwni.mjs.map → migrate-83OqvIDr.mjs.map} +1 -1
- package/dist/{migrate-CXLhrHwu.cjs → migrate-BCnC1nUd.cjs} +5 -5
- package/dist/{migrate-CXLhrHwu.cjs.map → migrate-BCnC1nUd.cjs.map} +1 -1
- package/dist/{migrate-DU4MtKxz.cjs → migrate-BwKps39u.cjs} +3 -3
- package/dist/{migrate-DU4MtKxz.cjs.map → migrate-BwKps39u.cjs.map} +1 -1
- package/dist/{migrate-DNOI23QA.mjs → migrate-rZPQE2lm.mjs} +5 -5
- package/dist/{migrate-DNOI23QA.mjs.map → migrate-rZPQE2lm.mjs.map} +1 -1
- package/dist/{notes-1TM_Vzi7.mjs → notes-BvER-Te2.mjs} +4 -3
- package/dist/notes-BvER-Te2.mjs.map +1 -0
- package/dist/{notes-BpaXOAkA.cjs → notes-Chp3yhjU.cjs} +4 -3
- package/dist/{notes-1TM_Vzi7.mjs.map → notes-Chp3yhjU.cjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{projectBucket-DbEWuLGX.cjs → projectBucket-BcbirdBj.cjs} +2 -2
- package/dist/{projectBucket-DbEWuLGX.cjs.map → projectBucket-BcbirdBj.cjs.map} +1 -1
- package/dist/{projectBucket-BRgsSv2P.mjs → projectBucket-BfE46Zj9.mjs} +2 -2
- package/dist/{projectBucket-BRgsSv2P.mjs.map → projectBucket-BfE46Zj9.mjs.map} +1 -1
- package/dist/{publish-DjFgxu2v.mjs → publish-Cm7fGhl3.mjs} +2 -2
- package/dist/{publish-DjFgxu2v.mjs.map → publish-Cm7fGhl3.mjs.map} +1 -1
- package/dist/{publish-BN1l3tPF.cjs → publish-N7RjKFiU.cjs} +2 -2
- package/dist/{publish-BN1l3tPF.cjs.map → publish-N7RjKFiU.cjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-NEKsqNAw.mjs → resolve-BP-wvD7F.mjs} +4 -4
- package/dist/{resolve-NEKsqNAw.mjs.map → resolve-BP-wvD7F.mjs.map} +1 -1
- package/dist/{resolve-BHVyg4Hg.cjs → resolve-Bjz8vr36.cjs} +4 -4
- package/dist/{resolve-BHVyg4Hg.cjs.map → resolve-Bjz8vr36.cjs.map} +1 -1
- package/dist/{rollback-CUjvOIDE.cjs → rollback-C0QxGS7N.cjs} +6 -6
- package/dist/{rollback-CUjvOIDE.cjs.map → rollback-C0QxGS7N.cjs.map} +1 -1
- package/dist/{rollback-BVgyLE7B.mjs → rollback-OWocmLZ3.mjs} +6 -6
- package/dist/{rollback-BVgyLE7B.mjs.map → rollback-OWocmLZ3.mjs.map} +1 -1
- package/dist/{runtime-CKOkIrw0.d.cts → runtime-BpGIXfYr.d.mts} +2 -2
- package/dist/{runtime-CKOkIrw0.d.cts.map → runtime-BpGIXfYr.d.mts.map} +1 -1
- package/dist/{runtime-Cdvv8SfU.d.mts → runtime-DLV0CNZ4.d.cts} +2 -2
- package/dist/{runtime-Cdvv8SfU.d.mts.map → runtime-DLV0CNZ4.d.cts.map} +1 -1
- package/dist/{s3-BO4yr61G.mjs → s3-BrXDNOOi.mjs} +3 -3
- package/dist/{s3-BO4yr61G.mjs.map → s3-BrXDNOOi.mjs.map} +1 -1
- package/dist/{s3-DnPbDfQN.cjs → s3-CQHYU8Iy.cjs} +3 -3
- package/dist/{s3-DnPbDfQN.cjs.map → s3-CQHYU8Iy.cjs.map} +1 -1
- package/dist/{serverSetup-BxnCM11A.mjs → serverSetup-DAXGkiFf.mjs} +6 -6
- package/dist/{serverSetup-BxnCM11A.mjs.map → serverSetup-DAXGkiFf.mjs.map} +1 -1
- package/dist/{serverSetup-DScJ7tQs.cjs → serverSetup-DcyafYuO.cjs} +6 -6
- package/dist/{serverSetup-DScJ7tQs.cjs.map → serverSetup-DcyafYuO.cjs.map} +1 -1
- package/dist/{sniffer-9smKtb86.mjs → sniffer-D6dwbd7L.mjs} +7 -7
- package/dist/{sniffer-9smKtb86.mjs.map → sniffer-D6dwbd7L.mjs.map} +1 -1
- package/dist/{sniffer-DHcxlSJF.cjs → sniffer-DpiPHtcR.cjs} +7 -7
- package/dist/{sniffer-DHcxlSJF.cjs.map → sniffer-DpiPHtcR.cjs.map} +1 -1
- package/dist/{snsSubscriptions-CygsiXhb.mjs → snsSubscriptions-BVaZU0qQ.mjs} +4 -4
- package/dist/{snsSubscriptions-CygsiXhb.mjs.map → snsSubscriptions-BVaZU0qQ.mjs.map} +1 -1
- package/dist/{snsSubscriptions-B8TYeAM-.cjs → snsSubscriptions-CXpZqb-Y.cjs} +4 -4
- package/dist/{snsSubscriptions-B8TYeAM-.cjs.map → snsSubscriptions-CXpZqb-Y.cjs.map} +1 -1
- package/dist/{sst-DiHVSku5.cjs → sst-C0VMb3o0.cjs} +5 -5
- package/dist/{sst-DiHVSku5.cjs.map → sst-C0VMb3o0.cjs.map} +1 -1
- package/dist/{sst-Bgb3WWEl.mjs → sst-CglMlWMQ.mjs} +5 -5
- package/dist/{sst-Bgb3WWEl.mjs.map → sst-CglMlWMQ.mjs.map} +1 -1
- package/dist/{stack-A3evQgbk.cjs → stack-DKloCsy6.cjs} +80 -24
- package/dist/stack-DKloCsy6.cjs.map +1 -0
- package/dist/{stack-Cy2FwO3Z.mjs → stack-DXHdVCsD.mjs} +62 -12
- package/dist/stack-DXHdVCsD.mjs.map +1 -0
- package/dist/{stage-Dgy08WVL.mjs → stage-BOOoPl_k.mjs} +6 -6
- package/dist/{stage-Dgy08WVL.mjs.map → stage-BOOoPl_k.mjs.map} +1 -1
- package/dist/{stage-Bm1x9Anp.cjs → stage-CcsCwU8-.cjs} +6 -6
- package/dist/{stage-Bm1x9Anp.cjs.map → stage-CcsCwU8-.cjs.map} +1 -1
- package/dist/{stages-COiipV8N.mjs → stages-CCAAe1tP.mjs} +2 -2
- package/dist/{stages-COiipV8N.mjs.map → stages-CCAAe1tP.mjs.map} +1 -1
- package/dist/{stages-BWg3NU3J.cjs → stages-D49CUpBY.cjs} +2 -2
- package/dist/{stages-BWg3NU3J.cjs.map → stages-D49CUpBY.cjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-BDRxzEZD.cjs → terminal-Bc0XhkqW.cjs} +2 -2
- package/dist/{terminal-BDRxzEZD.cjs.map → terminal-Bc0XhkqW.cjs.map} +1 -1
- package/dist/{terminal-BRAIvH83.mjs → terminal-D92VjzyD.mjs} +2 -2
- package/dist/{terminal-BRAIvH83.mjs.map → terminal-D92VjzyD.mjs.map} +1 -1
- package/dist/{types-DEmuMHsS.d.cts → types-Bj1A1wkS.d.mts} +3 -3
- package/dist/{types-g_S0_RAi.d.mts.map → types-Bj1A1wkS.d.mts.map} +1 -1
- package/dist/{types-g_S0_RAi.d.mts → types-CV4AzwC_.d.cts} +4 -2
- package/dist/{types-DEmuMHsS.d.cts.map → types-CV4AzwC_.d.cts.map} +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-_aoe8v6u.mjs → workspace-B0PI9k9p.mjs} +28 -5
- package/dist/workspace-B0PI9k9p.mjs.map +1 -0
- package/dist/{workspace-CEpojAus.cjs → workspace-LR9DFjU8.cjs} +39 -4
- package/dist/workspace-LR9DFjU8.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/apps-BGu47YRF.cjs.map +0 -1
- package/dist/apps-DGod3aS9.mjs.map +0 -1
- package/dist/compose-BVeevJO_.mjs.map +0 -1
- package/dist/compose-CXgwCuqv.mjs.map +0 -1
- package/dist/compose-CshnO-Th.cjs.map +0 -1
- package/dist/compose-IsvqY6iX.cjs.map +0 -1
- package/dist/deploy-CjubyZlP.mjs.map +0 -1
- package/dist/deploy-DQjEjUfB.cjs.map +0 -1
- package/dist/notes-BpaXOAkA.cjs.map +0 -1
- package/dist/stack-A3evQgbk.cjs.map +0 -1
- package/dist/stack-Cy2FwO3Z.mjs.map +0 -1
- package/dist/workspace-CEpojAus.cjs.map +0 -1
- package/dist/workspace-_aoe8v6u.mjs.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
|
-
import { B as FileSecretsStore, F as toEmbeddableSecrets, G as getOrCreateKey, H as encrypt, J as readKey, K as keystoreProject, V as decrypt, W as getKeystoreDir, bt as gkmHome, k as secretsStoreFor } from "./credentials-
|
|
3
|
-
import { B as LOGS_PORT, v as getPublicEnvPrefix } from "./workspace-
|
|
2
|
+
import { B as FileSecretsStore, F as toEmbeddableSecrets, G as getOrCreateKey, H as encrypt, J as readKey, K as keystoreProject, V as decrypt, W as getKeystoreDir, bt as gkmHome, k as secretsStoreFor } from "./credentials-DmNpxlFO.mjs";
|
|
3
|
+
import { B as LOGS_PORT, R as stageSampleRate, ct as protectedSubdomains, dt as fileServerLabel, ot as appKey, v as getPublicEnvPrefix } from "./workspace-B0PI9k9p.mjs";
|
|
4
|
+
import { i as holdsEveryCache, t as DEFAULT_CACHE } from "./types-Y1NfWlyG.mjs";
|
|
4
5
|
import { ConfigNotFound, NotInAnApp, loadWorkspaceAppInfo, loadWorkspaceConfig } from "./config.mjs";
|
|
5
6
|
import { dirname, join, resolve } from "node:path";
|
|
6
7
|
import { existsSync } from "node:fs";
|
|
7
8
|
import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
8
9
|
import { createServer } from "node:net";
|
|
9
10
|
import { createHash, randomBytes, randomInt } from "node:crypto";
|
|
10
|
-
import { DEFAULT_POSTGRES_VERSION, WILDCARD_SUBDOMAIN, drawSecret, kebabCase, providedKeyFor } from "@geekmidas/manifest";
|
|
11
|
+
import { CLIENT_IP_HEADER, DEFAULT_POSTGRES_VERSION, EDGE_TOKEN_HEADER, IMAGE_ORIGINS_KEY, PUBLIC_PREFIX, TELEMETRY_KEYS, WILDCARD_SUBDOMAIN, bucketExpiry, dependentsOf, drawSecret, hostLabels, imageOriginSources, isHostedDeclaration, isPublicDeclaration, isWildcardSite, kebabCase, providedKeyFor, publicEnvFor } from "@geekmidas/manifest";
|
|
11
12
|
import { generateKeyring } from "@geekmidas/constructs/encryption";
|
|
12
13
|
import { config } from "dotenv";
|
|
13
14
|
import { stringify } from "yaml";
|
|
@@ -126,13 +127,15 @@ function getPublicUrlArgNames(app) {
|
|
|
126
127
|
* It is reached, by default, through an SSH tunnel: published on 127.0.0.1
|
|
127
128
|
* only, because a port Docker publishes on every interface is opened in the
|
|
128
129
|
* firewall by Docker itself, past ufw's rules. Served publicly, it is a host
|
|
129
|
-
* on the stack's
|
|
130
|
+
* on the stack's edge — the `Telemetry` construct's label under the stage's
|
|
131
|
+
* domain — that refuses every address not allowed.
|
|
130
132
|
*
|
|
131
133
|
* Pure: the stack decides it, and the phases print and check it.
|
|
132
134
|
*/
|
|
133
135
|
/**
|
|
134
|
-
* The image, pinned
|
|
135
|
-
*
|
|
136
|
+
* The image, pinned — unless the `Telemetry` construct names its own. A log
|
|
137
|
+
* store's on-disk format is the thing that must not move under a running
|
|
138
|
+
* stack, so a new version is a change to this line, or to the construct's.
|
|
136
139
|
*/
|
|
137
140
|
const OPENOBSERVE_IMAGE = "public.ecr.aws/zinclabs/openobserve:v1.0.4";
|
|
138
141
|
/** Its compose service name — the host the apps send to. */
|
|
@@ -156,6 +159,33 @@ var LogsPasswordWeak = class extends GkmError {
|
|
|
156
159
|
this.name = "LogsPasswordWeak";
|
|
157
160
|
}
|
|
158
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* The loopback port a stage's OpenObserve is published on is held by another
|
|
164
|
+
* stack on its server — two stages on one machine, both on `5080`.
|
|
165
|
+
*/
|
|
166
|
+
var LogsPortTaken = class extends GkmError {
|
|
167
|
+
stage;
|
|
168
|
+
port;
|
|
169
|
+
holder;
|
|
170
|
+
named;
|
|
171
|
+
constructor(stage, port, holder, named) {
|
|
172
|
+
super(named ? `deploy.telemetry.${stage}.port is ${port}, and '${holder}' already publishes ${port} on this server. Give the stage another: deploy.telemetry.${stage}.port = ${port + 1}, or remove port to have a free one picked.` : `No loopback port from ${port} up is free for the stage '${stage}'s OpenObserve on this server ('${holder}' holds the last one tried). Set one: deploy.telemetry.${stage}.port = <free port>.`);
|
|
173
|
+
this.stage = stage;
|
|
174
|
+
this.port = port;
|
|
175
|
+
this.holder = holder;
|
|
176
|
+
this.named = named;
|
|
177
|
+
this.name = "LogsPortTaken";
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
/** A deployed stage with logs on and no root login stored yet. */
|
|
181
|
+
var LogsLoginMissing = class extends GkmError {
|
|
182
|
+
stage;
|
|
183
|
+
constructor(stage) {
|
|
184
|
+
super(`The stage '${stage}' runs OpenObserve and has no ${LOGS_EMAIL_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to store it, or set the login its OpenObserve already has: gkm secrets:set ${LOGS_EMAIL_KEY} admin@… --stage ${stage}`);
|
|
185
|
+
this.stage = stage;
|
|
186
|
+
this.name = "LogsLoginMissing";
|
|
187
|
+
}
|
|
188
|
+
};
|
|
159
189
|
/** A deployed stage with logs on and no root password generated yet. */
|
|
160
190
|
var LogsPasswordMissing = class extends GkmError {
|
|
161
191
|
stage;
|
|
@@ -177,25 +207,41 @@ function generateLogsPassword() {
|
|
|
177
207
|
return `${randomBytes(24).toString("base64url")}-Zo1`;
|
|
178
208
|
}
|
|
179
209
|
/**
|
|
180
|
-
* The stage's secrets with
|
|
210
|
+
* The stage's secrets with its root login stored, where they hold none:
|
|
211
|
+
* a generated password, and the email `admin@<stage domain>`.
|
|
212
|
+
*
|
|
213
|
+
* Stored once and read ever after, never derived again: OpenObserve creates
|
|
214
|
+
* its root user from these only on its first start, in its data volume, so a
|
|
215
|
+
* login computed afresh on each deploy would leave the stored user behind
|
|
216
|
+
* the moment what it was computed from — the stage's domain — moved. The
|
|
217
|
+
* first email is the one every stage's OpenObserve was created with before
|
|
218
|
+
* the login was stored, so a running stage keeps signing in.
|
|
219
|
+
*
|
|
181
220
|
* Pure, like `withGeneratedSecrets`: the caller keeps the result once the
|
|
182
221
|
* run goes ahead.
|
|
183
222
|
*/
|
|
184
|
-
function
|
|
185
|
-
|
|
223
|
+
function withLogsLogin(secrets, domain) {
|
|
224
|
+
const custom = { ...secrets.custom };
|
|
225
|
+
const generated = [];
|
|
226
|
+
if (!custom["ZO_ROOT_USER_EMAIL"] && domain) {
|
|
227
|
+
custom[LOGS_EMAIL_KEY] = `admin@${domain}`;
|
|
228
|
+
generated.push(LOGS_EMAIL_KEY);
|
|
229
|
+
}
|
|
230
|
+
if (!custom["ZO_ROOT_USER_PASSWORD"]) {
|
|
231
|
+
custom[LOGS_PASSWORD_KEY] = generateLogsPassword();
|
|
232
|
+
generated.push(LOGS_PASSWORD_KEY);
|
|
233
|
+
}
|
|
234
|
+
if (generated.length === 0) return {
|
|
186
235
|
secrets,
|
|
187
|
-
generated
|
|
236
|
+
generated
|
|
188
237
|
};
|
|
189
238
|
return {
|
|
190
239
|
secrets: {
|
|
191
240
|
...secrets,
|
|
192
|
-
custom
|
|
193
|
-
...secrets.custom,
|
|
194
|
-
[LOGS_PASSWORD_KEY]: generateLogsPassword()
|
|
195
|
-
},
|
|
241
|
+
custom,
|
|
196
242
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
197
243
|
},
|
|
198
|
-
generated
|
|
244
|
+
generated
|
|
199
245
|
};
|
|
200
246
|
}
|
|
201
247
|
/**
|
|
@@ -212,13 +258,15 @@ function otlpHeaders(email, password) {
|
|
|
212
258
|
function stackLogs(options) {
|
|
213
259
|
const { config, stage, local, custom } = options;
|
|
214
260
|
if (!local && !options.domain) throw new NoDomainForStage(stage);
|
|
215
|
-
const email = custom["ZO_ROOT_USER_EMAIL"] ?? (local ? options.localLogin?.email ?? "admin@gkm.localhost" :
|
|
261
|
+
const email = custom["ZO_ROOT_USER_EMAIL"] ?? (local ? options.localLogin?.email ?? "admin@gkm.localhost" : void 0);
|
|
262
|
+
if (!email) throw new LogsLoginMissing(stage);
|
|
216
263
|
const set = custom[LOGS_PASSWORD_KEY];
|
|
217
264
|
const password = set ?? (local ? options.localLogin?.password : void 0);
|
|
218
265
|
if (!password) throw new LogsPasswordMissing(stage);
|
|
219
266
|
if (!isStrongLogsPassword(password)) throw new LogsPasswordWeak(stage);
|
|
220
|
-
const
|
|
221
|
-
const
|
|
267
|
+
const { label } = options.telemetry;
|
|
268
|
+
const host = config.public ? local ? `${label}.${options.project}.localhost` : `${label}.${options.domain}` : void 0;
|
|
269
|
+
const url = host ? `https://${host}${local && options.https !== 443 ? `:${options.https}` : ""}` : loopbackUrl(config.port);
|
|
222
270
|
return {
|
|
223
271
|
...config,
|
|
224
272
|
email,
|
|
@@ -226,6 +274,7 @@ function stackLogs(options) {
|
|
|
226
274
|
passwordFromSecrets: Boolean(set),
|
|
227
275
|
url,
|
|
228
276
|
...host ? { host } : {},
|
|
277
|
+
image: options.telemetry.image ?? "public.ecr.aws/zinclabs/openobserve:v1.0.4",
|
|
229
278
|
env: {
|
|
230
279
|
[LOGS_EMAIL_KEY]: email,
|
|
231
280
|
[LOGS_PASSWORD_KEY]: password,
|
|
@@ -239,6 +288,31 @@ function stackLogs(options) {
|
|
|
239
288
|
}
|
|
240
289
|
};
|
|
241
290
|
}
|
|
291
|
+
/** Where a browser opens a loopback-published OpenObserve: the tunnel's end. */
|
|
292
|
+
function loopbackUrl(port) {
|
|
293
|
+
return `http://localhost:${port}`;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The stack's OpenObserve published on another loopback port — the one the
|
|
297
|
+
* server has free for it (`logsPortOnServer`). Served publicly, it publishes
|
|
298
|
+
* none, and is returned as it is.
|
|
299
|
+
*/
|
|
300
|
+
function logsOnPort(logs, port) {
|
|
301
|
+
if (logs.public || logs.port === port) return logs;
|
|
302
|
+
return {
|
|
303
|
+
...logs,
|
|
304
|
+
port,
|
|
305
|
+
url: loopbackUrl(port)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* What OpenObserve's service publishes: its port on the server's loopback
|
|
310
|
+
* only — Docker opens a port it publishes on every interface in the firewall
|
|
311
|
+
* itself, past ufw — and nothing when it is served through the edge.
|
|
312
|
+
*/
|
|
313
|
+
function logsPorts(logs) {
|
|
314
|
+
return logs.public ? {} : { ports: [`127.0.0.1:${logs.port}:${LOGS_PORT}`] };
|
|
315
|
+
}
|
|
242
316
|
/**
|
|
243
317
|
* OpenObserve's service. The image has no shell, `wget` or `curl`, so its
|
|
244
318
|
* health check is its own binary asking the running server for its status —
|
|
@@ -246,14 +320,14 @@ function stackLogs(options) {
|
|
|
246
320
|
*/
|
|
247
321
|
function logsService(logs) {
|
|
248
322
|
return {
|
|
249
|
-
image:
|
|
323
|
+
image: logs.image,
|
|
250
324
|
restart: "unless-stopped",
|
|
251
325
|
env_file: [{
|
|
252
326
|
path: `./${LOGS_SERVICE}.env`,
|
|
253
327
|
format: "raw"
|
|
254
328
|
}],
|
|
255
329
|
volumes: ["openobserve-data:/data"],
|
|
256
|
-
...logs
|
|
330
|
+
...logsPorts(logs),
|
|
257
331
|
healthcheck: {
|
|
258
332
|
test: [
|
|
259
333
|
"CMD",
|
|
@@ -466,6 +540,364 @@ function volumeOf(container) {
|
|
|
466
540
|
}[container];
|
|
467
541
|
}
|
|
468
542
|
//#endregion
|
|
543
|
+
//#region src/generators/processorRoute.ts
|
|
544
|
+
/**
|
|
545
|
+
* Where `gkm dev` serves a file server's processors, on the dev server of the
|
|
546
|
+
* app holding them: named after the file server.
|
|
547
|
+
*
|
|
548
|
+
* One definition for both sides — the dev server mounts it, and the local
|
|
549
|
+
* edge rewrites each processor pattern on the file server's host onto it — so
|
|
550
|
+
* the path the edge sends and the path the server answers cannot drift.
|
|
551
|
+
*/
|
|
552
|
+
const PROCESSORS_DEV_PREFIX = "/__gkm/processors/";
|
|
553
|
+
/** The base a file server's processors answer under, in `gkm dev`. */
|
|
554
|
+
function processorsDevRoute(fileServerId) {
|
|
555
|
+
return `${PROCESSORS_DEV_PREFIX}${fileServerId}`;
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region src/reconcile/caddyfile.ts
|
|
559
|
+
/**
|
|
560
|
+
* The Caddy configuration a plan implies.
|
|
561
|
+
*
|
|
562
|
+
* A file server is a *domain that serves a bucket*, and locally it had neither:
|
|
563
|
+
* `UPLOADS_URL` resolved to MinIO's path-style address, which works and
|
|
564
|
+
* is not the deployed shape. MinIO's own virtual-host mode cannot fix that —
|
|
565
|
+
* it reads the leading label *as the bucket name*, so it produces the right
|
|
566
|
+
* shape only when the server's id and the bucket's happen to agree, and never
|
|
567
|
+
* for a server fronting two buckets.
|
|
568
|
+
*
|
|
569
|
+
* So the mapping lives in front of MinIO instead: one host per file server,
|
|
570
|
+
* rewriting the bucket in as a path prefix. That is the whole of it — no
|
|
571
|
+
* caching, because caching is not what is missing locally, and a caching proxy
|
|
572
|
+
* would add an invalidation story a local stack has no use for.
|
|
573
|
+
*
|
|
574
|
+
* What it buys beyond the shape is a certificate: gkm's local authority
|
|
575
|
+
* (`trust/authority.ts`) issues one for the stage's hosts, which the edge
|
|
576
|
+
* serves the way a deployed edge serves the stage's own, so a local address is
|
|
577
|
+
* `https://` like the deployed one, and
|
|
578
|
+
* everything downstream of that — `Secure` cookies, `SameSite`, a cookie domain
|
|
579
|
+
* with more than one host under it — starts behaving the way it will in
|
|
580
|
+
* production rather than the way `http://localhost` allows.
|
|
581
|
+
*
|
|
582
|
+
* Pure, like `composeFor`: what should exist is data, and rendering it is one
|
|
583
|
+
* line at the edge.
|
|
584
|
+
*/
|
|
585
|
+
/**
|
|
586
|
+
* The kinds the edge serves.
|
|
587
|
+
*
|
|
588
|
+
* Everything that owns a *public address*. Deployed, each of these has a real
|
|
589
|
+
* hostname and a certificate, so this is what makes the local shape the same
|
|
590
|
+
* one rather than a near-enough one — and the application is indifferent
|
|
591
|
+
* either way, because it reads whichever address was injected and never
|
|
592
|
+
* composes one.
|
|
593
|
+
*
|
|
594
|
+
* Adding a kind here is the whole of adding it to the edge.
|
|
595
|
+
*/
|
|
596
|
+
const EDGE_KINDS = {
|
|
597
|
+
"file-server": true,
|
|
598
|
+
"rest-api": true,
|
|
599
|
+
"websocket-api": true,
|
|
600
|
+
site: true
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* How the edge reaches the host, from inside its container.
|
|
604
|
+
*
|
|
605
|
+
* A surface and a site are served by processes `gkm dev` starts on the host,
|
|
606
|
+
* not by containers — so the edge has to leave Docker's network to reach them.
|
|
607
|
+
* Docker Desktop resolves this name already; on Linux the compose definition
|
|
608
|
+
* maps it to the host gateway.
|
|
609
|
+
*/
|
|
610
|
+
const HOST_GATEWAY$1 = "host.docker.internal";
|
|
611
|
+
/** Where the edge's container reads `.gkm/caddy-sites/` — routes and certificates. */
|
|
612
|
+
const CADDY_SITES_IN_CONTAINER = "/etc/caddy/sites";
|
|
613
|
+
/**
|
|
614
|
+
* The suffix every local host shares.
|
|
615
|
+
*
|
|
616
|
+
* `.localhost` rather than a made-up TLD because it resolves to loopback
|
|
617
|
+
* without touching `/etc/hosts` — macOS and systemd-resolved both answer for
|
|
618
|
+
* subdomains of it.
|
|
619
|
+
*/
|
|
620
|
+
const LOCAL_TLD = "localhost";
|
|
621
|
+
/**
|
|
622
|
+
* The sites a plan implies, one per file server.
|
|
623
|
+
*
|
|
624
|
+
* The leading label is the *server's* stage-scoped name rather than the
|
|
625
|
+
* bucket's, which is the difference that matters: two servers over one bucket
|
|
626
|
+
* are a legitimate arrangement — two cache behaviours, one origin — and naming
|
|
627
|
+
* the host after the bucket would make them collide.
|
|
628
|
+
*/
|
|
629
|
+
function sitesFor(plan, project, addresses = {}, processorAddresses = {}) {
|
|
630
|
+
const byId = new Map(plan.resources.map((r) => [r.id, r]));
|
|
631
|
+
const sites = [];
|
|
632
|
+
for (const resource of plan.resources) {
|
|
633
|
+
if (!EDGE_KINDS[resource.kind]) continue;
|
|
634
|
+
const host = hostFor(resource, project);
|
|
635
|
+
if (resource.kind === "file-server") {
|
|
636
|
+
const origin = resource.of ? byId.get(resource.of) : void 0;
|
|
637
|
+
if (!origin) continue;
|
|
638
|
+
const address = processorAddresses[resource.id];
|
|
639
|
+
const port = address ? portOf(address) : void 0;
|
|
640
|
+
sites.push({
|
|
641
|
+
host,
|
|
642
|
+
upstream: "http://minio:9000",
|
|
643
|
+
rewrite: `/${origin.name}{uri}`,
|
|
644
|
+
...resource.processors?.length && port ? { processors: {
|
|
645
|
+
prefixes: resource.processors,
|
|
646
|
+
upstream: `http://${HOST_GATEWAY$1}:${port}`,
|
|
647
|
+
under: processorsDevRoute(resource.id)
|
|
648
|
+
} } : {}
|
|
649
|
+
});
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
const address = addresses[resource.id];
|
|
653
|
+
if (!address) continue;
|
|
654
|
+
const port = portOf(address);
|
|
655
|
+
if (!port) continue;
|
|
656
|
+
const upstream = `http://${HOST_GATEWAY$1}:${port}`;
|
|
657
|
+
if (resource.subdomain === WILDCARD_SUBDOMAIN) {
|
|
658
|
+
sites.push({
|
|
659
|
+
host,
|
|
660
|
+
upstream,
|
|
661
|
+
tenants: tenantsOf(resource, host, addresses)
|
|
662
|
+
});
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
const { aliases, redirects } = hostsFor(resource, project);
|
|
666
|
+
sites.push({
|
|
667
|
+
host,
|
|
668
|
+
upstream,
|
|
669
|
+
...aliases.length ? { aliases } : {},
|
|
670
|
+
...redirects.length ? { redirects } : {}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return sites;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* What stands between a wildcard site and a host that is not a tenant.
|
|
677
|
+
*
|
|
678
|
+
* Caddy already prefers a named host to the `*`, so `api.shop.localhost`
|
|
679
|
+
* reaches the API whatever the wildcard says. What it cannot know is the
|
|
680
|
+
* labels nothing is running on: `www`, or an app this stage has not started.
|
|
681
|
+
* Those are refused here, so no slug that a deploy would protect is ever
|
|
682
|
+
* served locally either.
|
|
683
|
+
*
|
|
684
|
+
* The `hosts` route is asked through `forward_auth`, which is a deployed
|
|
685
|
+
* edge's check in miniature: a `2xx` lets the request through, and any other
|
|
686
|
+
* answer — the app's own `404` — is what the browser gets, so a mistyped
|
|
687
|
+
* slug fails here and not first in production. Without an address for the
|
|
688
|
+
* surface serving it there is nothing to ask, and every host is served.
|
|
689
|
+
*/
|
|
690
|
+
function tenantsOf(resource, host, addresses) {
|
|
691
|
+
const domain = host.slice(`${WILDCARD_SUBDOMAIN}.`.length);
|
|
692
|
+
const surface = resource.hosts ? addresses[resource.hosts.surface] : void 0;
|
|
693
|
+
const port = surface ? portOf(surface) : void 0;
|
|
694
|
+
return {
|
|
695
|
+
protected: (resource.protectedSubdomains ?? []).map((label) => `${label}.${domain}`),
|
|
696
|
+
...resource.hosts && port ? { hosts: {
|
|
697
|
+
upstream: `http://${HOST_GATEWAY$1}:${port}`,
|
|
698
|
+
uri: `${resource.hosts.path}?domain={host}`
|
|
699
|
+
} } : {}
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
/** The port a local address answers on, defaulting by scheme. */
|
|
703
|
+
function portOf(address) {
|
|
704
|
+
try {
|
|
705
|
+
const { port, protocol } = new URL(address);
|
|
706
|
+
return port || (protocol === "https:" ? "443" : "80");
|
|
707
|
+
} catch {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Where one file server answers, including the stage its name carries.
|
|
713
|
+
*
|
|
714
|
+
* The project is a label rather than a decoration: it is what keeps two
|
|
715
|
+
* checkouts from answering on one address. Omitted when there is no project to
|
|
716
|
+
* name, because an empty label makes `uploads..localhost` — a host nothing
|
|
717
|
+
* resolves and no certificate can be issued for.
|
|
718
|
+
*/
|
|
719
|
+
function hostFor(resource, project) {
|
|
720
|
+
const label = resource.root && project ? stageOf(resource) : labelOf(resource);
|
|
721
|
+
if (resource.subdomain === WILDCARD_SUBDOMAIN) return [
|
|
722
|
+
WILDCARD_SUBDOMAIN,
|
|
723
|
+
stageOf(resource),
|
|
724
|
+
project,
|
|
725
|
+
LOCAL_TLD
|
|
726
|
+
].filter(Boolean).join(".");
|
|
727
|
+
return [
|
|
728
|
+
label,
|
|
729
|
+
project,
|
|
730
|
+
LOCAL_TLD
|
|
731
|
+
].filter(Boolean).join(".");
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Where a resource answers, every host of it: {@link hostFor}'s, and each
|
|
735
|
+
* alias and redirect label under the project, carrying the stage as its own
|
|
736
|
+
* label does — `www-test.shop.localhost` for `gkm test`.
|
|
737
|
+
*/
|
|
738
|
+
function hostsFor(resource, project) {
|
|
739
|
+
const stage = stageOf(resource);
|
|
740
|
+
const under = (label) => [
|
|
741
|
+
stage ? `${label}-${stage}` : label,
|
|
742
|
+
project,
|
|
743
|
+
LOCAL_TLD
|
|
744
|
+
].filter(Boolean).join(".");
|
|
745
|
+
return {
|
|
746
|
+
host: hostFor(resource, project),
|
|
747
|
+
aliases: (resource.aliases ?? []).map(under),
|
|
748
|
+
redirects: (resource.redirects ?? []).map(under)
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* A resource's own label: its `subdomain` where it declared one, and a file
|
|
753
|
+
* server's own name — the label a deploy uses too — with the stage it carries
|
|
754
|
+
* kept, so `gkm test` and `gkm dev` still answer on different hosts.
|
|
755
|
+
*/
|
|
756
|
+
function labelOf(resource) {
|
|
757
|
+
const own = resource.kind === "file-server" ? fileServerLabel(resource.id) : resource.subdomain;
|
|
758
|
+
if (!own) return resource.name;
|
|
759
|
+
const stage = stageOf(resource);
|
|
760
|
+
return stage ? `${own}-${stage}` : own;
|
|
761
|
+
}
|
|
762
|
+
/** The stage a resource's name carries, or nothing for the local stage's. */
|
|
763
|
+
function stageOf(resource) {
|
|
764
|
+
const base = resource.id.toLowerCase();
|
|
765
|
+
return resource.name === base ? void 0 : resource.name.slice(base.length + 1);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* The static root config, which only ever imports.
|
|
769
|
+
*
|
|
770
|
+
* Written once and identical for every stage, because the *sites* are what
|
|
771
|
+
* differ and they live in their own files. That split is not tidiness: one
|
|
772
|
+
* container serves every stage — the same way one Postgres holds `orders` and
|
|
773
|
+
* `orders_test` — so a single Caddyfile would mean `gkm test` deleting the
|
|
774
|
+
* routes `gkm dev` is serving, and each command silently breaking the other.
|
|
775
|
+
*/
|
|
776
|
+
function caddyfileRoot() {
|
|
777
|
+
return `${GENERATED}
|
|
778
|
+
{
|
|
779
|
+
# No ACME, no public DNS: each stage's certificate is gkm's, beside its
|
|
780
|
+
# routes, and the names are local.
|
|
781
|
+
auto_https disable_redirects
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
# One file per stage, so two stages share this edge the way they already share
|
|
785
|
+
# one Postgres and one MinIO.
|
|
786
|
+
import ${CADDY_SITES_IN_CONTAINER}/*.caddy
|
|
787
|
+
`;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* One stage's sites, as the file imported above.
|
|
791
|
+
*
|
|
792
|
+
* `rewrite` rather than a path prefix on the address: the bucket is the
|
|
793
|
+
* origin's business, and the client asks for the key it stored.
|
|
794
|
+
*
|
|
795
|
+
* `header_up Host {upstream_hostport}` matters more than it looks. MinIO routes
|
|
796
|
+
* and signs on the Host header, so forwarding the requested hostname would make
|
|
797
|
+
* it look for a bucket named after the domain.
|
|
798
|
+
*/
|
|
799
|
+
function toCaddyfile(sites, options) {
|
|
800
|
+
if (sites.length === 0) return `${GENERATED}
|
|
801
|
+
# No file server is declared in this stage, so it routes nothing.
|
|
802
|
+
`;
|
|
803
|
+
const port = options.port && options.port !== 443 ? `:${options.port}` : "";
|
|
804
|
+
const blocks = sites.map(({ host, upstream, rewrite, processors, tenants, aliases, redirects }) => {
|
|
805
|
+
const proxy = `reverse_proxy ${upstream} {${rewrite ? `
|
|
806
|
+
rewrite ${rewrite}
|
|
807
|
+
# MinIO routes and signs on the Host header, so forwarding the requested
|
|
808
|
+
# hostname would make it look for a bucket named after the domain.
|
|
809
|
+
header_up Host {upstream_hostport}` : `
|
|
810
|
+
# The application reads whatever address was injected, so it has to see
|
|
811
|
+
# the one a caller used — that is what makes a redirect, a cookie domain
|
|
812
|
+
# and a generated link point back here rather than at the upstream.
|
|
813
|
+
header_up Host {host}
|
|
814
|
+
header_up X-Forwarded-Proto {scheme}`}
|
|
815
|
+
}`;
|
|
816
|
+
const redirectBlocks = (redirects ?? []).map((from) => `
|
|
817
|
+
https://${from} {
|
|
818
|
+
tls ${options.certificate} ${options.certificate}
|
|
819
|
+
|
|
820
|
+
redir https://${host}${port}{uri} permanent
|
|
821
|
+
}`).join("");
|
|
822
|
+
return `
|
|
823
|
+
${[host, ...aliases ?? []].map((name) => `https://${name}`).join(", ")} {
|
|
824
|
+
tls ${options.certificate} ${options.certificate}
|
|
825
|
+
|
|
826
|
+
${clientIpRule(options.edgeToken)}
|
|
827
|
+
${processors ? `
|
|
828
|
+
# Its processors' patterns, to the dev server holding them — under the
|
|
829
|
+
# route it mounts them on. Answered there, so the bucket below never is.
|
|
830
|
+
@processors path ${processors.prefixes.map((prefix) => `${prefix}*`).join(" ")}
|
|
831
|
+
handle @processors {
|
|
832
|
+
reverse_proxy ${processors.upstream} {
|
|
833
|
+
rewrite ${processors.under}{uri}
|
|
834
|
+
header_up Host {host}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
` : ""}${tenants ? tenantBlock(tenants, proxy) : ` ${proxy}`}
|
|
838
|
+
}${redirectBlocks}`;
|
|
839
|
+
});
|
|
840
|
+
return `${GENERATED}${blocks.join("\n")}\n`;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* A wildcard site's routes: a protected host refused, every other host asked
|
|
844
|
+
* about before it is proxied. `handle` blocks rather than bare directives,
|
|
845
|
+
* because Caddy orders directives itself and would proxy before it refused.
|
|
846
|
+
*/
|
|
847
|
+
function tenantBlock(tenants, proxy) {
|
|
848
|
+
return `${tenants.protected.length ? `
|
|
849
|
+
# Labels an app answers on, or that the workspace protects: never a
|
|
850
|
+
# tenant's, whether or not anything is running on them.
|
|
851
|
+
@protected host ${tenants.protected.join(" ")}
|
|
852
|
+
handle @protected {
|
|
853
|
+
respond 404
|
|
854
|
+
}
|
|
855
|
+
` : ""}
|
|
856
|
+
handle {${tenants.hosts ? `
|
|
857
|
+
# Which hosts are tenants is the app's to say: its \`hosts\` route
|
|
858
|
+
# answers 200 to serve this one, and anything else goes back as is.
|
|
859
|
+
forward_auth ${tenants.hosts.upstream} {
|
|
860
|
+
uri ${tenants.hosts.uri}
|
|
861
|
+
}
|
|
862
|
+
` : ""}
|
|
863
|
+
${proxy.replaceAll("\n", "\n ")}
|
|
864
|
+
}`;
|
|
865
|
+
}
|
|
866
|
+
const GENERATED = `# Generated by gkm from the construct manifest — do not edit.
|
|
867
|
+
#
|
|
868
|
+
# One host per declared file server, in front of the object store that holds its
|
|
869
|
+
# objects. This is the shape a file server has deployed — a domain serving a
|
|
870
|
+
# bucket — which MinIO alone cannot produce: its virtual-host mode reads the
|
|
871
|
+
# leading label as the bucket name.
|
|
872
|
+
#
|
|
873
|
+
# Certificates come from gkm's local CA. "gkm dev" and "gkm test" point Node at
|
|
874
|
+
# its root, so nothing has to be installed to use these URLs from code; a
|
|
875
|
+
# browser needs the root trusted once ("gkm trust").
|
|
876
|
+
`;
|
|
877
|
+
/**
|
|
878
|
+
* The lines every site block of an edge opens with, for gkm's own
|
|
879
|
+
* `x-gkm-client-ip` — the client address the auth server rate-limits by.
|
|
880
|
+
*
|
|
881
|
+
* Only a service of this stack may send it. One that calls a sibling at its
|
|
882
|
+
* public address comes through this edge, and proves where it comes from with
|
|
883
|
+
* the stack's token (`x-gkm-edge-token`), derived from the stage's seed and
|
|
884
|
+
* handed to every process of the stack — never to a browser. A request
|
|
885
|
+
* without it has the header removed, so nobody outside can choose the address
|
|
886
|
+
* they are rate-limited by. Without a token, it is removed from every request.
|
|
887
|
+
*/
|
|
888
|
+
function clientIpRule(edgeToken) {
|
|
889
|
+
if (!edgeToken) return `
|
|
890
|
+
# gkm's own header, which only a service of this stack may send: the auth
|
|
891
|
+
# server rate-limits by the client address it carries.
|
|
892
|
+
request_header -${CLIENT_IP_HEADER}`;
|
|
893
|
+
return `
|
|
894
|
+
# gkm's own header, which only a service of this stack may send — proven by
|
|
895
|
+
# the stack's token: the auth server rate-limits by the client address it
|
|
896
|
+
# carries. Removed from every other request.
|
|
897
|
+
@gkm_outside not header ${EDGE_TOKEN_HEADER} ${edgeToken}
|
|
898
|
+
request_header @gkm_outside -${CLIENT_IP_HEADER}`;
|
|
899
|
+
}
|
|
900
|
+
//#endregion
|
|
469
901
|
//#region src/reconcile/emulator.ts
|
|
470
902
|
/**
|
|
471
903
|
* The AWS emulator (floci, LocalStack-compatible) the `sns` backend runs on
|
|
@@ -600,6 +1032,465 @@ function watchedBuckets(manifest, subscribers) {
|
|
|
600
1032
|
return watched;
|
|
601
1033
|
}
|
|
602
1034
|
//#endregion
|
|
1035
|
+
//#region src/telemetry/edges.ts
|
|
1036
|
+
/**
|
|
1037
|
+
* Which processes use a `Telemetry` node — read off the manifest's edges.
|
|
1038
|
+
*
|
|
1039
|
+
* A process uses telemetry when its own declaration names the node: a
|
|
1040
|
+
* surface's `telemetry`, a worker's. A surface's process runs its own
|
|
1041
|
+
* endpoints, so a worker's edge never counts for it.
|
|
1042
|
+
*
|
|
1043
|
+
* A site's edge is recorded and never followed here: a site is handed none of
|
|
1044
|
+
* the node's keys (see `PUBLIC.telemetry`).
|
|
1045
|
+
*/
|
|
1046
|
+
/** The `OTEL_*` keys a `Telemetry` node provides. */
|
|
1047
|
+
const TELEMETRY_ENV_KEYS = TELEMETRY_KEYS;
|
|
1048
|
+
/** Whether `key` is one of the keys a `Telemetry` node provides. */
|
|
1049
|
+
function isTelemetryKey(key) {
|
|
1050
|
+
return TELEMETRY_ENV_KEYS.includes(key);
|
|
1051
|
+
}
|
|
1052
|
+
/** The node a declaration's `telemetry` edge names, when it names one. */
|
|
1053
|
+
function nodeOf(manifest, id) {
|
|
1054
|
+
if (!id) return void 0;
|
|
1055
|
+
const node = manifest[id];
|
|
1056
|
+
return node?.kind === "telemetry" ? node : void 0;
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* The `Telemetry` node the process for `id` — a surface, a worker, or a file
|
|
1060
|
+
* server's processor unit, by construct id — emits through, or undefined
|
|
1061
|
+
* when it has no edge to one.
|
|
1062
|
+
*/
|
|
1063
|
+
function telemetryOf(manifest, id) {
|
|
1064
|
+
const declaration = manifest[id];
|
|
1065
|
+
if (!declaration) return void 0;
|
|
1066
|
+
if (declaration.kind === "worker" || declaration.kind === "file-server") return nodeOf(manifest, declaration.telemetry);
|
|
1067
|
+
if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api") return void 0;
|
|
1068
|
+
return nodeOf(manifest, declaration.telemetry);
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* The `Telemetry` node the app `appName` emits through — its surface's, or
|
|
1072
|
+
* undefined for a site, an app without one, or one with no edge.
|
|
1073
|
+
*/
|
|
1074
|
+
function appTelemetry(manifest, appName) {
|
|
1075
|
+
const id = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api") && appKey(id) === appName)?.[0];
|
|
1076
|
+
return id ? telemetryOf(manifest, id) : void 0;
|
|
1077
|
+
}
|
|
1078
|
+
/** Whether any process in the manifest emits through a `Telemetry` node. */
|
|
1079
|
+
function usesTelemetry(manifest) {
|
|
1080
|
+
return Object.entries(manifest).some(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api" || d.kind === "worker" || d.kind === "file-server") && telemetryOf(manifest, id) !== void 0);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* One process's share of the telemetry keys a stage resolved: all of them,
|
|
1084
|
+
* named for the process, when it has an edge to the node — and none
|
|
1085
|
+
* otherwise.
|
|
1086
|
+
*
|
|
1087
|
+
* `env` is everything else the process is handed; its `OTEL_*` keys are
|
|
1088
|
+
* replaced, never merged, so a process without the edge cannot inherit them.
|
|
1089
|
+
*/
|
|
1090
|
+
function scopeTelemetryEnv(env, options) {
|
|
1091
|
+
const scoped = Object.fromEntries(Object.entries(env).filter(([key]) => !isTelemetryKey(key)));
|
|
1092
|
+
if (!options.uses || !options.telemetry) return scoped;
|
|
1093
|
+
const values = Object.fromEntries(Object.entries(options.telemetry).filter(([key]) => isTelemetryKey(key)));
|
|
1094
|
+
if (!values.OTEL_EXPORTER_OTLP_ENDPOINT) return scoped;
|
|
1095
|
+
return {
|
|
1096
|
+
...scoped,
|
|
1097
|
+
...values,
|
|
1098
|
+
OTEL_SERVICE_NAME: options.serviceName
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/** Whether the site `siteId` has an edge to a `Telemetry` node. */
|
|
1102
|
+
function siteUsesTelemetry(manifest, siteId) {
|
|
1103
|
+
const site = manifest[siteId];
|
|
1104
|
+
return site?.kind === "site" && nodeOf(manifest, site.telemetry) !== void 0;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Whether the client of the surface `surfaceId` propagates trace context:
|
|
1108
|
+
* when a site that calls it has an edge to a `Telemetry` node. One client
|
|
1109
|
+
* serves every site that calls the surface on the host, so one with the
|
|
1110
|
+
* edge turns it on; a site's image generates its own, from its own edge.
|
|
1111
|
+
*/
|
|
1112
|
+
function surfaceClientTraced(manifest, surfaceId) {
|
|
1113
|
+
return Object.entries(manifest).some(([id, d]) => d.kind === "site" && siteUsesTelemetry(manifest, id) && d.dependencies.some((edge) => edge.target === surfaceId));
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Whether the site app `appName`'s clients propagate trace context, and at
|
|
1117
|
+
* what rate: when the site has an edge to a `Telemetry` construct, at the
|
|
1118
|
+
* stage's sample rate — a public value, every trace locally — and not at all
|
|
1119
|
+
* for a stage that sends no telemetry.
|
|
1120
|
+
*/
|
|
1121
|
+
function siteClientTelemetry(manifest, appName, workspace, stage) {
|
|
1122
|
+
const id = Object.entries(manifest).find(([id, d]) => d.kind === "site" && appKey(id) === appName)?.[0];
|
|
1123
|
+
if (!id || !siteUsesTelemetry(manifest, id)) return void 0;
|
|
1124
|
+
const sampleRate = stageSampleRate(workspace.deploy?.telemetry, stage ?? workspace.stages.local, !stage || stage === workspace.stages.local);
|
|
1125
|
+
return sampleRate === void 0 ? void 0 : { sampleRate };
|
|
1126
|
+
}
|
|
1127
|
+
/** The label a log UI answers on when the workspace declares no `Telemetry`. */
|
|
1128
|
+
const DEFAULT_TELEMETRY_ID = "Telemetry";
|
|
1129
|
+
/**
|
|
1130
|
+
* Two `Telemetry` nodes declare different labels or images for the one
|
|
1131
|
+
* OpenObserve a stack runs.
|
|
1132
|
+
*/
|
|
1133
|
+
var TelemetryNodesDisagree = class extends GkmError {
|
|
1134
|
+
field;
|
|
1135
|
+
ids;
|
|
1136
|
+
constructor(field, ids) {
|
|
1137
|
+
super(`A stack runs one OpenObserve for every Telemetry node, and ${ids.join(", ")} give it different ${field === "subdomain" ? "labels" : "images"}. Give each the same ${field}${field === "subdomain" ? " (each defaults to its id kebab-cased)" : ""}.`);
|
|
1138
|
+
this.field = field;
|
|
1139
|
+
this.ids = ids;
|
|
1140
|
+
this.name = "TelemetryNodesDisagree";
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
/**
|
|
1144
|
+
* The stack's one OpenObserve, as the workspace's `Telemetry` nodes declare
|
|
1145
|
+
* it: the label its UI answers on (`hostLabels`: `subdomain`, else the id
|
|
1146
|
+
* kebab-cased) and the image it runs, where a node names one.
|
|
1147
|
+
*
|
|
1148
|
+
* @throws {TelemetryNodesDisagree} when two nodes declare different ones
|
|
1149
|
+
*/
|
|
1150
|
+
function stackTelemetry(manifest) {
|
|
1151
|
+
const nodes = Object.values(manifest).filter((d) => d.kind === "telemetry").sort((a, b) => a.id.localeCompare(b.id));
|
|
1152
|
+
const labels = [...new Set((nodes.length ? nodes : [{ id: DEFAULT_TELEMETRY_ID }]).map((node) => hostLabels(node).primary))];
|
|
1153
|
+
if (labels.length > 1) throw new TelemetryNodesDisagree("subdomain", nodes.map((node) => node.id));
|
|
1154
|
+
const images = [...new Set(nodes.flatMap((node) => node.image ?? []))];
|
|
1155
|
+
if (images.length > 1) throw new TelemetryNodesDisagree("image", nodes.filter((node) => node.image).map((node) => node.id));
|
|
1156
|
+
return {
|
|
1157
|
+
label: labels[0],
|
|
1158
|
+
...images[0] ? { image: images[0] } : {}
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/reconcile/plan.ts
|
|
1163
|
+
/**
|
|
1164
|
+
* The reconcile plan — what a manifest wants to exist, for one stage.
|
|
1165
|
+
*
|
|
1166
|
+
* Pure. Turning the plan into running containers and provisioned resources is
|
|
1167
|
+
* the applier's job; deciding *what* should exist is this, so the decisions can
|
|
1168
|
+
* be asserted as data rather than by starting Docker.
|
|
1169
|
+
*
|
|
1170
|
+
* One plan serves every stage. `gkm dev` reconciles `development` and `gkm test`
|
|
1171
|
+
* reconciles `test`; they differ only in what the resources are called, never in
|
|
1172
|
+
* what infrastructure exists. Roles are cluster-scoped in Postgres while grants
|
|
1173
|
+
* are per-object, so one container and one role pair serve both.
|
|
1174
|
+
*/
|
|
1175
|
+
/**
|
|
1176
|
+
* Which container serves a kind.
|
|
1177
|
+
*
|
|
1178
|
+
* Derived kinds map to the same container as their parent — a schema tenant
|
|
1179
|
+
* lives in its parent's Postgres — so the set is deduplicated rather than
|
|
1180
|
+
* counted.
|
|
1181
|
+
*/
|
|
1182
|
+
const CONTAINERS = {
|
|
1183
|
+
database: "postgres",
|
|
1184
|
+
"database-reader": "postgres",
|
|
1185
|
+
"database-schema": "postgres",
|
|
1186
|
+
objects: "minio",
|
|
1187
|
+
"file-server": "caddy",
|
|
1188
|
+
email: "mailpit",
|
|
1189
|
+
inbox: "mailpit",
|
|
1190
|
+
"websocket-api": "redis"
|
|
1191
|
+
};
|
|
1192
|
+
/**
|
|
1193
|
+
* The container a cache backend needs locally.
|
|
1194
|
+
*
|
|
1195
|
+
* Each one matches the protocol its deployed form speaks, which is the property
|
|
1196
|
+
* worth having: a cache that behaves differently in the two places is worse than
|
|
1197
|
+
* a slower one.
|
|
1198
|
+
*
|
|
1199
|
+
* `db` is deliberately absent, the same way `pgboss` is absent from
|
|
1200
|
+
* `EVENT_CONTAINERS`: the cache is a table in a database the manifest already
|
|
1201
|
+
* declares, so mapping it here would start a container for a project that needs
|
|
1202
|
+
* none.
|
|
1203
|
+
*/
|
|
1204
|
+
const CACHE_CONTAINERS = {
|
|
1205
|
+
upstash: "redis-http",
|
|
1206
|
+
elasticache: "redis",
|
|
1207
|
+
redis: "redis"
|
|
1208
|
+
};
|
|
1209
|
+
/**
|
|
1210
|
+
* Kinds that resolve a value without anything running.
|
|
1211
|
+
*
|
|
1212
|
+
* A secret is the case: it has no address, so there is nothing to start and
|
|
1213
|
+
* nothing to connect to — but it still appears in the plan, because the target
|
|
1214
|
+
* still has to resolve it.
|
|
1215
|
+
*/
|
|
1216
|
+
const CONTAINERLESS = {
|
|
1217
|
+
secret: true,
|
|
1218
|
+
credential: true,
|
|
1219
|
+
encryption: true,
|
|
1220
|
+
"rest-api": true,
|
|
1221
|
+
site: true,
|
|
1222
|
+
"mobile-app": true,
|
|
1223
|
+
"external-api": true,
|
|
1224
|
+
telemetry: true
|
|
1225
|
+
};
|
|
1226
|
+
/** The container that collects telemetry locally, and serves its UI. */
|
|
1227
|
+
const TELEMETRY_CONTAINER = "openobserve";
|
|
1228
|
+
/**
|
|
1229
|
+
* Containers that cannot run alone.
|
|
1230
|
+
*
|
|
1231
|
+
* The one case is the cache: `serverless-redis-http` is a proxy and needs the
|
|
1232
|
+
* Redis it proxies. Kept here rather than in the compose definition so the plan
|
|
1233
|
+
* -- which is what decides what must be running -- still names everything.
|
|
1234
|
+
*/
|
|
1235
|
+
const REQUIRES = { "redis-http": ["redis"] };
|
|
1236
|
+
/**
|
|
1237
|
+
* The role each kind's one key plays, where it is not a URL.
|
|
1238
|
+
*
|
|
1239
|
+
* The twin of `ProvidesByKind` in `@geekmidas/manifest`: that is what a
|
|
1240
|
+
* construct declares, this is what the local target resolves, and both derive
|
|
1241
|
+
* the key from the same `providedKeyFor` so they cannot disagree.
|
|
1242
|
+
*/
|
|
1243
|
+
const ROLES = {
|
|
1244
|
+
queue: "publisherConnectionString",
|
|
1245
|
+
topic: "publisherConnectionString",
|
|
1246
|
+
credential: "credentials",
|
|
1247
|
+
"mobile-app": "scheme",
|
|
1248
|
+
objects: "connectionString"
|
|
1249
|
+
};
|
|
1250
|
+
/** The kinds whose container is the events backend's rather than their own. */
|
|
1251
|
+
const EVENT_KINDS = {
|
|
1252
|
+
queue: true,
|
|
1253
|
+
topic: true
|
|
1254
|
+
};
|
|
1255
|
+
/**
|
|
1256
|
+
* Which kinds provision something *inside* their container.
|
|
1257
|
+
*
|
|
1258
|
+
* A database creates a database, a bucket creates a bucket; mail creates
|
|
1259
|
+
* nothing — Mailpit accepts whatever is sent to it and has no per-stage object
|
|
1260
|
+
* to name. Both still appear in the plan, because both still resolve a URL; the
|
|
1261
|
+
* flag is the difference between "must be running" and "must be created".
|
|
1262
|
+
*/
|
|
1263
|
+
const PROVISIONS = {
|
|
1264
|
+
database: true,
|
|
1265
|
+
"database-reader": true,
|
|
1266
|
+
"database-schema": true,
|
|
1267
|
+
objects: true,
|
|
1268
|
+
cache: true,
|
|
1269
|
+
"file-server": true
|
|
1270
|
+
};
|
|
1271
|
+
/**
|
|
1272
|
+
* The container each events backend needs, where it needs one of its own.
|
|
1273
|
+
*
|
|
1274
|
+
* `pgboss` is deliberately absent rather than mapped to `postgres`: it is a
|
|
1275
|
+
* schema tenant in a database the manifest already declares, so mapping it here
|
|
1276
|
+
* would start a Postgres for a project that declared no database at all.
|
|
1277
|
+
*
|
|
1278
|
+
* This one comes from config rather than from a declaration because there are
|
|
1279
|
+
* no `topic` or `queue` kinds yet. When they land the mapping moves to
|
|
1280
|
+
* {@link CONTAINERS} keyed by kind, and this constant goes with them.
|
|
1281
|
+
*/
|
|
1282
|
+
const EVENT_CONTAINERS = {
|
|
1283
|
+
sns: "localstack",
|
|
1284
|
+
rabbitmq: "rabbitmq"
|
|
1285
|
+
};
|
|
1286
|
+
/** The backend a project gets when it declares queues or topics and says nothing. */
|
|
1287
|
+
const DEFAULT_EVENTS = "pgboss";
|
|
1288
|
+
/**
|
|
1289
|
+
* How a resource of each kind separates its stage suffix.
|
|
1290
|
+
*
|
|
1291
|
+
* Postgres identifiers are snake_case and a hyphen would need quoting
|
|
1292
|
+
* everywhere; buckets and queues are kebab and disallow underscores in some
|
|
1293
|
+
* providers. The suffix is the same word either way.
|
|
1294
|
+
*/
|
|
1295
|
+
const SEPARATORS = {
|
|
1296
|
+
database: "_",
|
|
1297
|
+
"database-reader": "_",
|
|
1298
|
+
"database-schema": "_",
|
|
1299
|
+
objects: "-"
|
|
1300
|
+
};
|
|
1301
|
+
/**
|
|
1302
|
+
* The stage-scoped name for a resource.
|
|
1303
|
+
*
|
|
1304
|
+
* The local stage carries no suffix, so `gkm dev` keeps using `orders` and a
|
|
1305
|
+
* developer's psql history, saved connections, and muscle memory survive a
|
|
1306
|
+
* change of stage name. Every other stage is suffixed.
|
|
1307
|
+
*/
|
|
1308
|
+
function resourceName(id, kind, stage, localStage) {
|
|
1309
|
+
const base = id.toLowerCase();
|
|
1310
|
+
if (stage === localStage) return base;
|
|
1311
|
+
return `${base}${SEPARATORS[kind] ?? "-"}${stage}`;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* The container a kind needs, or `undefined` if it needs none.
|
|
1315
|
+
*
|
|
1316
|
+
* Queues and topics have no container of their own — they live in whichever
|
|
1317
|
+
* broker the project selected, which is why the backend is an argument here
|
|
1318
|
+
* rather than a second pass that adds containers after the fact.
|
|
1319
|
+
*/
|
|
1320
|
+
function containerFor(kind, events = DEFAULT_EVENTS, cache = DEFAULT_CACHE.aws, derived = false, edge = true) {
|
|
1321
|
+
if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
|
|
1322
|
+
if (kind === "file-server") return edge ? "caddy" : CONTAINERS.objects;
|
|
1323
|
+
if (kind === "cache") {
|
|
1324
|
+
if (derived && !holdsEveryCache(cache)) return CONTAINERS.database;
|
|
1325
|
+
return CACHE_CONTAINERS[cache] ?? CONTAINERS.database;
|
|
1326
|
+
}
|
|
1327
|
+
return CONTAINERS[kind];
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Build the plan for a manifest and stage.
|
|
1331
|
+
*
|
|
1332
|
+
* `order` is the caller's provisioning order — parents before children — which
|
|
1333
|
+
* `provisionOrder` produces from the manifest. Passing it in keeps this
|
|
1334
|
+
* function free of the traversal and makes the ordering assertable on its own.
|
|
1335
|
+
*/
|
|
1336
|
+
function planFor(manifest, stage, order, options = {}) {
|
|
1337
|
+
const containers = /* @__PURE__ */ new Set();
|
|
1338
|
+
const resources = [];
|
|
1339
|
+
const fakes = {};
|
|
1340
|
+
const events = options.events ?? "pgboss";
|
|
1341
|
+
const cache = options.cache ?? DEFAULT_CACHE.aws;
|
|
1342
|
+
for (const id of order) {
|
|
1343
|
+
const declaration = manifest[id];
|
|
1344
|
+
if (!declaration) continue;
|
|
1345
|
+
const local = declaration.kind === "external-api" ? options.fakes?.[id] : void 0;
|
|
1346
|
+
const fake = local && {
|
|
1347
|
+
key: fakeKey(id),
|
|
1348
|
+
...local
|
|
1349
|
+
};
|
|
1350
|
+
if (fake) fakes[fake.key] = {
|
|
1351
|
+
id,
|
|
1352
|
+
...fake.image ? {
|
|
1353
|
+
image: fake.image,
|
|
1354
|
+
port: fake.port
|
|
1355
|
+
} : {}
|
|
1356
|
+
};
|
|
1357
|
+
const detached = declaration.kind === "cache" && holdsEveryCache(cache);
|
|
1358
|
+
const container = fake?.image ? fake.key : declaration.kind === "telemetry" ? usesTelemetry(manifest) ? TELEMETRY_CONTAINER : void 0 : containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", options.edge !== false);
|
|
1359
|
+
if (!container && !CONTAINERLESS[declaration.kind]) continue;
|
|
1360
|
+
if (container) {
|
|
1361
|
+
containers.add(container);
|
|
1362
|
+
for (const required of REQUIRES[container] ?? []) containers.add(required);
|
|
1363
|
+
}
|
|
1364
|
+
resources.push({
|
|
1365
|
+
id,
|
|
1366
|
+
kind: declaration.kind,
|
|
1367
|
+
...container ? { container } : {},
|
|
1368
|
+
name: resourceName(id, declaration.kind, stage, options.localStage),
|
|
1369
|
+
envKey: providedKeyFor(id, declaration.kind, ROLES[declaration.kind] ?? "url"),
|
|
1370
|
+
provisions: PROVISIONS[declaration.kind] === true,
|
|
1371
|
+
...declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "objects" || declaration.kind === "file-server" ? { callers: dependentsOf(manifest, id) } : {},
|
|
1372
|
+
...declaration.kind === "site" ? { publicEnv: publicEnvFor(declaration, manifest) } : {},
|
|
1373
|
+
...isPublicDeclaration(declaration) && imageOriginSources(declaration, manifest).length > 0 ? { imageOrigins: {
|
|
1374
|
+
key: `${PUBLIC_PREFIX[declaration.variant]}${IMAGE_ORIGINS_KEY}`,
|
|
1375
|
+
sources: imageOriginSources(declaration, manifest)
|
|
1376
|
+
} } : {},
|
|
1377
|
+
...declaration.kind === "mobile-app" ? {
|
|
1378
|
+
publicEnv: publicEnvFor(declaration, manifest),
|
|
1379
|
+
...declaration.scheme ? { scheme: declaration.scheme } : {}
|
|
1380
|
+
} : {},
|
|
1381
|
+
...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
|
|
1382
|
+
...declaration.kind === "file-server" && declaration.processors?.length ? { processors: [...new Set(declaration.processors.map((p) => p.prefix))].sort() } : {},
|
|
1383
|
+
...declaration.kind === "email" && declaration.from ? { from: declaration.from } : {},
|
|
1384
|
+
...declaration.kind === "inbox" ? { inbox: {
|
|
1385
|
+
addresses: declaration.addresses,
|
|
1386
|
+
subdomains: declaration.subdomains === true,
|
|
1387
|
+
topic: declaration.topic
|
|
1388
|
+
} } : {},
|
|
1389
|
+
...declaration.kind === "objects" && bucketExpiry(manifest, id) ? { expire: bucketExpiry(manifest, id) } : {},
|
|
1390
|
+
...(declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site") && declaration.subdomain ? { subdomain: declaration.subdomain } : {},
|
|
1391
|
+
...isHostedDeclaration(declaration) && hostLabels(declaration).aliases.length ? { aliases: [...hostLabels(declaration).aliases] } : {},
|
|
1392
|
+
...isHostedDeclaration(declaration) && hostLabels(declaration).redirects.length ? { redirects: [...hostLabels(declaration).redirects] } : {},
|
|
1393
|
+
...isWildcardSite(declaration) ? {
|
|
1394
|
+
protectedSubdomains: protectedSubdomains(manifest, options.protectedSubdomains),
|
|
1395
|
+
...declaration.hosts ? { hosts: declaration.hosts } : {}
|
|
1396
|
+
} : {},
|
|
1397
|
+
...fake ? { fake: {
|
|
1398
|
+
key: fake.key,
|
|
1399
|
+
credentials: fake.credentials
|
|
1400
|
+
} } : {},
|
|
1401
|
+
...declaration.kind === "external-api" && !fake ? { url: declaration.url } : {},
|
|
1402
|
+
...declaration.kind === "credential" && options.credentialFakes?.[id] !== void 0 ? { fakeCredentials: options.credentialFakes[id] } : {},
|
|
1403
|
+
...declaration.kind === "secret" && (declaration.length !== void 0 || declaration.symbols !== void 0) ? { format: {
|
|
1404
|
+
...declaration.length !== void 0 ? { length: declaration.length } : {},
|
|
1405
|
+
...declaration.symbols !== void 0 ? { symbols: declaration.symbols } : {}
|
|
1406
|
+
} } : {},
|
|
1407
|
+
..."of" in declaration && !detached ? { of: declaration.of } : {},
|
|
1408
|
+
..."schema" in declaration && declaration.schema ? { schema: declaration.schema } : {},
|
|
1409
|
+
..."version" in declaration && declaration.version ? { version: declaration.version } : {},
|
|
1410
|
+
..."image" in declaration && declaration.image ? { image: declaration.image } : {},
|
|
1411
|
+
..."extensions" in declaration && declaration.extensions?.length ? { extensions: declaration.extensions } : {},
|
|
1412
|
+
..."roles" in declaration && declaration.roles === false ? { roles: false } : {},
|
|
1413
|
+
..."table" in declaration && declaration.table && !detached ? { table: declaration.table } : {}
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
if (options.edge !== false && resources.some((r) => EDGE_KINDS[r.kind] === true)) containers.add("caddy");
|
|
1417
|
+
for (const extra of options.extraContainers ?? []) containers.add(extra);
|
|
1418
|
+
if (events === "pgboss" && resources.some((r) => EVENT_KINDS[r.kind]) && !resources.some((r) => r.kind === "database")) throw new PgBossNeedsDatabase(resources.filter((r) => EVENT_KINDS[r.kind]).map((r) => r.id));
|
|
1419
|
+
if (cache === "db") {
|
|
1420
|
+
const placeless = resources.filter((r) => r.kind === "cache" && !r.of);
|
|
1421
|
+
if (placeless.length > 0) {
|
|
1422
|
+
const databases = resources.filter((r) => r.kind === "database");
|
|
1423
|
+
const [only] = databases;
|
|
1424
|
+
if (!only) throw new CacheNeedsDatabase(resources.filter((r) => r.kind === "cache").map((r) => r.id));
|
|
1425
|
+
if (databases.length > 1) throw new CacheIsAmbiguous(placeless.map((r) => r.id), databases.map((r) => r.id));
|
|
1426
|
+
for (const resource of placeless) resource.of = only.id;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
const sites = resources.filter((r) => r.kind === "site" && r.subdomain !== WILDCARD_SUBDOMAIN);
|
|
1430
|
+
const root = rootSite(sites.map((r) => {
|
|
1431
|
+
const declared = manifest[r.id];
|
|
1432
|
+
return {
|
|
1433
|
+
name: appKey(r.id),
|
|
1434
|
+
...declared?.kind === "site" && declared.root ? { root: true } : {}
|
|
1435
|
+
};
|
|
1436
|
+
}));
|
|
1437
|
+
for (const site of sites) if (appKey(site.id) === root) site.root = true;
|
|
1438
|
+
const workerBroker = events === "pgboss" && Object.values(manifest).some((d) => d?.kind === "worker") && resources.some((r) => r.kind === "database");
|
|
1439
|
+
return {
|
|
1440
|
+
stage,
|
|
1441
|
+
events,
|
|
1442
|
+
cache,
|
|
1443
|
+
containers: [...containers],
|
|
1444
|
+
resources,
|
|
1445
|
+
...Object.keys(fakes).length ? { fakes } : {},
|
|
1446
|
+
...workerBroker ? { workerBroker: true } : {}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Queues or topics were declared with pg-boss and no database to hold them.
|
|
1451
|
+
*
|
|
1452
|
+
* Not a reconcile failure but a manifest one: the fix is a line of application
|
|
1453
|
+
* code either way — declare a database, or select a backend that brings its own
|
|
1454
|
+
* broker.
|
|
1455
|
+
*/
|
|
1456
|
+
var CacheNeedsDatabase = class extends GkmError {
|
|
1457
|
+
ids;
|
|
1458
|
+
constructor(ids) {
|
|
1459
|
+
super(`A cache backed by the database needs a declared database, and none was declared, and on this deploy target that is where a cache lives. Declare one. Caches affected: ${ids.join(", ")}.`);
|
|
1460
|
+
this.ids = ids;
|
|
1461
|
+
this.name = "CacheNeedsDatabase";
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
/**
|
|
1465
|
+
* A `'db'` cache — a server target's default — in an app that declares more
|
|
1466
|
+
* than one database.
|
|
1467
|
+
*
|
|
1468
|
+
* The target says *a* database and the graph offers several, so there is no
|
|
1469
|
+
* answer to give — and the wrong kind of failure would be to pick one, since a
|
|
1470
|
+
* cache silently landing in the wrong database is a bug that surfaces as
|
|
1471
|
+
* missing rows much later. The fix is a stronger statement in application code:
|
|
1472
|
+
* `orders.cache('Sessions')` names the database, which is a fact about the
|
|
1473
|
+
* application rather than a deployment choice.
|
|
1474
|
+
*/
|
|
1475
|
+
var CacheIsAmbiguous = class extends GkmError {
|
|
1476
|
+
ids;
|
|
1477
|
+
databases;
|
|
1478
|
+
constructor(ids, databases) {
|
|
1479
|
+
super(`A cache backed by the database needs to know which one, and this app declares ${databases.length}: ${databases.join(", ")}. Declare the cache from its database — e.g. ${databases[0]}.cache('Sessions') — rather than as a bare new Cache(). Caches affected: ${ids.join(", ")}.`);
|
|
1480
|
+
this.ids = ids;
|
|
1481
|
+
this.databases = databases;
|
|
1482
|
+
this.name = "CacheIsAmbiguous";
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
var PgBossNeedsDatabase = class extends GkmError {
|
|
1486
|
+
ids;
|
|
1487
|
+
constructor(ids) {
|
|
1488
|
+
super(`pg-boss keeps its queues in a declared database, and none was declared. Declare one: on this deploy target, events are carried by pg-boss. Queues and topics affected: ${ids.join(", ")}.`);
|
|
1489
|
+
this.ids = ids;
|
|
1490
|
+
this.name = "PgBossNeedsDatabase";
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
//#endregion
|
|
603
1494
|
//#region src/compose/redis.ts
|
|
604
1495
|
/**
|
|
605
1496
|
* The stack's Redis: what every declared cache lives in when a workspace runs
|
|
@@ -1178,14 +2069,14 @@ async function prepareEntryCredentials(options) {
|
|
|
1178
2069
|
const declaredKeys = [];
|
|
1179
2070
|
let reconciled;
|
|
1180
2071
|
if (workspace) {
|
|
1181
|
-
const { reconcileWorkspace } = await import("./apps-
|
|
2072
|
+
const { reconcileWorkspace } = await import("./apps-B4qOLFEC.mjs").then((n) => n.h);
|
|
1182
2073
|
const result = await reconcileWorkspace(workspace, {
|
|
1183
2074
|
stage: options.reconcileStage ?? workspace.stages.local,
|
|
1184
2075
|
start: options.startDocker ?? false
|
|
1185
2076
|
});
|
|
1186
2077
|
reconciled = result;
|
|
1187
2078
|
if (options.scoped && appName) {
|
|
1188
|
-
const { appProcess, processEnv } = await import("./apps-
|
|
2079
|
+
const { appProcess, processEnv } = await import("./apps-B4qOLFEC.mjs").then((n) => n.r);
|
|
1189
2080
|
const own = processEnv(result.manifest, appProcess(workspace, result.manifest, result.background, appName), { ...credentials }, result.env);
|
|
1190
2081
|
for (const key of Object.keys(credentials)) delete credentials[key];
|
|
1191
2082
|
Object.assign(credentials, own);
|
|
@@ -1241,7 +2132,7 @@ function composeFor(plan, options) {
|
|
|
1241
2132
|
const volumes = {};
|
|
1242
2133
|
for (const container of [...plan.containers].sort()) {
|
|
1243
2134
|
const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
|
|
1244
|
-
const named = container === "postgres" ? declaredPostgresImage(plan) : void 0;
|
|
2135
|
+
const named = container === "postgres" ? declaredPostgresImage(plan) : container === "openobserve" ? declaredTelemetryImage(plan) : void 0;
|
|
1245
2136
|
const fake = plan.fakes?.[container];
|
|
1246
2137
|
const image = named ?? (declared ? postgresImage(declared) : fake?.image ?? DEFAULT_IMAGES[container]);
|
|
1247
2138
|
if (!image) throw new UnknownContainer(container);
|
|
@@ -1307,6 +2198,13 @@ function declaredPostgresImage(plan) {
|
|
|
1307
2198
|
})));
|
|
1308
2199
|
return images[0];
|
|
1309
2200
|
}
|
|
2201
|
+
/**
|
|
2202
|
+
* The image a `Telemetry` node named for OpenObserve, if one did — the same
|
|
2203
|
+
* one the stack runs (`stackTelemetry` refuses two that disagree).
|
|
2204
|
+
*/
|
|
2205
|
+
function declaredTelemetryImage(plan) {
|
|
2206
|
+
return plan.resources.filter((r) => r.kind === "telemetry" && r.image).sort((a, b) => a.id.localeCompare(b.id))[0]?.image;
|
|
2207
|
+
}
|
|
1310
2208
|
/** Two databases on the one local cluster named different images for it. */
|
|
1311
2209
|
var ConflictingPostgresImages = class extends Error {
|
|
1312
2210
|
databases;
|
|
@@ -1555,6 +2453,6 @@ var UnassignedPort = class extends Error {
|
|
|
1555
2453
|
}
|
|
1556
2454
|
};
|
|
1557
2455
|
//#endregion
|
|
1558
|
-
export {
|
|
2456
|
+
export { clientIpRule as $, resourceName as A, NOTIFICATION_RULE_PREFIX as B, redisService as C, otlpHeaders as Ct, PgBossNeedsDatabase as D, getPublicUrlArgNames as Dt, withRedisPassword as E, NoDomainForStage as Et, stackTelemetry as F, EMULATOR_ACCESS_KEY_ID as G, minioWebhookEnv as H, surfaceClientTraced as I, emulatorQueueUrl as J, EMULATOR_REGION as K, telemetryOf as L, isTelemetryKey as M, scopeTelemetryEnv as N, TELEMETRY_CONTAINER as O, isMainFrontendApp as Ot, siteClientTelemetry as P, caddyfileRoot as Q, usesTelemetry as R, STACK_CACHE as S, logsService as St, stackRedis as T, withLogsLogin as Tt, objectsWebhookToken as U, minioNotificationRule as V, watchedBuckets as W, CADDY_SITES_IN_CONTAINER as X, emulatorTopicArn as Y, LOCAL_TLD as Z, readLocalCredentials as _, LOGS_SERVICE as _t, createEntryWrapper as a, DEFAULT_IMAGES as at, REDIS_PASSWORD_KEY as b, logsOnPort as bt, loadEnvFiles as c, portKeys as ct, prepareEntryCredentials as d, primaryPortKey as dt, hostFor as et, savePortState as f, serviceAddresses as ft, postgresSuperuser as g, LOGS_PASSWORD_KEY as gt, postgresRoleSlug as h, LOGS_ORG as ht, createCredentialsPreload as i, PROCESSORS_DEV_PREFIX as it, appTelemetry as j, planFor as k, resolveHost as kt, loadPortState as l, portsOf as lt, loadLocalCredentials as m, LOGS_EMAIL_KEY as mt, composeFor as n, sitesFor as nt, findAvailablePort as o, describeServices as ot, LOCAL_RABBITMQ_USER as p, LOCAL_LOGS_EMAIL as pt, emulatorEndpoint as q, toYaml as r, toCaddyfile as rt, isPortAvailable as s, fakeKey as st, CLUSTER_DATABASE as t, hostsFor as tt, loadSecretsForApp as u, postgresImage as ut, saveLocalCredentials as v, LogsPortTaken as vt, runsRedis as w, stackLogs as wt, REDIS_SERVICE as x, logsPorts as xt, withGeneratedSecrets as y, logsAccess as yt, HOST_GATEWAY as z };
|
|
1559
2457
|
|
|
1560
|
-
//# sourceMappingURL=compose-
|
|
2458
|
+
//# sourceMappingURL=compose-CANkT9bL.mjs.map
|