Skip to content

Commit

Permalink
runner delete should remove app-proxy as well (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-codefresh authored Oct 15, 2020
1 parent 62eef63 commit 74890d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
37 changes: 23 additions & 14 deletions lib/interface/cli/commands/hybrid/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
getRelatedAgents,
getRelatedNamespaces,
drawCodefreshFiglet,
unInstallAppProxy,
} = require('./helper');

const defaultNamespace = 'codefresh';
Expand Down Expand Up @@ -46,7 +47,7 @@ async function promptConfirmationMessage({
console.log('Deletion process aborted, exiting...');
process.exit(1);
}
}
}

const deleteCmd = new Command({
root: false,
Expand All @@ -66,7 +67,7 @@ const deleteCmd = new Command({
})
.option('url', {
describe: 'Codefresh system custom url',
})
})
.option('force', {
describe: 'Run the delete operation without asking to confirm (use with caution!)',
alias: 'f',
Expand Down Expand Up @@ -94,7 +95,7 @@ const deleteCmd = new Command({
'kube-context-name': kubeContextName,
'kube-namespace': kubeNamespace,
name: agentName,
'values': valuesFile,
values: valuesFile,
} = argv;

const [listReErr, runtimes] = await to(sdk.runtimeEnvs.list({ }));
Expand All @@ -109,28 +110,28 @@ const deleteCmd = new Command({

console.log(colors.green('This uninstaller will guide you through the runner uninstallation process'));
if (valuesFile) {
let valuesFileStr = fs.readFileSync(valuesFile, 'utf8');
const valuesFileStr = fs.readFileSync(valuesFile, 'utf8');
valuesObj = YAML.parse(valuesFileStr);

if ( !kubeConfigPath && valuesObj.ConfigPath ) {
if (!kubeConfigPath && valuesObj.ConfigPath) {
kubeConfigPath = valuesObj.ConfigPath;
}
if ( !kubeNamespace && valuesObj.Namespace ) {
if (!kubeNamespace && valuesObj.Namespace) {
kubeNamespace = valuesObj.Namespace;
}
if ( !kubeContextName && valuesObj.Context ) {
if (!kubeContextName && valuesObj.Context) {
kubeContextName = valuesObj.Context;
}
if ( !url && valuesObj.CodefreshHost ) {
url = valuesObj.CodefreshHost
if (!url && valuesObj.CodefreshHost) {
url = valuesObj.CodefreshHost;
}

if ( !agentName && valuesObj.AgentId ) {
agentName = valuesObj.AgentId
if (!agentName && valuesObj.AgentId) {
agentName = valuesObj.AgentId;
}
}
if (!url) {
url = DEFAULTS.URL
url = DEFAULTS.URL;
}

if (!kubeContextName) {
Expand Down Expand Up @@ -216,7 +217,7 @@ const deleteCmd = new Command({
await promptConfirmationMessage({ agentName, kubeNamespace, attachedRuntimes });
}

attachedRuntimes.forEach(async (reName) => {
await Promise.all(attachedRuntimes.map(async (reName) => {
const uninstallRuntimeOptions = {
'agent-name': agentName,
'runtime-kube-namespace': kubeNamespace,
Expand All @@ -226,9 +227,17 @@ const deleteCmd = new Command({
name: reName,
terminateProcess: false,
};
const re = runtimes.find(runtime => runtime.metadata.name === reName);
if (re.appProxy) {
await unInstallAppProxy({
kubeConfigPath,
kubeContextName,
kubeNamespace,
});
}
const [uninstallReErr] = await to(unInstallRuntime.handler(uninstallRuntimeOptions));
handleError(uninstallReErr, `Failed to uninstall runtime-environment "${colors.cyan(reName)}"`);
});
}));

const uninstallAgentOptions = {
'kube-namespace': kubeNamespace,
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ const initCmd = new Command({
await getAgents.handler({});
console.log('');
if (installMonitor) {
console.log(`Go to ${colors.blue('https://g.codefresh.io/kubernetes/monitor/services')} to view your cluster in Codefresh dashbaord`);
console.log(`Go to ${colors.blue('https://g.codefresh.io/kubernetes/services/')} to view your cluster in Codefresh dashbaord`);
}
console.log(`Link to the new runtime: ${colors.blue(`https://g.codefresh.io/account-admin/account-conf/runtime-environments?runtime=${encodeURI(installationPlan.getContext('runtimeName'))}`)}`);
console.log(`\nDocumenation link: ${colors.blue('https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release')}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.73.5",
"version": "0.73.6",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 74890d8

Please sign in to comment.