Skip to content

Commit 5e1dcb1

Browse files
CR-1885 (#613)
* CR-1885 * CR-1885
1 parent f6e5200 commit 5e1dcb1

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed
Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
1+
const fs = require('fs');
2+
const _ = require('lodash');
3+
const YAML = require('yaml');
14
const gitopsInstaller = require('../common/install');
25
const argocdInstaller = require('../argocd/install');
36

7+
const valuesMapping = {
8+
'kube-config-path': 'ConfigPath',
9+
'kube-context-name': 'Context',
10+
'kube-namespace': 'Namespace',
11+
'install-manifest': 'Manifest',
12+
13+
'codefresh-host': 'CodefreshHost',
14+
'codefresh-token': 'Token',
15+
'codefresh-clusters': 'ClustersList',
16+
17+
'argo-password': 'Password',
18+
19+
'git-integration': 'Git',
20+
'git-repo-url': 'Repo',
21+
};
22+
23+
function mergeValuesFromValuesFile(argv, valuesFile) {
24+
const valuesFileStr = fs.readFileSync(valuesFile, 'utf8');
25+
const valuesObj = YAML.parse(valuesFileStr);
26+
27+
Object.keys(valuesMapping)
28+
.forEach((argvKey) => {
29+
const valuesKey = valuesMapping[argvKey];
30+
if (!_.has(argv, argvKey) && _.has(valuesObj, valuesKey)) {
31+
Object.assign(argv, {
32+
[argvKey]: _.get(valuesObj, valuesKey),
33+
[_.camelCase(argvKey)]: _.get(valuesObj, valuesKey),
34+
});
35+
}
36+
});
37+
}
38+
439
class CodefreshInstall {
540
// eslint-disable-next-line class-methods-use-this
641
async install(argv) {
7-
await gitopsInstaller.install(argv);
42+
const _argv = _.cloneDeep(argv);
43+
if (argv.values) {
44+
mergeValuesFromValuesFile(_argv, _argv.values/* , handleError */);
45+
}
46+
await gitopsInstaller.install(_argv);
847
return argocdInstaller.install({
9-
...argv,
48+
..._argv,
1049
provider: 'argocd-agent',
1150
});
1251
}
1352
}
53+
1454
module.exports = new CodefreshInstall();

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const installArgoCmd = new Command({
2828
.option('git-integration', {
2929
describe: 'Name of git integration in Codefresh',
3030
})
31+
.option('git-repo-url', {
32+
describe: 'Url to manifest repo',
33+
})
3134
.option('codefresh-integration', {
3235
describe: 'Name of gitops integration in Codefresh',
3336
})
@@ -73,14 +76,21 @@ const installArgoCmd = new Command({
7376
.option('https-proxy', {
7477
describe: 'https proxy to be used in the runner',
7578
})
76-
// argocd options
7779
.option('install-manifest', {
7880
describe: 'Url of argocd install manifest',
7981
default: 'https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml',
8082
})
8183
.option('set-argo-password', {
8284
describe: 'Set password for admin user of new argocd installation',
85+
})
86+
.option('codefresh-host', {
87+
describe: 'Codefresh api host',
88+
default: 'https://g.codefresh.io/',
89+
})
90+
.option('values', {
91+
describe: 'Specify values in a YAML file',
8392
}),
93+
8494
handler: async (argv) => {
8595
const { provider } = argv;
8696

0 commit comments

Comments
 (0)