Skip to content

Commit

Permalink
CR-620 Add postiional provider for update and uninstall gitops (#578)
Browse files Browse the repository at this point in the history
Co-authored-by: 123 <git config --global user.name [email protected]>
  • Loading branch information
olegz-codefresh and 123 authored Oct 25, 2020
1 parent f2ad955 commit ebe61dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
15 changes: 10 additions & 5 deletions lib/interface/cli/commands/gitops/uninstall.cmd.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable max-len */
const Command = require('../../Command');
const unInstallRoot = require('../root/uninstall.cmd');
const { downloadArgo } = require('../hybrid/helper');
const { downloadProvider } = require('../hybrid/helper');
const { Runner, components } = require('../../../../binary');


const unInstallAgentCmd = new Command({
root: false,
parent: unInstallRoot,
command: 'gitops',
command: 'gitops <provider>',
description: 'Uninstall gitops agent',
webDocs: {
category: 'Gitops',
Expand All @@ -17,13 +17,18 @@ const unInstallAgentCmd = 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 = [
'uninstall',
Expand All @@ -34,7 +39,7 @@ const unInstallAgentCmd = new Command({
commands.push(kubeConfigPath);
}

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

Expand Down
16 changes: 10 additions & 6 deletions lib/interface/cli/commands/gitops/upgrade.cmd.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Command = require('../../Command');

const upgradeRoot = require('../root/upgrade.cmd');
const { downloadArgo } = require('../hybrid/helper');
const { downloadProvider } = require('../hybrid/helper');
const { Runner, components } = require('../../../../binary');

const command = new Command({
root: false,
parent: upgradeRoot,
command: 'gitops',
command: 'gitops <provider>',
description: 'Upgrade gitops agent',
webDocs: {
category: 'Gitops',
Expand All @@ -16,6 +16,11 @@ const command = new Command({
},
builder: (yargs) => {
yargs
.positional('provider', {
describe: 'Gitops provider',
choices: ['argocd-agent'],
required: true,
})
.option('kube-config-path', {
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
})
Expand All @@ -25,9 +30,8 @@ const command = new Command({
);
},
handler: async (argv) => {
const { 'kube-config-path': kubeConfigPath } = argv;

const binLocation = await downloadArgo();
const { 'kube-config-path': kubeConfigPath, provider } = argv;
const binLocation = await downloadProvider({ provider });
const componentRunner = new Runner(binLocation);

const commands = [
Expand All @@ -39,7 +43,7 @@ const command = new Command({
commands.push(kubeConfigPath);
}

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

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.11",
"version": "0.73.12",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit ebe61dd

Please sign in to comment.