Skip to content

Commit

Permalink
Added shootdomain auto suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhprasad-sap committed Jul 15, 2024
1 parent fd95151 commit 41e34f6
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bin/cap-op-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const isCli = require.main === module
const cds = require('@sap/cds-dk')
const yaml = require('@sap/cds-foss').yaml
const Mustache = require('mustache')
const { execSync } = require('child_process')

const { ask, mergeObj, isCAPOperatorChart } = require('../lib/util')

Expand Down Expand Up @@ -72,7 +73,7 @@ async function generateRuntimeValues(option, inputYamlPath) {
const questions = [
['Enter app name for deployment: ', appName, true],
['Enter CAP Operator subdomain (In kyma cluster it is "cap-op" by default): ', 'cap-op', true],
['Enter your cluster shoot domain: ', '', true],
['Enter your cluster shoot domain: ', getShootDomain(), true],
['Enter your global account ID: ', '', true],
['Enter your provider subdomain: ', '', true],
['Enter your provider tenant ID: ', '', true],
Expand Down Expand Up @@ -157,6 +158,19 @@ function getAppDetails() {
return { appName: segments[segments.length - 1], appDescription: description }
}

function getShootDomain() {
let domain = ''
try {
const domainCmd = execSync(`kubectl config view --minify --output jsonpath="{.clusters[*].cluster.server}"`, { stdio: "pipe" }).toString()
const domainStartIndex = domainCmd.indexOf('api.')
if (domainStartIndex !== -1) {
domain = domainCmd.substring(domainStartIndex + 4)
}
} catch (error) {}

return domain
}

if (isCli) {
const [, , cmd, option, inputYamlPath] = process.argv;
(async () => await capOperatorPlugin(cmd, option, inputYamlPath ?? undefined))()
Expand Down

0 comments on commit 41e34f6

Please sign in to comment.