diff --git a/lib/binary/components.js b/lib/binary/components.js index 97d1561a9..73232a837 100644 --- a/lib/binary/components.js +++ b/lib/binary/components.js @@ -37,21 +37,23 @@ module.exports = { }, }, gitops: { - name: 'gitops', - description: 'Install gitops agent', - version: { - prefix: '', - }, - local: { - versionFile: 'version.txt', - dir: 'gitops', - binary: 'argocd-agent', - }, - remote: { - versionPath: 'installer', - versionFile: 'VERSION', - branch: 'master', - repo: 'argocd-agent', - }, + 'argocd-agent': { + name: 'gitops', + description: 'Install gitops argocd agent', + version: { + prefix: '', + }, + local: { + versionFile: 'version.txt', + dir: 'gitops', + binary: 'argocd-agent', + }, + remote: { + versionPath: 'installer', + versionFile: 'VERSION', + branch: 'master', + repo: 'argocd-agent', + }, + } }, }; diff --git a/lib/interface/cli/commands/gitops/install.cmd.js b/lib/interface/cli/commands/gitops/install.cmd.js index 4d4a51f49..77c0cec8b 100644 --- a/lib/interface/cli/commands/gitops/install.cmd.js +++ b/lib/interface/cli/commands/gitops/install.cmd.js @@ -1,13 +1,13 @@ /* eslint-disable max-len */ const Command = require('../../Command'); const installRoot = require('../root/install.cmd'); -const { downloadArgo } = require('../hybrid/helper'); +const { downloadProvider } = require('../hybrid/helper'); const { Runner, components } = require('../../../../binary'); const installArgoCmd = new Command({ root: false, parent: installRoot, - command: 'gitops', + command: 'gitops ', description: 'Install gitops agent', webDocs: { category: 'Gitops', @@ -16,13 +16,18 @@ const installArgoCmd = new Command({ }, builder: yargs => yargs .env('CF_ARG_') + .positional('provider', { + describe: 'Gitops provider', + choices: ['argocd-agent'], + required: true, + }) .option('kube-config-path', { describe: 'Path to kubeconfig file (default is $HOME/.kube/config)', }), handler: async (argv) => { - const { 'kube-config-path': kubeConfigPath } = argv; + const { 'kube-config-path': kubeConfigPath, provider } = argv; - const binLocation = await downloadArgo(); + const binLocation = await downloadProvider({ provider }); const componentRunner = new Runner(binLocation); const commands = [ @@ -34,7 +39,7 @@ const installArgoCmd = new Command({ commands.push(kubeConfigPath); } - await componentRunner.run(components.gitops, commands); + await componentRunner.run(components.gitops[provider], commands); }, }); diff --git a/lib/interface/cli/commands/hybrid/helper.js b/lib/interface/cli/commands/hybrid/helper.js index 3868a078a..4e917d423 100644 --- a/lib/interface/cli/commands/hybrid/helper.js +++ b/lib/interface/cli/commands/hybrid/helper.js @@ -356,7 +356,7 @@ async function downloadVeonona(location = CODEFRESH_PATH) { return location; } -async function downloadArgo(location = CODEFRESH_PATH) { +async function downloadProvider({ provider, location = CODEFRESH_PATH }) { const downloader = new Downloader({ progress: new cliProgress.SingleBar( { @@ -367,9 +367,10 @@ async function downloadArgo(location = CODEFRESH_PATH) { ), location, }); - const [error] = await to(downloader.download(components.gitops)); + const [error] = await to(downloader.download(components.gitops[provider])); if (error) { - const newLocation = path.join(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, components.gitops.local.dir, components.gitops.local.binary); + const localSettings = components.gitops[provider].local; + const newLocation = path.join(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER, localSettings.dir, localSettings.binary); if (await pathExists(newLocation)) { console.log('Failed to download installer, using binary from components folder'); return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER); @@ -930,7 +931,7 @@ module.exports = { downloadRelatedComponents: downloadHybridComponents, downloadSteveDore, downloadVeonona, - downloadArgo, + downloadProvider, runUpgrade, detectProxy, serealizeToKeyValuePairs, diff --git a/package.json b/package.json index 2c8896759..e419fbbde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.73.8", + "version": "0.73.9", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,