diff --git a/lib/interface/cli/commands/components/download.cmd.js b/lib/interface/cli/commands/components/download.cmd.js new file mode 100644 index 000000000..c5b5d6172 --- /dev/null +++ b/lib/interface/cli/commands/components/download.cmd.js @@ -0,0 +1,28 @@ +const Command = require('../../Command'); +const componentsRoot = require('../root/components.cmd'); +const helper = require('../hybrid/helper'); + +const command = new Command({ + command: 'download', + parent: componentsRoot, + description: 'Download Codefresh CLI components', + webDocs: { + category: 'Components', + title: 'Download', + }, + builder: (yargs) => yargs + .env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv + .option('location', { + describe: 'Override download folder location. Default: ~/.Codefresh', + }) + .option('components', { + describe: 'Components. List of [stevedore, venona, argocd-agent, codefresh]', + }), + handler: async (argv) => { + console.log('Downloading components'); + const { location, components } = argv; + await helper.downloadComponents(location, components); + }, +}); + +module.exports = command; diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index f63a411bc..9771dde2c 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -420,6 +420,33 @@ async function downloadHybridComponents(location, bypassDownload = false) { console.log(`Kubernetes registrator installer downloaded successfully ${location}`); } +/* eslint-disable no-restricted-syntax, no-await-in-loop */ +async function downloadComponents(location = CODEFRESH_PATH, componentsArray = []) { + for (const component of componentsArray) { + switch (component) { + case 'stevedore': + await downloadSteveDore(location); + console.log(colors.green(`Kubernetes registrator installer downloaded successfully to ${location}`)); + break; + case 'venona': + await downloadVeonona(location); + console.log(colors.green(`Kubernetes components installer downloaded successfully to ${location}`)); + break; + case 'argocd-agent': + await downloadProvider({ provider: 'argocd-agent', location }); + console.log(colors.green(`Argocd-agent downloaded successfully to ${location}`)); + break; + case 'codefresh': + await downloadProvider({ provider: 'codefresh', location }); + console.log(colors.green(`Codefresh gitops provider downloaded successfully to ${location}`)); + break; + default: + console.log(colors.yellow(`Skip unknown component ${component}`)); + } + } +} +/* eslint-enable no-restricted-syntax, no-await-in-loop */ + async function runClusterAcceptanceTests({ apiHost, kubeNamespace, @@ -1106,6 +1133,7 @@ module.exports = { keyValueAsStringToObject, objectToKeyValueArray, downloadRelatedComponents: downloadHybridComponents, + downloadComponents, downloadSteveDore, downloadVeonona, downloadProvider, diff --git a/package.json b/package.json index 3580dd7df..59a650c5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.80.2", + "version": "0.80.3", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,