codefresh 1.2.9 → 1.2.11
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.
- package/lib/binary/components.js +0 -38
- package/lib/interface/cli/commands/components/download.cmd.js +1 -1
- package/lib/interface/cli/commands/hybrid/helper.js +1 -877
- package/lib/interface/cli/completion/tree.json +1 -1
- package/package.json +2 -11
- package/lib/interface/cli/commands/agent/helper.js +0 -28
- package/lib/interface/cli/commands/agent/install.cmd.js +0 -283
- package/lib/interface/cli/commands/agent/uninstall.cmd.js +0 -92
- package/lib/interface/cli/commands/app-proxy/helper.js +0 -63
- package/lib/interface/cli/commands/app-proxy/install.cmd.js +0 -204
- package/lib/interface/cli/commands/app-proxy/uninstall.cmd.js +0 -175
- package/lib/interface/cli/commands/app-proxy/upgrade.cmd.js +0 -110
- package/lib/interface/cli/commands/gitops/argocd/install.js +0 -9
- package/lib/interface/cli/commands/gitops/argocd/uninstall.js +0 -11
- package/lib/interface/cli/commands/gitops/argocd/upgrade.js +0 -9
- package/lib/interface/cli/commands/gitops/codefresh/install.js +0 -50
- package/lib/interface/cli/commands/gitops/codefresh/uninstall.js +0 -14
- package/lib/interface/cli/commands/gitops/codefresh/upgrade.js +0 -9
- package/lib/interface/cli/commands/gitops/common/install.js +0 -62
- package/lib/interface/cli/commands/gitops/common/uninstall.js +0 -39
- package/lib/interface/cli/commands/gitops/common/upgrade.js +0 -45
- package/lib/interface/cli/commands/gitops/install.cmd.js +0 -116
- package/lib/interface/cli/commands/gitops/install.spec.js +0 -77
- package/lib/interface/cli/commands/gitops/uninstall.cmd.js +0 -56
- package/lib/interface/cli/commands/gitops/upgrade.cmd.js +0 -56
- package/lib/interface/cli/commands/hybrid/delete.cmd.js +0 -341
- package/lib/interface/cli/commands/hybrid/init.cmd.js +0 -957
- package/lib/interface/cli/commands/hybrid/key-helper.js +0 -82
- package/lib/interface/cli/commands/hybrid/migration.js +0 -192
- package/lib/interface/cli/commands/hybrid/upgrade.cmd.js +0 -195
- package/lib/interface/cli/commands/monitor/install.cmd.js +0 -160
- package/lib/interface/cli/commands/monitor/uninstall.cmd.js +0 -78
- package/lib/interface/cli/commands/root/install.cmd.js +0 -17
- package/lib/interface/cli/commands/root/uninstall.cmd.js +0 -17
- package/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js +0 -180
- package/lib/interface/cli/commands/runtimeEnvironments/create.cmd.js +0 -23
- package/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +0 -340
- package/lib/interface/cli/commands/runtimeEnvironments/uninstall.cmd.js +0 -149
- package/lib/interface/cli/helpers/kubernetes.js +0 -61
- package/lib/interface/cli/helpers/progressEvents.js +0 -25
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
const Command = require('../../Command');
|
|
3
|
-
const unInstallRoot = require('../root/uninstall.cmd');
|
|
4
|
-
const { sdk } = require('../../../../logic');
|
|
5
|
-
const { getKubeContext } = require('../../helpers/kubernetes');
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
const ProgressEvents = require('../../helpers/progressEvents');
|
|
8
|
-
const cliProgress = require('cli-progress');
|
|
9
|
-
const { DefaultLogFormatter } = require('./../hybrid/helper');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const detachRuntimeFromAgent = async (agent, runtimeName) => {
|
|
13
|
-
const { runtimes } = agent;
|
|
14
|
-
const runtimeIdx = runtimes.findIndex(re => re === runtimeName);
|
|
15
|
-
runtimes.splice(runtimeIdx, 1);
|
|
16
|
-
await sdk.agents.update({ agentId: agent.id, runtimes });
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const unInstallRuntimeCmd = new Command({
|
|
20
|
-
root: false,
|
|
21
|
-
parent: unInstallRoot,
|
|
22
|
-
command: 'runtime',
|
|
23
|
-
description: 'Uninstall a runtime on kubernetes cluster',
|
|
24
|
-
webDocs: {
|
|
25
|
-
category: 'Runtime-Environments',
|
|
26
|
-
title: 'Uninstall Runtime-Environment',
|
|
27
|
-
weight: 100,
|
|
28
|
-
},
|
|
29
|
-
builder: yargs => yargs
|
|
30
|
-
.env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv
|
|
31
|
-
.option('agent-name', {
|
|
32
|
-
describe: 'Agent\'s name to be uninstalled',
|
|
33
|
-
})
|
|
34
|
-
.option('name', {
|
|
35
|
-
describe: 'Runtime\'s name to be uninstalled',
|
|
36
|
-
})
|
|
37
|
-
.option('agent-id', {
|
|
38
|
-
describe: 'Agent\'s ID',
|
|
39
|
-
})
|
|
40
|
-
.option('runtime-kube-context-name', {
|
|
41
|
-
describe: 'Name of the kubernetes context on which venona should be uninstalled [$CF_ARG_KUBE_CONTEXT_NAME]',
|
|
42
|
-
})
|
|
43
|
-
.option('runtime-kube-namespace', {
|
|
44
|
-
describe: 'Name of the namespace on which venona should be uninstalled [$CF_ARG_KUBE_NAMESPACE]',
|
|
45
|
-
})
|
|
46
|
-
.option('runtime-kube-config-path', {
|
|
47
|
-
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
|
|
48
|
-
})
|
|
49
|
-
.option('agent-kube-context-name', {
|
|
50
|
-
describe: 'Agent kubernetes context',
|
|
51
|
-
})
|
|
52
|
-
.option('agent-kube-namespace', {
|
|
53
|
-
describe: 'Agent\'s namespace',
|
|
54
|
-
})
|
|
55
|
-
.option('agent-kube-config-path', {
|
|
56
|
-
describe: 'Path to kubeconfig file for the agent (default is $HOME/.kube/config)',
|
|
57
|
-
})
|
|
58
|
-
.option('verbose', {
|
|
59
|
-
describe: 'Print logs',
|
|
60
|
-
}),
|
|
61
|
-
handler: async (argv) => {
|
|
62
|
-
const {
|
|
63
|
-
'agent-name': agentName,
|
|
64
|
-
'agent-id': agentId,
|
|
65
|
-
name: runtimeName,
|
|
66
|
-
'runtime-kube-namespace': kubeNamespace,
|
|
67
|
-
'runtime-kube-config-path': kubeConfigPath,
|
|
68
|
-
'restart-agent': restartAgent,
|
|
69
|
-
'agent-kube-config-path': agentKubeConfigPath,
|
|
70
|
-
verbose,
|
|
71
|
-
terminateProcess,
|
|
72
|
-
|
|
73
|
-
} = argv;
|
|
74
|
-
|
|
75
|
-
let {
|
|
76
|
-
'runtime-kube-context-name': kubeContextName,
|
|
77
|
-
'agent-kube-context-name': agentKubeContextName,
|
|
78
|
-
'agent-kube-namespace': agentKubeNamespace,
|
|
79
|
-
} = argv;
|
|
80
|
-
|
|
81
|
-
if (!kubeContextName) {
|
|
82
|
-
kubeContextName = getKubeContext(kubeConfigPath);
|
|
83
|
-
}
|
|
84
|
-
if (!agentKubeContextName) {
|
|
85
|
-
agentKubeContextName = getKubeContext(agentKubeConfigPath);
|
|
86
|
-
}
|
|
87
|
-
if (!agentKubeNamespace) {
|
|
88
|
-
agentKubeNamespace = kubeNamespace;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let agent;
|
|
92
|
-
if (_.isNull(runtimeName) || _.isUndefined(runtimeName) || runtimeName === '') {
|
|
93
|
-
throw new Error('runtime name is mandatory');
|
|
94
|
-
}
|
|
95
|
-
if (agentName) {
|
|
96
|
-
agent = await sdk.agents.getByName({ name: agentName });
|
|
97
|
-
} else if (agentId) {
|
|
98
|
-
agent = await sdk.agents.get({ agentId });
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error('agent name or agent id is needed');
|
|
101
|
-
}
|
|
102
|
-
if (agent === '' || !agent) {
|
|
103
|
-
throw new Error('agent was not found');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const runtimes = _.get(agent, 'runtimes', []);
|
|
107
|
-
if (!_.find(runtimes, value => value === runtimeName)) {
|
|
108
|
-
throw new Error(`Runtime ${runtimeName} is not attached to agent ${agent.name}`);
|
|
109
|
-
}
|
|
110
|
-
const runtimeIns = await sdk.runtimeEnvs.get({ name: runtimeName });
|
|
111
|
-
const storageClassName = _.get(runtimeIns, 'RuntimeScheduler.Pvcs.Dind.StorageClassName');
|
|
112
|
-
await detachRuntimeFromAgent(agent, runtimeName);
|
|
113
|
-
|
|
114
|
-
// Get agent
|
|
115
|
-
|
|
116
|
-
const events = new ProgressEvents();
|
|
117
|
-
const format = 'downloading [{bar}] {percentage}% | {value}/{total}';
|
|
118
|
-
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
|
|
119
|
-
let totalSize;
|
|
120
|
-
events.onStart((size) => {
|
|
121
|
-
progressBar.start(size, 0);
|
|
122
|
-
totalSize = size;
|
|
123
|
-
});
|
|
124
|
-
events.onProgress((progress) => {
|
|
125
|
-
progressBar.update(progress);
|
|
126
|
-
if (progress >= totalSize) {
|
|
127
|
-
console.log('\n');
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await sdk.runtime.unInstall({
|
|
132
|
-
runtimeName,
|
|
133
|
-
kubeContextName,
|
|
134
|
-
kubeNamespace,
|
|
135
|
-
kubeConfigPath,
|
|
136
|
-
agentKubeContextName,
|
|
137
|
-
agentKubeNamespace,
|
|
138
|
-
agentKubeConfigPath,
|
|
139
|
-
restartAgent,
|
|
140
|
-
storageClassName,
|
|
141
|
-
verbose,
|
|
142
|
-
terminateProcess: (terminateProcess !== false),
|
|
143
|
-
events,
|
|
144
|
-
logFormatting: DefaultLogFormatter,
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
module.exports = unInstallRuntimeCmd;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const { KubeConfig, Client } = require('kubernetes-client');
|
|
4
|
-
const Request = require('kubernetes-client/backends/request');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
const { homedir } = require('os');
|
|
7
|
-
|
|
8
|
-
const isInCluster = () => fs.existsSync('/var/run/secrets/kubernetes.io/serviceaccount');
|
|
9
|
-
|
|
10
|
-
const _getKubeConfig = (kubeconfigPath) => {
|
|
11
|
-
const kc = new KubeConfig();
|
|
12
|
-
if (isInCluster()) {
|
|
13
|
-
kc.loadFromCluster();
|
|
14
|
-
return kc;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir(), '.kube', 'config');
|
|
18
|
-
if (!fs.existsSync(kubePath)) {
|
|
19
|
-
throw new Error(`kubeconfig not found at: ${kubePath}, make sure the $KUBECONFIG environment variable is set correctly`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
kc.loadFromFile(kubePath);
|
|
23
|
-
|
|
24
|
-
return kc;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const getKubeContext = (kubeconfigPath) => {
|
|
29
|
-
const kubeconfig = _getKubeConfig(kubeconfigPath);
|
|
30
|
-
return kubeconfig.currentContext;
|
|
31
|
-
};
|
|
32
|
-
const getAllKubeContexts = (kubeconfigPath) => {
|
|
33
|
-
const kubeconfig = _getKubeConfig(kubeconfigPath);
|
|
34
|
-
const { contexts } = kubeconfig;
|
|
35
|
-
if (contexts) {
|
|
36
|
-
return contexts.reduce((acc, curr) => {
|
|
37
|
-
acc.push(curr.name);
|
|
38
|
-
return acc;
|
|
39
|
-
}, []);
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
};
|
|
43
|
-
const getAllNamespaces = async (kubeconfigPath, kubeContextName) => {
|
|
44
|
-
const kubeconfig = _getKubeConfig(kubeconfigPath);
|
|
45
|
-
kubeconfig.setCurrentContext(kubeContextName);
|
|
46
|
-
const backend = new Request({ kubeconfig });
|
|
47
|
-
const client = new Client({ backend, version: 1.13 });
|
|
48
|
-
const resp = await client.api.v1.namespaces.get();
|
|
49
|
-
if (resp.statusCode !== 200) {
|
|
50
|
-
throw new Error(`could not get namespaces from cluster ${kubeContextName}, failed with status: ${resp.statusCode}`);
|
|
51
|
-
}
|
|
52
|
-
const nsObjs = _.get(resp, 'body.items');
|
|
53
|
-
return _.map(nsObjs, ns => _.get(ns, 'metadata.name'));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
getKubeContext,
|
|
58
|
-
getAllKubeContexts,
|
|
59
|
-
getAllNamespaces,
|
|
60
|
-
isInCluster,
|
|
61
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const EventEmitter = require('events');
|
|
2
|
-
|
|
3
|
-
class ProgressEvents {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.emitter = new EventEmitter();
|
|
6
|
-
}
|
|
7
|
-
onStart(handler) {
|
|
8
|
-
this.emitter.addListener('start', (args) => {
|
|
9
|
-
handler(args);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
onProgress(handler) {
|
|
13
|
-
this.emitter.addListener('progress', (args) => {
|
|
14
|
-
handler(args);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
reportStart(args) {
|
|
18
|
-
this.emitter.emit('start', args);
|
|
19
|
-
}
|
|
20
|
-
reportProgress(args) {
|
|
21
|
-
this.emitter.emit('progress', args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = ProgressEvents;
|