diff --git a/.github/workflows/multiTenant_deploy.yml b/.github/workflows/multiTenant_deploy.yml index 36b66ffe..0b8e3529 100644 --- a/.github/workflows/multiTenant_deploy.yml +++ b/.github/workflows/multiTenant_deploy.yml @@ -43,7 +43,7 @@ jobs: sudo apt update sudo apt install cf8-cli cf login -a "$CF_API" -u "$CF_USER" -p "$CF_PASSWORD" -o "$CF_ORG" -s "${{ github.event.inputs.space }}" - + - name: Prepare app & Build and deploy run: | npm pack @@ -51,13 +51,14 @@ jobs: cd app/multi-tenant/personal-space/cap-js-incidents-app npm i *.tgz - - name: Inject REPOSITORY_ID into mta.yaml + - name: Inject secrets into mta.yaml working-directory: app/multi-tenant/personal-space/cap-js-incidents-app run: | sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 sudo chmod a+x /usr/local/bin/yq yq -i e '(.modules[] | select(.name == "incidents-mtx-srv")).properties.REPOSITORY_ID = "${{ secrets.REPOSITORY_ID }}"' mta.yaml yq -i e '(.modules[] | select(.name == "incidents-mtx-mtx")).requires[] |= (select(.name == "app-api").properties.REPOSITORY_ID = "${{ secrets.REPOSITORY_ID }}")' mta.yaml + yq -i e '(.modules[] | select(.name == "incidents-mtx-mtx")).properties.DATABASE_ID = "${{ secrets.DATABASE_ID }}"' mta.yaml - name: Build and deploy working-directory: app/multi-tenant/personal-space/cap-js-incidents-app diff --git a/.github/workflows/multiTenant_deploy_and_Integration_test.yml b/.github/workflows/multiTenant_deploy_and_Integration_test.yml index c12f1219..372e6b79 100644 --- a/.github/workflows/multiTenant_deploy_and_Integration_test.yml +++ b/.github/workflows/multiTenant_deploy_and_Integration_test.yml @@ -49,13 +49,14 @@ jobs: cd app/multi-tenant/central-space/cap-js-incidents-app npm i *.tgz - - name: Inject REPOSITORY_ID into mta.yaml + - name: Inject secrets into mta.yaml working-directory: app/multi-tenant/central-space/cap-js-incidents-app run: | sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 sudo chmod a+x /usr/local/bin/yq yq -i e '(.modules[] | select(.name == "incidents-mtx-srv")).properties.REPOSITORY_ID = "${{ secrets.REPOSITORY_ID_MT }}"' mta.yaml yq -i e '(.modules[] | select(.name == "incidents-mtx-mtx")).requires[] |= (select(.name == "app-api").properties.REPOSITORY_ID = "${{ secrets.REPOSITORY_ID_MT }}")' mta.yaml + yq -i e '(.modules[] | select(.name == "incidents-mtx-mtx")).properties.DATABASE_ID = "${{ secrets.DATABASE_ID }}"' mta.yaml - name: Build and deploy working-directory: app/multi-tenant/central-space/cap-js-incidents-app diff --git a/app/multi-tenant/central-space/cap-js-incidents-app/mta.yaml b/app/multi-tenant/central-space/cap-js-incidents-app/mta.yaml index 3ebdc6bf..831f3a69 100644 --- a/app/multi-tenant/central-space/cap-js-incidents-app/mta.yaml +++ b/app/multi-tenant/central-space/cap-js-incidents-app/mta.yaml @@ -42,6 +42,8 @@ modules: # but let's give it a try here # https://cap.cloud.sap/docs/guides/multitenancy/#update-database-schema-for-tenants command: cds-mtx upgrade '*' + properties: + DATABASE_ID: REPLACE_WITH_YOUR_DATABASE_ID provides: - name: mtx-api properties: diff --git a/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/package.json b/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/package.json index bf19c0fb..65ee5d7e 100644 --- a/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/package.json +++ b/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/package.json @@ -2,11 +2,11 @@ "name": "incidents-mtx", "dependencies": { "@cap-js/sdm": "../../../cap-js-sdm-1.10.0.tgz", - "@sap/cds": "^8", - "@sap/cds-hana": "^2", - "@sap/cds-mtxs": "^2", + "@sap/cds": "^9", + "@cap-js/hana": "^2", + "@sap/cds-mtxs": "^3", "@sap/xsenv": "^5", - "@sap/xssec": "^3", + "@sap/xssec": "^4", "express": "^4" }, "scripts": { diff --git a/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/server.js b/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/server.js index 8f8b8dac..07aad5ef 100644 --- a/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/server.js +++ b/app/multi-tenant/central-space/cap-js-incidents-app/mtx/sidecar/server.js @@ -9,6 +9,17 @@ cds.once('bootstrap', async (app) => { LOG.error('Hello'); app.disable('x-powered-by'); + const databaseId = process.env.DATABASE_ID; + if (databaseId && databaseId !== 'REPLACE_WITH_YOUR_DATABASE_ID') { + cds.env.requires['cds.xt.DeploymentService'] ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi.create ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi.create.database_id = databaseId; + LOG.info(`Configured HDI database_id from environment`); + } else { + LOG.error(`DATABASE_ID environment variable is not set or is still the placeholder. HDI container creation will fail.`); + } + try { const services = xsenv.getServices({ runtimeRepo: { tag: 'html5-apps-repo-rt' }, @@ -28,7 +39,6 @@ cds.once('bootstrap', async (app) => { LOG.info(`Configured SaaS dependency to SDM: ${runtimeSdmXsappname}`); LOG.info(`Configured SaaS dependency to Destination: ${runtimeDestinationXsappname}`); } catch (err) { - // LOG.warn(`Could not find service binding for HTML5 app repo runtime. Skipping Saas dependency setup. Error: ${err.message}`); LOG.warn(`Could not find service binding for needed dependency. Skipping Saas dependency setup. Error: ${err.message}`); } }); diff --git a/app/multi-tenant/personal-space/cap-js-incidents-app/mta.yaml b/app/multi-tenant/personal-space/cap-js-incidents-app/mta.yaml index 1ea444b0..947d1b76 100644 --- a/app/multi-tenant/personal-space/cap-js-incidents-app/mta.yaml +++ b/app/multi-tenant/personal-space/cap-js-incidents-app/mta.yaml @@ -42,6 +42,8 @@ modules: # but let's give it a try here # https://cap.cloud.sap/docs/guides/multitenancy/#update-database-schema-for-tenants command: cds-mtx upgrade '*' + properties: + DATABASE_ID: REPLACE_WITH_YOUR_DATABASE_ID provides: - name: mtx-api properties: diff --git a/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/package.json b/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/package.json index bf19c0fb..65ee5d7e 100644 --- a/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/package.json +++ b/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/package.json @@ -2,11 +2,11 @@ "name": "incidents-mtx", "dependencies": { "@cap-js/sdm": "../../../cap-js-sdm-1.10.0.tgz", - "@sap/cds": "^8", - "@sap/cds-hana": "^2", - "@sap/cds-mtxs": "^2", + "@sap/cds": "^9", + "@cap-js/hana": "^2", + "@sap/cds-mtxs": "^3", "@sap/xsenv": "^5", - "@sap/xssec": "^3", + "@sap/xssec": "^4", "express": "^4" }, "scripts": { diff --git a/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/server.js b/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/server.js index 8f8b8dac..07aad5ef 100644 --- a/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/server.js +++ b/app/multi-tenant/personal-space/cap-js-incidents-app/mtx/sidecar/server.js @@ -9,6 +9,17 @@ cds.once('bootstrap', async (app) => { LOG.error('Hello'); app.disable('x-powered-by'); + const databaseId = process.env.DATABASE_ID; + if (databaseId && databaseId !== 'REPLACE_WITH_YOUR_DATABASE_ID') { + cds.env.requires['cds.xt.DeploymentService'] ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi.create ??= {}; + cds.env.requires['cds.xt.DeploymentService'].hdi.create.database_id = databaseId; + LOG.info(`Configured HDI database_id from environment`); + } else { + LOG.error(`DATABASE_ID environment variable is not set or is still the placeholder. HDI container creation will fail.`); + } + try { const services = xsenv.getServices({ runtimeRepo: { tag: 'html5-apps-repo-rt' }, @@ -28,7 +39,6 @@ cds.once('bootstrap', async (app) => { LOG.info(`Configured SaaS dependency to SDM: ${runtimeSdmXsappname}`); LOG.info(`Configured SaaS dependency to Destination: ${runtimeDestinationXsappname}`); } catch (err) { - // LOG.warn(`Could not find service binding for HTML5 app repo runtime. Skipping Saas dependency setup. Error: ${err.message}`); LOG.warn(`Could not find service binding for needed dependency. Skipping Saas dependency setup. Error: ${err.message}`); } }); diff --git a/app/single-tenant/personal-space/incidents-app/mta.yaml b/app/single-tenant/personal-space/incidents-app/mta.yaml index 32d588b0..494c95fe 100644 --- a/app/single-tenant/personal-space/incidents-app/mta.yaml +++ b/app/single-tenant/personal-space/incidents-app/mta.yaml @@ -136,7 +136,7 @@ resources: parameters: config: tenant-mode: dedicated - xsappname: sdmincidents + xsappname: sdmincidents-${org}-${space} oauth2-configuration: redirect-uris: - ~{app-api/app-url}/**