|
| 1 | +/* eslint-disable max-len */ |
| 2 | +const Command = require('../../Command'); |
| 3 | +const unInstallRoot = require('../root/uninstall.cmd'); |
| 4 | +const { downloadArgo } = require('../hybrid/helper'); |
| 5 | +const { Runner, components } = require('../../../../binary'); |
| 6 | + |
| 7 | + |
| 8 | +const unInstallAgentCmd = new Command({ |
| 9 | + root: false, |
| 10 | + parent: unInstallRoot, |
| 11 | + command: 'argo', |
| 12 | + description: 'Uninstall argo agent', |
| 13 | + webDocs: { |
| 14 | + category: 'Argo', |
| 15 | + title: 'Uninstall', |
| 16 | + weight: 100, |
| 17 | + }, |
| 18 | + builder: yargs => yargs |
| 19 | + .env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv |
| 20 | + .option('kube-context-name', { |
| 21 | + describe: 'Name of the kubernetes context on which monitor should be uninstalled [$CF_ARG_KUBE_CONTEXT_NAME]', |
| 22 | + }) |
| 23 | + .option('kube-namespace', { |
| 24 | + describe: 'Name of the namespace on which monitor should be uninstalled [$CF_ARG_KUBE_NAMESPACE]', |
| 25 | + }), |
| 26 | + handler: async (argv) => { |
| 27 | + const { |
| 28 | + 'kube-namespace': kubeNamespace, |
| 29 | + 'kube-context-name': kubeContextName, |
| 30 | + } = argv; |
| 31 | + |
| 32 | + const binLocation = await downloadArgo(); |
| 33 | + const componentRunner = new Runner(binLocation); |
| 34 | + |
| 35 | + const commands = [ |
| 36 | + 'uninstall', |
| 37 | + ]; |
| 38 | + |
| 39 | + if (kubeContextName) { |
| 40 | + commands.push('--kube-context-name'); |
| 41 | + commands.push(kubeContextName); |
| 42 | + } |
| 43 | + |
| 44 | + if (kubeNamespace) { |
| 45 | + commands.push('--kube-namespace'); |
| 46 | + commands.push(kubeNamespace); |
| 47 | + } |
| 48 | + |
| 49 | + await componentRunner.run(components.argo, commands); |
| 50 | + }, |
| 51 | +}); |
| 52 | + |
| 53 | +module.exports = unInstallAgentCmd; |
0 commit comments