Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Handle dynamic service instance key name in runtime-values.yaml #35

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bin/cap-op-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions files/runtime-values.yaml.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
serviceInstances:
saas-registry:
{{saasRegistryKeyName}}:
parameters:
xsappname: {{appName}}
appName: {{appName}}
Expand All @@ -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:
Expand Down
Loading