Skip to content

Commit

Permalink
more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhprasad-sap committed Aug 27, 2024
1 parent 2d7f0b4 commit d5ae516
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/cap-op-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ async function capOperatorPlugin(cmd, option, yamlPath) {
if (option === '--with-input-yaml' && !yamlPath)
return _usage(`Input yaml path is missing.`)

if (option === '--with-input-yaml' && !yamlPath && cds.utils.exists(cds.utils.path.join(cds.root,yamlPath)))
return _usage(`Input yaml path ${yamlPath} does not exist.`)

await generateRuntimeValues(option, yamlPath)
}

if (cmd === 'convert-to-configurable-template-chart') {
if (option === '--with-runtime-yaml' && !yamlPath)
return _usage(`Input runtime yaml path is missing.`)

if (option === '--with-runtime-yaml' && !yamlPath && cds.utils.exists(cds.utils.path.join(cds.root,yamlPath)))
return _usage(`Input runtime yaml path ${yamlPath} does not exist.`)

await convertToconfigurableTemplateChart(option, yamlPath)
}
} catch (e) {
Expand Down Expand Up @@ -72,7 +78,7 @@ EXAMPLES

async function transformRuntimeValues(runtimeYamlPath) {
console.log('Transforming runtime values file '+ cds.utils.path.join(cds.root,runtimeYamlPath) + ' to the configurable template chart format.')
runtimeYaml = yaml.parse(await cds.utils.read(cds.utils.path.join(cds.root, runtimeYamlPath)))
let runtimeYaml = yaml.parse(await cds.utils.read(cds.utils.path.join(cds.root, runtimeYamlPath)))
if (runtimeYaml?.workloads?.server?.deploymentDefinition?.env) {
const index = runtimeYaml.workloads.server.deploymentDefinition.env.findIndex(e => e.name === 'CDS_CONFIG')
if (index > -1) {
Expand All @@ -87,10 +93,8 @@ async function transformRuntimeValues(runtimeYamlPath) {
}

async function isRuntimeValueAlreadyTransformed(runtimeYamlPath) {
runtimeYaml = yaml.parse(await cds.utils.read(cds.utils.path.join(cds.root, runtimeYamlPath)))
if (runtimeYaml['hanaInstanceId'])
return true
return false
let runtimeYaml = yaml.parse(await cds.utils.read(cds.utils.path.join(cds.root, runtimeYamlPath)))
return !!runtimeYaml['hanaInstanceId']
}

async function convertToconfigurableTemplateChart(option, runtimeYamlPath) {
Expand Down

0 comments on commit d5ae516

Please sign in to comment.