diff --git a/bin/cap-op-plugin.js b/bin/cap-op-plugin.js index a5167db..d17b0cd 100755 --- a/bin/cap-op-plugin.js +++ b/bin/cap-op-plugin.js @@ -95,6 +95,10 @@ async function generateRuntimeValues(option, inputYamlPath) { const valuesYaml = yaml.parse(await cds.utils.read(cds.utils.path.join(cds.root, 'chart/values.yaml'))) + //get saas-registry and xsuaa service keys + answerStruct['saasRegistryKeyName'] = getServiceInstanceKeyName(valuesYaml['serviceInstances'], 'saas-registry') || 'saas-registry' + answerStruct['xsuaaKeyName'] = getServiceInstanceKeyName(valuesYaml['serviceInstances'], 'xsuaa') || 'xsuaa' + let runtimeValuesYaml = yaml.parse(Mustache.render(await cds.utils.read(cds.utils.path.join(__dirname, '../files/runtime-values.yaml.hbs')), answerStruct)) if (!answerStruct['imagePullSecret']) @@ -140,6 +144,14 @@ async function generateRuntimeValues(option, inputYamlPath) { console.log("Generated 'runtime-values.yaml' file in the 'chart' folder.") } +function getServiceInstanceKeyName(serviceInstances, offeringName) { + for (const key in serviceInstances) { + if (serviceInstances[key].serviceOfferingName === offeringName) + return key + } + return null +} + function updateCdsConfigEnv(runtimeValuesYaml, workloadKey, workloadDefintion, cdsConfigHana) { const index = runtimeValuesYaml['workloads'][workloadKey][workloadDefintion]['env'].findIndex(e => e.name === 'CDS_CONFIG') if (index > -1) { diff --git a/files/runtime-values.yaml.hbs b/files/runtime-values.yaml.hbs index cce5d03..1126416 100644 --- a/files/runtime-values.yaml.hbs +++ b/files/runtime-values.yaml.hbs @@ -1,5 +1,5 @@ serviceInstances: - saas-registry: + {{saasRegistryKeyName}}: parameters: xsappname: {{appName}} appName: {{appName}} @@ -8,7 +8,7 @@ serviceInstances: appUrls: getDependencies: "https://{{providerSubdomain}}.{{appName}}.{{clusterDomain}}/callback/v1.0/dependencies" onSubscription: "https://{{capOperatorSubdomain}}.{{clusterDomain}}/provision/tenants/{tenantId}" - xsuaa: + {{xsuaaKeyName}}: parameters: xsappname: {{appName}} oauth2-configuration: