codefresh 1.3.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/binary/components.js +0 -57
  2. package/lib/interface/cli/commands/agent/install.cmd.js +6 -126
  3. package/lib/interface/cli/commands/components/download.cmd.js +1 -1
  4. package/lib/interface/cli/commands/hybrid/execute-test-pipeline.cmd.js +37 -11
  5. package/lib/interface/cli/commands/hybrid/helper.js +8 -896
  6. package/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js +3 -103
  7. package/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +8 -134
  8. package/lib/interface/cli/completion/tree.json +1 -1
  9. package/lib/interface/cli/helpers/kubernetes.js +8 -42
  10. package/package.json +3 -22
  11. package/lib/interface/cli/commands/agent/uninstall.cmd.js +0 -92
  12. package/lib/interface/cli/commands/app-proxy/helper.js +0 -63
  13. package/lib/interface/cli/commands/app-proxy/install.cmd.js +0 -204
  14. package/lib/interface/cli/commands/app-proxy/uninstall.cmd.js +0 -175
  15. package/lib/interface/cli/commands/app-proxy/upgrade.cmd.js +0 -110
  16. package/lib/interface/cli/commands/gitops/argocd/install.js +0 -9
  17. package/lib/interface/cli/commands/gitops/argocd/uninstall.js +0 -11
  18. package/lib/interface/cli/commands/gitops/argocd/upgrade.js +0 -9
  19. package/lib/interface/cli/commands/gitops/codefresh/install.js +0 -50
  20. package/lib/interface/cli/commands/gitops/codefresh/uninstall.js +0 -14
  21. package/lib/interface/cli/commands/gitops/codefresh/upgrade.js +0 -9
  22. package/lib/interface/cli/commands/gitops/common/install.js +0 -62
  23. package/lib/interface/cli/commands/gitops/common/uninstall.js +0 -39
  24. package/lib/interface/cli/commands/gitops/common/upgrade.js +0 -45
  25. package/lib/interface/cli/commands/gitops/install.cmd.js +0 -116
  26. package/lib/interface/cli/commands/gitops/install.spec.js +0 -77
  27. package/lib/interface/cli/commands/gitops/uninstall.cmd.js +0 -56
  28. package/lib/interface/cli/commands/gitops/upgrade.cmd.js +0 -56
  29. package/lib/interface/cli/commands/hybrid/InstallationPlan.js +0 -216
  30. package/lib/interface/cli/commands/hybrid/delete.cmd.js +0 -341
  31. package/lib/interface/cli/commands/hybrid/init.cmd.js +0 -957
  32. package/lib/interface/cli/commands/hybrid/installation-process.js +0 -51
  33. package/lib/interface/cli/commands/hybrid/key-helper.js +0 -82
  34. package/lib/interface/cli/commands/hybrid/migration.js +0 -192
  35. package/lib/interface/cli/commands/hybrid/pipeline-helper.js +0 -71
  36. package/lib/interface/cli/commands/hybrid/upgrade.cmd.js +0 -195
  37. package/lib/interface/cli/commands/monitor/install.cmd.js +0 -160
  38. package/lib/interface/cli/commands/monitor/uninstall.cmd.js +0 -78
  39. package/lib/interface/cli/commands/root/uninstall.cmd.js +0 -17
  40. package/lib/interface/cli/commands/runtimeEnvironments/create.cmd.js +0 -23
  41. package/lib/interface/cli/commands/runtimeEnvironments/uninstall.cmd.js +0 -149
  42. package/lib/interface/cli/helpers/progressEvents.js +0 -25
@@ -1,50 +0,0 @@
1
- const fs = require('fs');
2
- const _ = require('lodash');
3
- const YAML = require('yaml');
4
- const gitopsInstaller = require('../common/install');
5
-
6
- const valuesMapping = {
7
- 'kube-config-path': 'ConfigPath',
8
- 'kube-context-name': 'Context',
9
- 'kube-namespace': 'Namespace',
10
- 'install-manifest': 'Manifest',
11
- 'in-cluster': 'InCluster',
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
-
39
- class CodefreshInstall {
40
- // eslint-disable-next-line class-methods-use-this
41
- async install(argv) {
42
- const _argv = _.cloneDeep(argv);
43
- if (argv.values) {
44
- mergeValuesFromValuesFile(_argv, _argv.values/* , handleError */);
45
- }
46
- await gitopsInstaller.install(_argv);
47
- }
48
- }
49
-
50
- module.exports = new CodefreshInstall();
@@ -1,14 +0,0 @@
1
- const _ = require('lodash');
2
- const gitopsUninstaller = require('../common/uninstall');
3
-
4
- class CodefreshInstall {
5
- // eslint-disable-next-line class-methods-use-this
6
- async uninstall(argv) {
7
- const uninstallOptions = _.pick(argv, [
8
- 'kube-config-path', 'kube-context-name', 'kube-namespace', 'install-manifest', 'in-cluster',
9
- ]);
10
- await gitopsUninstaller.uninstall(argv.provider, uninstallOptions);
11
- }
12
- }
13
-
14
- module.exports = new CodefreshInstall();
@@ -1,9 +0,0 @@
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();
@@ -1,62 +0,0 @@
1
- const { detectProxy } = require('../../../helpers/general');
2
- const { downloadProvider } = require('../../hybrid/helper');
3
- const { Runner, components } = require('../../../../../binary');
4
- const _ = require('lodash');
5
-
6
- class GitopsInstaller {
7
- // eslint-disable-next-line class-methods-use-this
8
- async install(argv) {
9
- let { httpProxy, httpsProxy } = argv;
10
- const { kubeConfigPath, provider, argoHost, argoUsername, argoPassword, bypassDownload } = argv;
11
-
12
- const binLocation = await downloadProvider({ provider }, bypassDownload);
13
- const componentRunner = new Runner(binLocation);
14
-
15
- const commands = [
16
- 'install',
17
- ];
18
-
19
- if (kubeConfigPath) {
20
- commands.push('--kubeconfig');
21
- commands.push(kubeConfigPath);
22
- }
23
-
24
- const installOptions = _.pick(argv, ['git-integration', 'codefresh-integration', 'argo-token', 'output',
25
- 'update', 'kube-context-name', 'kube-namespace', 'sync-mode', 'sync-apps', 'codefresh-host',
26
- 'codefresh-token', 'codefresh-agent-suffix', 'in-cluster']);
27
- installOptions['argo-host'] = argoHost;
28
- installOptions['argo-username'] = argoUsername;
29
- installOptions['argo-password'] = argoPassword;
30
-
31
- _.forEach(_.pickBy(installOptions, _.identity), (value, key) => {
32
- if (_.isArray(value)) {
33
- value.forEach((item) => {
34
- commands.push(`--${key}`);
35
- commands.push(item);
36
- });
37
- } else {
38
- commands.push(`--${key}`);
39
- if (value !== true) commands.push(value);
40
- }
41
- });
42
-
43
- const detectedProxyVars = detectProxy();
44
- httpProxy = httpProxy || detectedProxyVars.httpProxy;
45
- httpsProxy = httpsProxy || detectedProxyVars.httpsProxy;
46
-
47
- if (httpProxy) {
48
- commands.push('--http-proxy');
49
- commands.push(httpProxy);
50
- }
51
-
52
- if (httpsProxy) {
53
- commands.push('--https-proxy');
54
- commands.push(httpsProxy);
55
- }
56
-
57
-
58
- await componentRunner.run(components.gitops[provider], commands);
59
- }
60
- }
61
-
62
- module.exports = new GitopsInstaller();
@@ -1,39 +0,0 @@
1
- const { downloadProvider } = require('../../hybrid/helper');
2
- const { Runner, components } = require('../../../../../binary');
3
- const _ = require('lodash');
4
-
5
- class GitopsUninstaller {
6
- // eslint-disable-next-line class-methods-use-this
7
- async uninstall(provider, argv) {
8
- const { 'kube-config-path': kubeConfigPath, 'bypass-download': bypassDownload } = argv;
9
- const binLocation = await downloadProvider({ provider }, bypassDownload);
10
- const componentRunner = new Runner(binLocation);
11
-
12
- const commands = [
13
- 'uninstall',
14
- ];
15
-
16
- if (kubeConfigPath) {
17
- commands.push('--kubeconfig');
18
- commands.push(kubeConfigPath);
19
- }
20
-
21
- const installOptions = _.omit(argv, 'kube-config-path');
22
-
23
- _.forEach(_.pickBy(installOptions, _.identity), (value, key) => {
24
- if (_.isArray(value)) {
25
- value.forEach((item) => {
26
- commands.push(`--${key}`);
27
- commands.push(item);
28
- });
29
- } else {
30
- commands.push(`--${key}`);
31
- if (value !== true) commands.push(value);
32
- }
33
- });
34
-
35
- await componentRunner.run(components.gitops[provider], commands);
36
- }
37
- }
38
-
39
- module.exports = new GitopsUninstaller();
@@ -1,45 +0,0 @@
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
- 'bypass-download': bypassDownload,
15
- } = argv;
16
-
17
- const binLocation = await downloadProvider({ provider }, bypassDownload);
18
- const componentRunner = new Runner(binLocation);
19
-
20
- const commands = [
21
- 'update',
22
- ];
23
-
24
- if (kubeConfigPath) {
25
- commands.push('--kubeconfig');
26
- commands.push(kubeConfigPath);
27
- }
28
- if (kubeNamespace) {
29
- commands.push('--kube-namespace');
30
- commands.push(kubeNamespace);
31
- }
32
- if (kubeContextName) {
33
- commands.push('--kube-context-name');
34
- commands.push(kubeContextName);
35
- }
36
- if (inCluster) {
37
- commands.push('--in-cluster');
38
- commands.push('true');
39
- }
40
-
41
- await componentRunner.run(components.gitops[provider], commands);
42
- }
43
- }
44
-
45
- module.exports = new GitopsUpgrader();
@@ -1,116 +0,0 @@
1
- /* eslint-disable max-len */
2
- const _ = require('lodash');
3
- const Command = require('../../Command');
4
- const installRoot = require('../root/install.cmd');
5
-
6
- const PROVIDERS = {
7
- codefresh: require('./codefresh/install'),
8
- 'argocd-agent': require('./argocd/install'),
9
- };
10
-
11
- const installArgoCmd = new Command({
12
- root: false,
13
- parent: installRoot,
14
- command: 'gitops <provider>',
15
- description: 'Install gitops',
16
- webDocs: {
17
- category: 'Gitops',
18
- title: 'Install',
19
- weight: 100,
20
- },
21
- builder: yargs => yargs
22
- .env('CF_ARG_')
23
- .positional('provider', {
24
- describe: 'Gitops provider',
25
- choices: ['codefresh', 'argocd-agent'],
26
- required: true,
27
- })
28
- .option('git-integration', {
29
- describe: 'Name of git integration in Codefresh',
30
- })
31
- .option('git-repo-url', {
32
- describe: 'Url to manifest repo',
33
- })
34
- .option('codefresh-integration', {
35
- describe: 'Name of gitops integration in Codefresh ( Please create a dedicated context for the agent to avoid hitting the Github rate limits )',
36
- })
37
- .option('argo-host', {
38
- describe: 'Host of argocd installation',
39
- })
40
- .option('argo-token', {
41
- describe: 'Token of argocd installation. Preferred auth method',
42
- })
43
- .option('argo-username', {
44
- describe: 'Username of existing argocd installation. Should be used with argo-password',
45
- })
46
- .option('argo-password', {
47
- describe: 'Password of existing argocd installation. Should be used with argo-username',
48
- })
49
- .option('update', {
50
- describe: 'Update gitops integration if exists',
51
- })
52
- .option('kube-config-path', {
53
- describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
54
- })
55
- .option('kube-context-name', {
56
- describe: 'Name of Kubernetes context',
57
- })
58
- .option('kube-namespace', {
59
- describe: 'Namespace in Kubernetes cluster',
60
- })
61
- .option('in-cluster', {
62
- type: 'boolean',
63
- default: false,
64
- describe: 'Use this option if gitops provider is been updated from inside a cluster',
65
- })
66
- .option('output', {
67
- describe: 'Path to k8s manifest output file, example: -o /home/user/out.yaml',
68
- alias: 'o',
69
- })
70
- .option('sync-mode', {
71
- choices: ['NONE', 'SELECT', 'CONTINUE_SYNC', 'ONE_TIME_SYNC'],
72
- describe: 'Synchronization mode\nNONE - don\'t synchronize\nSELECT - select applications for synchronization\nCONTINUE_SYNC - continuous synchronization\nONE_TIME_SYNC - synchronize one time',
73
- })
74
- .option('sync-apps', {
75
- array: true,
76
- describe: 'Applications to be synchronized',
77
- })
78
- .option('http-proxy', {
79
- describe: 'http proxy to be used in the runner',
80
- })
81
- .option('https-proxy', {
82
- describe: 'https proxy to be used in the runner',
83
- })
84
- .option('install-manifest', {
85
- describe: 'Url of argocd install manifest',
86
- default: 'https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml',
87
- })
88
- .option('set-argo-password', {
89
- describe: 'Set password for admin user of new argocd installation',
90
- })
91
- .option('codefresh-host', {
92
- describe: 'Codefresh api host',
93
- default: 'https://g.codefresh.io/',
94
- })
95
- .option('codefresh-agent-suffix', {
96
- describe: 'Suffix for agent application\'s resources. Can be used for installing multiple agents in one namespace',
97
- default: '',
98
- })
99
- .option('values', {
100
- describe: 'Specify values in a YAML file',
101
- })
102
- .option('bypass-download', {
103
- describe: 'Will bypass the attempt to download the installer. Instead, will immediately attempt to use the binary from the components folder',
104
- default: false,
105
- type: 'boolean',
106
- }),
107
-
108
- handler: async (argv) => {
109
- const { provider } = argv;
110
-
111
- const providerInstaller = PROVIDERS[provider];
112
- return providerInstaller.install(argv);
113
- },
114
- });
115
-
116
- module.exports = installArgoCmd;
@@ -1,77 +0,0 @@
1
- const installCmd = require('./install.cmd').toCommand();
2
- const { Runner } = require('../../../../binary');
3
- const yargs = require('yargs');
4
-
5
- jest.mock('../hybrid/helper', () => ({
6
- downloadProvider: async () => {},
7
- }));
8
-
9
- jest.mock('../../../../binary');
10
-
11
- describe('install gitops', () => {
12
- beforeEach(async () => {
13
- Runner.mockClear();
14
- });
15
-
16
- it('install gitops argocd-agent w/o arguments', async () => {
17
- const argv = { provider: 'argocd-agent' };
18
- await installCmd.handler(argv);
19
- const { calls } = Runner.mock.instances[0].run.mock;
20
- expect(calls).toHaveLength(1);
21
- const [component, commands] = calls[0];
22
- expect(component.name).toEqual('gitops');
23
- expect(commands).toEqual(['install']);
24
- });
25
-
26
- it('install gitops argocd-agent with arguments', async () => {
27
- const argv = {
28
- provider: 'argocd-agent',
29
- 'git-integration': 'gitIntegration',
30
- 'codefresh-integration': 'codefreshIntegration',
31
- 'kube-context-name': 'kubeContextName',
32
- 'kube-namespace': 'kubeNamespace',
33
- 'sync-mode': 'SELECT',
34
- 'sync-apps': 'syncApps',
35
- };
36
- await installCmd.handler(argv);
37
- const { calls } = Runner.mock.instances[0].run.mock;
38
- expect(calls).toHaveLength(1);
39
- const [component, commands] = calls[0];
40
- expect(component.name).toEqual('gitops');
41
- expect(commands).toEqual([
42
- 'install',
43
- '--git-integration',
44
- 'gitIntegration',
45
- '--codefresh-integration',
46
- 'codefreshIntegration',
47
- '--kube-context-name',
48
- 'kubeContextName',
49
- '--kube-namespace',
50
- 'kubeNamespace',
51
- '--sync-mode',
52
- 'SELECT',
53
- '--sync-apps',
54
- 'syncApps',
55
- ]);
56
- });
57
-
58
- it('install gitops codefresh with required arguments', async () => {
59
- const argv = {
60
- provider: 'codefresh',
61
- 'set-argo-password': 'pass',
62
- setArgoPassword: 'pass',
63
- 'kube-namespace': 'ns',
64
- kubeNamespace: 'ns',
65
- };
66
- await installCmd.handler(argv);
67
- const { calls } = Runner.mock.instances[0].run.mock;
68
- expect(calls).toHaveLength(1);
69
- const [component, commands] = calls[0];
70
- expect(component.name).toEqual('cf-gitops-controller');
71
- expect(commands).toEqual([
72
- 'install',
73
- '--kube-namespace',
74
- 'ns',
75
- ]);
76
- });
77
- });
@@ -1,56 +0,0 @@
1
- /* eslint-disable max-len */
2
- const Command = require('../../Command');
3
- const unInstallRoot = require('../root/uninstall.cmd');
4
- const { downloadProvider } = require('../hybrid/helper');
5
- const { Runner, components } = require('../../../../binary');
6
- const codefreshProvider = require('./codefresh/uninstall');
7
- const argocdAgentProvider = require('./argocd/uninstall');
8
-
9
- const PROVIDERS = {
10
- codefresh: codefreshProvider,
11
- 'argocd-agent': argocdAgentProvider,
12
- };
13
-
14
- const unInstallAgentCmd = new Command({
15
- root: false,
16
- parent: unInstallRoot,
17
- command: 'gitops <provider>',
18
- description: 'Uninstall gitops agent',
19
- webDocs: {
20
- category: 'Gitops',
21
- title: 'Uninstall',
22
- weight: 100,
23
- },
24
- builder: yargs => yargs
25
- .env('CF_ARG_')
26
- .positional('provider', {
27
- describe: 'Gitops provider',
28
- choices: Object.keys(PROVIDERS),
29
- required: true,
30
- })
31
- .option('kube-config-path', {
32
- describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
33
- })
34
- .option('kube-context-name', {
35
- describe: 'Name of Kubernetes context',
36
- })
37
- .option('kube-namespace', {
38
- describe: 'Namespace in Kubernetes cluster',
39
- })
40
- .option('install-manifest', {
41
- describe: 'Url of argocd install manifest',
42
- default: 'https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml',
43
- })
44
- .option('in-cluster', {
45
- type: 'boolean',
46
- default: false,
47
- describe: 'Use this option if gitops provider is been updated from inside a cluster',
48
- }),
49
- handler: async (argv) => {
50
- const { provider } = argv;
51
- const providerInstaller = PROVIDERS[provider];
52
- return providerInstaller.uninstall(argv);
53
- },
54
- });
55
-
56
- module.exports = unInstallAgentCmd;
@@ -1,56 +0,0 @@
1
- const Command = require('../../Command');
2
- const upgradeRoot = require('../root/upgrade.cmd');
3
- const codefreshProvider = require('./codefresh/upgrade');
4
- const argocdAgentProvider = require('./argocd/upgrade');
5
-
6
- const PROVIDERS = {
7
- codefresh: codefreshProvider,
8
- 'argocd-agent': argocdAgentProvider,
9
- };
10
-
11
- const command = new Command({
12
- root: false,
13
- parent: upgradeRoot,
14
- command: 'gitops <provider>',
15
- description: 'Upgrade gitops agent',
16
- webDocs: {
17
- category: 'Gitops',
18
- title: 'Upgrade',
19
- weight: 100,
20
- },
21
- builder: (yargs) => {
22
- yargs
23
- .positional('provider', {
24
- describe: 'Gitops provider',
25
- choices: Object.keys(PROVIDERS),
26
- required: true,
27
- })
28
- .option('kube-config-path', {
29
- describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
30
- })
31
- .option('kube-namespace', {
32
- describe: 'Name of the namespace on which Argo agent should be updated',
33
- })
34
- .option('kube-context-name', {
35
- describe: 'Name of the kubernetes context where Argo agent should be updated (default is current-context)',
36
- })
37
- .option('in-cluster', {
38
- type: 'boolean',
39
- default: false,
40
- describe: 'Use this option if gitops provider is been updated from inside a cluster',
41
- })
42
- .example(
43
- 'codefresh upgrade gitops argocd-agent',
44
- 'Update gitops agent',
45
- );
46
- },
47
- handler: async (argv) => {
48
- const { provider } = argv;
49
-
50
- const providerInstaller = PROVIDERS[provider];
51
- return providerInstaller.upgrade(argv);
52
- },
53
- });
54
-
55
- module.exports = command;
56
-