Skip to content

Commit

Permalink
add agent parameter (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-codefresh authored Oct 21, 2020
1 parent 383b5fc commit 7f42691
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
34 changes: 18 additions & 16 deletions lib/binary/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}
},
};
15 changes: 10 additions & 5 deletions lib/interface/cli/commands/gitops/install.cmd.js
Original file line number Diff line number Diff line change
@@ -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 <provider>',
description: 'Install gitops agent',
webDocs: {
category: 'Gitops',
Expand All @@ -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 = [
Expand All @@ -34,7 +39,7 @@ const installArgoCmd = new Command({
commands.push(kubeConfigPath);
}

await componentRunner.run(components.gitops, commands);
await componentRunner.run(components.gitops[provider], commands);
},
});

Expand Down
9 changes: 5 additions & 4 deletions lib/interface/cli/commands/hybrid/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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);
Expand Down Expand Up @@ -930,7 +931,7 @@ module.exports = {
downloadRelatedComponents: downloadHybridComponents,
downloadSteveDore,
downloadVeonona,
downloadArgo,
downloadProvider,
runUpgrade,
detectProxy,
serealizeToKeyValuePairs,
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.8",
"version": "0.73.9",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 7f42691

Please sign in to comment.