Skip to content

Commit

Permalink
download components (#761)
Browse files Browse the repository at this point in the history
* download components

* eslint
  • Loading branch information
andrii-codefresh authored Nov 9, 2022
1 parent b74ca12 commit 4e9b9a2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
28 changes: 28 additions & 0 deletions lib/interface/cli/commands/components/download.cmd.js
Original file line number Diff line number Diff line change
@@ -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;
28 changes: 28 additions & 0 deletions lib/interface/cli/commands/hybrid/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1106,6 +1133,7 @@ module.exports = {
keyValueAsStringToObject,
objectToKeyValueArray,
downloadRelatedComponents: downloadHybridComponents,
downloadComponents,
downloadSteveDore,
downloadVeonona,
downloadProvider,
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.80.2",
"version": "0.80.3",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 4e9b9a2

Please sign in to comment.