Skip to content

Commit 89af496

Browse files
CR-2946
1 parent 1a01afb commit 89af496

File tree

5 files changed

+74
-37
lines changed

5 files changed

+74
-37
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const gitopsUpgrader = require('../common/upgrade');
2+
3+
class ArgoCDUpgrade {
4+
// eslint-disable-next-line class-methods-use-this
5+
async upgrade(argv) {
6+
return gitopsUpgrader.upgrade(argv);
7+
}
8+
}
9+
module.exports = new ArgoCDUpgrade();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const gitopsUpgrader = require('../common/upgrade');
2+
3+
class CodefreshGitopsUpgrade {
4+
// eslint-disable-next-line class-methods-use-this
5+
async upgrade(argv) {
6+
return gitopsUpgrader.upgrade(argv);
7+
}
8+
}
9+
module.exports = new CodefreshGitopsUpgrade();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { downloadProvider } = require('../../hybrid/helper');
2+
const { Runner, components } = require('../../../../../binary');
3+
const _ = require('lodash');
4+
5+
class GitopsUpgrader {
6+
// eslint-disable-next-line class-methods-use-this
7+
async upgrade(argv) {
8+
const {
9+
provider,
10+
'kube-config-path': kubeConfigPath,
11+
'kube-namespace': kubeNamespace,
12+
'kube-context-name': kubeContextName,
13+
'in-cluster': inCluster,
14+
} = argv;
15+
16+
const binLocation = await downloadProvider({ provider });
17+
const componentRunner = new Runner(binLocation);
18+
19+
const commands = [
20+
'update',
21+
];
22+
23+
if (kubeConfigPath) {
24+
commands.push('--kubeconfig');
25+
commands.push(kubeConfigPath);
26+
}
27+
if (kubeNamespace) {
28+
commands.push('--kube-namespace');
29+
commands.push(kubeNamespace);
30+
}
31+
if (kubeContextName) {
32+
commands.push('--kube-context-name');
33+
commands.push(kubeContextName);
34+
}
35+
if (inCluster) {
36+
commands.push('--in-cluster');
37+
commands.push('true');
38+
}
39+
40+
await componentRunner.run(components.gitops[provider], commands);
41+
}
42+
}
43+
44+
module.exports = new GitopsUpgrader();

lib/interface/cli/commands/gitops/upgrade.cmd.js

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const Command = require('../../Command');
2-
32
const upgradeRoot = require('../root/upgrade.cmd');
4-
const { downloadProvider } = require('../hybrid/helper');
5-
const { Runner, components } = require('../../../../binary');
3+
const codefreshProvider = require('./codefresh/upgrade');
4+
const argocdAgentProvider = require('./argocd/upgrade');
5+
6+
const PROVIDERS = {
7+
codefresh: codefreshProvider,
8+
'argocd-agent': argocdAgentProvider,
9+
};
610

711
const command = new Command({
812
root: false,
@@ -18,7 +22,7 @@ const command = new Command({
1822
yargs
1923
.positional('provider', {
2024
describe: 'Gitops provider',
21-
choices: ['argocd-agent'],
25+
choices: Object.keys(PROVIDERS),
2226
required: true,
2327
})
2428
.option('kube-config-path', {
@@ -41,39 +45,10 @@ const command = new Command({
4145
);
4246
},
4347
handler: async (argv) => {
44-
const {
45-
provider,
46-
'kube-config-path': kubeConfigPath,
47-
'kube-namespace': kubeNamespace,
48-
'kube-context-name': kubeContextName,
49-
'in-cluster': inCluster,
50-
} = argv;
51-
52-
const binLocation = await downloadProvider({ provider });
53-
const componentRunner = new Runner(binLocation);
54-
55-
const commands = [
56-
'update',
57-
];
58-
59-
if (kubeConfigPath) {
60-
commands.push('--kubeconfig');
61-
commands.push(kubeConfigPath);
62-
}
63-
if (kubeNamespace) {
64-
commands.push('--kube-namespace');
65-
commands.push(kubeNamespace);
66-
}
67-
if (kubeContextName) {
68-
commands.push('--kube-context-name');
69-
commands.push(kubeContextName);
70-
}
71-
if (inCluster) {
72-
commands.push('--in-cluster');
73-
commands.push('true');
74-
}
48+
const { provider } = argv;
7549

76-
await componentRunner.run(components.gitops[provider], commands);
50+
const providerInstaller = PROVIDERS[provider];
51+
return providerInstaller.upgrade(argv);
7752
},
7853
});
7954

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.75.1",
3+
"version": "0.75.2",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)