codefresh 1.2.11 → 1.2.12
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 +38 -0
- package/lib/interface/cli/commands/agent/helper.js +28 -0
- package/lib/interface/cli/commands/agent/install.cmd.js +283 -0
- package/lib/interface/cli/commands/agent/uninstall.cmd.js +92 -0
- package/lib/interface/cli/commands/app-proxy/helper.js +63 -0
- package/lib/interface/cli/commands/app-proxy/install.cmd.js +204 -0
- package/lib/interface/cli/commands/app-proxy/uninstall.cmd.js +175 -0
- package/lib/interface/cli/commands/app-proxy/upgrade.cmd.js +110 -0
- package/lib/interface/cli/commands/components/download.cmd.js +1 -1
- package/lib/interface/cli/commands/gitops/argocd/install.js +9 -0
- package/lib/interface/cli/commands/gitops/argocd/uninstall.js +11 -0
- package/lib/interface/cli/commands/gitops/argocd/upgrade.js +9 -0
- package/lib/interface/cli/commands/gitops/codefresh/install.js +50 -0
- package/lib/interface/cli/commands/gitops/codefresh/uninstall.js +14 -0
- package/lib/interface/cli/commands/gitops/codefresh/upgrade.js +9 -0
- package/lib/interface/cli/commands/gitops/common/install.js +62 -0
- package/lib/interface/cli/commands/gitops/common/uninstall.js +39 -0
- package/lib/interface/cli/commands/gitops/common/upgrade.js +45 -0
- package/lib/interface/cli/commands/gitops/install.cmd.js +116 -0
- package/lib/interface/cli/commands/gitops/install.spec.js +77 -0
- package/lib/interface/cli/commands/gitops/uninstall.cmd.js +56 -0
- package/lib/interface/cli/commands/gitops/upgrade.cmd.js +56 -0
- package/lib/interface/cli/commands/hybrid/delete.cmd.js +341 -0
- package/lib/interface/cli/commands/hybrid/helper.js +877 -1
- package/lib/interface/cli/commands/hybrid/init.cmd.js +957 -0
- package/lib/interface/cli/commands/hybrid/key-helper.js +82 -0
- package/lib/interface/cli/commands/hybrid/migration.js +192 -0
- package/lib/interface/cli/commands/hybrid/upgrade.cmd.js +195 -0
- package/lib/interface/cli/commands/monitor/install.cmd.js +160 -0
- package/lib/interface/cli/commands/monitor/uninstall.cmd.js +78 -0
- package/lib/interface/cli/commands/root/install.cmd.js +17 -0
- package/lib/interface/cli/commands/root/uninstall.cmd.js +17 -0
- package/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js +180 -0
- package/lib/interface/cli/commands/runtimeEnvironments/create.cmd.js +23 -0
- package/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +340 -0
- package/lib/interface/cli/commands/runtimeEnvironments/uninstall.cmd.js +149 -0
- package/lib/interface/cli/completion/tree.json +1 -1
- package/lib/interface/cli/helpers/kubernetes.js +61 -0
- package/lib/interface/cli/helpers/progressEvents.js +25 -0
- package/package.json +11 -2
package/lib/binary/components.js
CHANGED
|
@@ -37,4 +37,42 @@ module.exports = {
|
|
|
37
37
|
repo: 'venona',
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
gitops: {
|
|
41
|
+
'argocd-agent': {
|
|
42
|
+
name: 'gitops',
|
|
43
|
+
description: 'Install gitops argocd agent',
|
|
44
|
+
version: {
|
|
45
|
+
prefix: '',
|
|
46
|
+
},
|
|
47
|
+
local: {
|
|
48
|
+
versionFile: 'version.txt',
|
|
49
|
+
dir: 'gitops',
|
|
50
|
+
binary: 'argocd-agent',
|
|
51
|
+
},
|
|
52
|
+
remote: {
|
|
53
|
+
versionPath: 'installer',
|
|
54
|
+
versionFile: 'VERSION',
|
|
55
|
+
branch: 'master',
|
|
56
|
+
repo: 'argocd-agent',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
codefresh: {
|
|
60
|
+
name: 'cf-gitops-controller',
|
|
61
|
+
description: 'Install gitops codefresh controller',
|
|
62
|
+
version: {
|
|
63
|
+
prefix: '',
|
|
64
|
+
},
|
|
65
|
+
local: {
|
|
66
|
+
versionFile: 'version.txt',
|
|
67
|
+
dir: 'cf-gitops-controller',
|
|
68
|
+
binary: 'cf-gitops-controller',
|
|
69
|
+
},
|
|
70
|
+
remote: {
|
|
71
|
+
versionPath: '/',
|
|
72
|
+
versionFile: 'VERSION',
|
|
73
|
+
branch: 'main',
|
|
74
|
+
repo: 'cf-gitops-controller',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
40
78
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const sdk = require('../../../../logic/sdk');
|
|
2
|
+
const _ = require('lodash');
|
|
3
|
+
|
|
4
|
+
async function getNewAgentName(kubeContextName, kubeNamespace, agents) {
|
|
5
|
+
const defaultName = `${kubeContextName}_${kubeNamespace}`;
|
|
6
|
+
if (!agents) {
|
|
7
|
+
// eslint-disable-next-line no-param-reassign
|
|
8
|
+
agents = await sdk.agents.list({ });
|
|
9
|
+
}
|
|
10
|
+
let name;
|
|
11
|
+
|
|
12
|
+
if (!_.isArray(agents) || !_.find(agents, a => a.name === defaultName)) {
|
|
13
|
+
name = defaultName; // use the default name if there are no collisions
|
|
14
|
+
} else {
|
|
15
|
+
const agentsNames = new Set(_.map(agents, a => a.name)); // for fast lookup
|
|
16
|
+
let i = 1;
|
|
17
|
+
while (agentsNames.has(`${defaultName}_${i}`)) {
|
|
18
|
+
i += 1;
|
|
19
|
+
}
|
|
20
|
+
name = `${defaultName}_${i}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return name;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
getNewAgentName,
|
|
28
|
+
};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const cliProgress = require('cli-progress');
|
|
3
|
+
const colors = require('colors');
|
|
4
|
+
const Command = require('../../Command');
|
|
5
|
+
const installRoot = require('../root/install.cmd');
|
|
6
|
+
const { sdk } = require('../../../../logic');
|
|
7
|
+
const installRuntimeCmd = require('../runtimeEnvironments/install.cmd');
|
|
8
|
+
const { getKubeContext } = require('../../helpers/kubernetes');
|
|
9
|
+
const ProgressEvents = require('../../helpers/progressEvents');
|
|
10
|
+
const { getNewAgentName } = require('./helper');
|
|
11
|
+
const { DefaultLogFormatter } = require('../hybrid/helper');
|
|
12
|
+
const Output = require('../../../../output/Output');
|
|
13
|
+
|
|
14
|
+
const defaultNamespace = 'codefresh';
|
|
15
|
+
|
|
16
|
+
async function createAgent(argv) {
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
kubeConfigPath,
|
|
20
|
+
kubeContextName = getKubeContext(kubeConfigPath),
|
|
21
|
+
kubeNamespace = defaultNamespace,
|
|
22
|
+
} = argv;
|
|
23
|
+
const finalName = name || await getNewAgentName(kubeContextName, kubeNamespace);
|
|
24
|
+
try {
|
|
25
|
+
const { token } = await sdk.agents.create({ name: finalName });
|
|
26
|
+
console.log(`A Codefresh Runner with the name: ${colors.cyan(finalName)} has been created.`);
|
|
27
|
+
return token;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
const msg = Output._extractErrorMessage(err);
|
|
30
|
+
if (msg.includes('Agent name duplication')) {
|
|
31
|
+
throw new Error(`A Codefresh Runner with the name "${colors.cyan(finalName)}" already exists. Please choose a different name, or delete the current agent from the platform.`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function getAgentNameByToken(token) {
|
|
39
|
+
const [apiKey] = token.split('.');
|
|
40
|
+
const agentData = await sdk.tokens.getById({ id: apiKey });
|
|
41
|
+
if (!agentData) {
|
|
42
|
+
throw new Error('token is not valid');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
subject: {
|
|
47
|
+
type,
|
|
48
|
+
ref,
|
|
49
|
+
},
|
|
50
|
+
} = agentData;
|
|
51
|
+
|
|
52
|
+
if (type !== 'agent') {
|
|
53
|
+
throw new Error('token is not assosicated with a runner');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { name } = await sdk.agents.get({ agentId: ref });
|
|
57
|
+
return name;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function installAgentInCluster(argv, token, agentName) {
|
|
61
|
+
const {
|
|
62
|
+
kubeNodeSelector,
|
|
63
|
+
dryRun,
|
|
64
|
+
inCluster,
|
|
65
|
+
tolerations,
|
|
66
|
+
dockerRegistry,
|
|
67
|
+
skipVersionCheck,
|
|
68
|
+
kubeConfigPath,
|
|
69
|
+
kubeContextName = getKubeContext(kubeConfigPath),
|
|
70
|
+
kubeNamespace = defaultNamespace,
|
|
71
|
+
envVars,
|
|
72
|
+
verbose,
|
|
73
|
+
terminateProcess,
|
|
74
|
+
} = argv;
|
|
75
|
+
|
|
76
|
+
const apiHost = sdk.config.context.url;
|
|
77
|
+
const events = new ProgressEvents();
|
|
78
|
+
const format = 'downloading [{bar}] {percentage}% | {value}/{total}';
|
|
79
|
+
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
|
|
80
|
+
let totalSize;
|
|
81
|
+
events.onStart((size) => {
|
|
82
|
+
console.log('Downloading Codefresh Runner installer \n');
|
|
83
|
+
progressBar.start(size, 0);
|
|
84
|
+
totalSize = size;
|
|
85
|
+
});
|
|
86
|
+
events.onProgress((progress) => {
|
|
87
|
+
progressBar.update(progress);
|
|
88
|
+
if (progress >= totalSize) {
|
|
89
|
+
console.log('\n');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const agentInstallStatusCode = await sdk.agents.install({
|
|
93
|
+
agentId: agentName,
|
|
94
|
+
apiHost,
|
|
95
|
+
token,
|
|
96
|
+
kubeConfigPath,
|
|
97
|
+
kubeContextName,
|
|
98
|
+
kubeNamespace,
|
|
99
|
+
kubeNodeSelector,
|
|
100
|
+
inCluster,
|
|
101
|
+
dockerRegistry,
|
|
102
|
+
tolerations,
|
|
103
|
+
skipVersionCheck,
|
|
104
|
+
envVars,
|
|
105
|
+
events,
|
|
106
|
+
dryRun,
|
|
107
|
+
verbose,
|
|
108
|
+
terminateProcess,
|
|
109
|
+
logFormatting: DefaultLogFormatter,
|
|
110
|
+
});
|
|
111
|
+
if (agentInstallStatusCode !== 0) {
|
|
112
|
+
throw new Error(`\nRunner installation failed with code ${agentInstallStatusCode}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function installRuntimeFunc(argv, agentName) {
|
|
117
|
+
const {
|
|
118
|
+
runtimeName,
|
|
119
|
+
skipReCreation,
|
|
120
|
+
buildNodeSelector,
|
|
121
|
+
storageClassName,
|
|
122
|
+
setValue,
|
|
123
|
+
setFile,
|
|
124
|
+
agentKubeContextName,
|
|
125
|
+
agentKubeNamespace,
|
|
126
|
+
kubeConfigPath,
|
|
127
|
+
kubeContextName,
|
|
128
|
+
kubeNamespace,
|
|
129
|
+
skipClusterCreation,
|
|
130
|
+
makeDefaultRuntime,
|
|
131
|
+
platformOnly,
|
|
132
|
+
verbose,
|
|
133
|
+
terminateProcess,
|
|
134
|
+
} = argv;
|
|
135
|
+
await installRuntimeCmd.handler({
|
|
136
|
+
runtimeName,
|
|
137
|
+
skipReCreation,
|
|
138
|
+
skipClusterCreation,
|
|
139
|
+
runtimeKubeConfigPath: kubeConfigPath,
|
|
140
|
+
runtimeKubeContextName: kubeContextName,
|
|
141
|
+
runtimeKubeNamespace: kubeNamespace,
|
|
142
|
+
kubeNodeSelector: buildNodeSelector,
|
|
143
|
+
storageClassName,
|
|
144
|
+
setValue,
|
|
145
|
+
setFile,
|
|
146
|
+
makeDefaultRuntime,
|
|
147
|
+
attachRuntime: true,
|
|
148
|
+
agentName,
|
|
149
|
+
agentKubeContextName,
|
|
150
|
+
agentKubeNamespace,
|
|
151
|
+
restartAgent: true,
|
|
152
|
+
platformOnly,
|
|
153
|
+
verbose,
|
|
154
|
+
terminateProcess,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const installAgentCmd = new Command({
|
|
159
|
+
root: false,
|
|
160
|
+
parent: installRoot,
|
|
161
|
+
command: 'agent',
|
|
162
|
+
description: 'Install and create an agent on kubernetes cluster',
|
|
163
|
+
webDocs: {
|
|
164
|
+
category: 'Agents',
|
|
165
|
+
title: 'Install',
|
|
166
|
+
weight: 100,
|
|
167
|
+
},
|
|
168
|
+
builder: (yargs) => yargs
|
|
169
|
+
.env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv
|
|
170
|
+
.option('name', {
|
|
171
|
+
describe: 'Agent\'s name to be created if token is not provided',
|
|
172
|
+
})
|
|
173
|
+
.option('token', {
|
|
174
|
+
describe: 'Agent\'s token',
|
|
175
|
+
})
|
|
176
|
+
.option('kube-context-name', {
|
|
177
|
+
describe: 'Name of the kubernetes context on which runner should be installed [$CF_ARG_KUBE_CONTEXT_NAME]',
|
|
178
|
+
})
|
|
179
|
+
.option('kube-node-selector', {
|
|
180
|
+
describe: 'The kubernetes node selector "key=value" to be used by runner build resources (default is no node selector) (string)',
|
|
181
|
+
})
|
|
182
|
+
.option('dry-run', {
|
|
183
|
+
describe: 'Set to true to simulate installation',
|
|
184
|
+
})
|
|
185
|
+
.option('in-cluster', {
|
|
186
|
+
describe: 'Set flag if runner is been installed from inside a cluster',
|
|
187
|
+
})
|
|
188
|
+
.option('kube-namespace', {
|
|
189
|
+
describe: 'Name of the namespace on which runner should be installed [$CF_ARG_KUBE_NAMESPACE]',
|
|
190
|
+
})
|
|
191
|
+
.option('tolerations', {
|
|
192
|
+
describe: 'The kubernetes tolerations as path to a JSON file to be used by runner resources (default is no tolerations) (string)',
|
|
193
|
+
})
|
|
194
|
+
.option('kube-config-path', {
|
|
195
|
+
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
|
|
196
|
+
})
|
|
197
|
+
.option('skip-version-check', {
|
|
198
|
+
describe: 'Do not compare current runner\'s version with latest',
|
|
199
|
+
})
|
|
200
|
+
.option('install-runtime', {
|
|
201
|
+
describe: 'Install and attach runtime on the same namespace as the agent (default is false)',
|
|
202
|
+
})
|
|
203
|
+
.option('runtime-name', {
|
|
204
|
+
describe: 'The name of the runtime to install',
|
|
205
|
+
})
|
|
206
|
+
.option('build-node-selector', {
|
|
207
|
+
describe: 'The kubernetes node selector "key=value" to be used by runner build resources (default is no node selector) (string)',
|
|
208
|
+
})
|
|
209
|
+
.option('skip-re-creation', {
|
|
210
|
+
description: 'If set to true, will skip runtime creation in the platform',
|
|
211
|
+
})
|
|
212
|
+
.option('set-value', {
|
|
213
|
+
describe: 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes',
|
|
214
|
+
})
|
|
215
|
+
.option('set-file', {
|
|
216
|
+
describe: 'Set values for templates from file, example: --set-file Storage.GoogleServiceAccount=/path/to/service-account.json',
|
|
217
|
+
})
|
|
218
|
+
.option('skip-cluster-creation', {
|
|
219
|
+
description: 'If set to true, will skip cluster integration creation for this runtime',
|
|
220
|
+
})
|
|
221
|
+
.option('make-default-runtime', {
|
|
222
|
+
describe: 'should all pipelines run on the hybrid runtime (default is false)',
|
|
223
|
+
})
|
|
224
|
+
.option('storage-class-name', {
|
|
225
|
+
describe: 'Set a name of your custom storage class, note: this will not install volume provisioning components',
|
|
226
|
+
})
|
|
227
|
+
.option('agent-kube-context-name', {
|
|
228
|
+
describe: 'Agent kubernetes context (on attach)',
|
|
229
|
+
})
|
|
230
|
+
.option('agent-kube-namespace', {
|
|
231
|
+
describe: 'Agent\'s namespace (on attach)',
|
|
232
|
+
})
|
|
233
|
+
.option('docker-registry', {
|
|
234
|
+
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
|
|
235
|
+
type: 'string',
|
|
236
|
+
})
|
|
237
|
+
.option('platform-only', {
|
|
238
|
+
describe: 'Set to true to create runtime on the platform side only',
|
|
239
|
+
})
|
|
240
|
+
.option('verbose', {
|
|
241
|
+
describe: 'Print logs',
|
|
242
|
+
}),
|
|
243
|
+
handler: async (argv) => {
|
|
244
|
+
const {
|
|
245
|
+
agentKubeNamespace,
|
|
246
|
+
installRuntime,
|
|
247
|
+
platformOnly,
|
|
248
|
+
} = argv;
|
|
249
|
+
let {
|
|
250
|
+
name,
|
|
251
|
+
token,
|
|
252
|
+
} = argv;
|
|
253
|
+
|
|
254
|
+
if (installRuntimeFunc && !agentKubeNamespace) {
|
|
255
|
+
throw new Error('agent-kube-namespace is a mandatory parameter when installing runtime');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!token) {
|
|
259
|
+
// Create an agent if not provided
|
|
260
|
+
token = await createAgent(argv);
|
|
261
|
+
} else {
|
|
262
|
+
// take the agent name from the token
|
|
263
|
+
const nameFromToken = await getAgentNameByToken(token);
|
|
264
|
+
if (!name) {
|
|
265
|
+
name = nameFromToken;
|
|
266
|
+
} else if (name !== nameFromToken) {
|
|
267
|
+
throw new Error(`token is assosicated with agent ${nameFromToken}, different from supplied '--name ${name}'`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (!platformOnly) {
|
|
272
|
+
await installAgentInCluster(argv, token, name);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (installRuntime) {
|
|
276
|
+
await installRuntimeFunc(argv, name);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
console.log(token);
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
module.exports = installAgentCmd;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const Command = require('../../Command');
|
|
3
|
+
const deleteAgent = require('../agent/delete.cmd');
|
|
4
|
+
const unInstallRoot = require('../root/uninstall.cmd');
|
|
5
|
+
const { sdk } = require('../../../../logic');
|
|
6
|
+
const { getKubeContext } = require('../../helpers/kubernetes');
|
|
7
|
+
const ProgressEvents = require('../../helpers/progressEvents');
|
|
8
|
+
const cliProgress = require('cli-progress');
|
|
9
|
+
const { DefaultLogFormatter } = require('./../hybrid/helper');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const unInstallAgentCmd = new Command({
|
|
13
|
+
root: false,
|
|
14
|
+
parent: unInstallRoot,
|
|
15
|
+
command: 'agent',
|
|
16
|
+
description: 'Uninstall an agent on kubernetes cluster',
|
|
17
|
+
webDocs: {
|
|
18
|
+
category: 'Agents',
|
|
19
|
+
title: 'Uninstall',
|
|
20
|
+
weight: 100,
|
|
21
|
+
},
|
|
22
|
+
builder: yargs => yargs
|
|
23
|
+
.env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv
|
|
24
|
+
.option('name', {
|
|
25
|
+
describe: 'Agent\'s name to be uninstalled',
|
|
26
|
+
})
|
|
27
|
+
.option('kube-context-name', {
|
|
28
|
+
describe: 'Name of the kubernetes context on which venona should be uninstalled [$CF_ARG_KUBE_CONTEXT_NAME]',
|
|
29
|
+
})
|
|
30
|
+
.option('kube-namespace', {
|
|
31
|
+
describe: 'Name of the namespace on which venona should be uninstalled [$CF_ARG_KUBE_NAMESPACE]',
|
|
32
|
+
})
|
|
33
|
+
.option('kube-config-path', {
|
|
34
|
+
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
|
|
35
|
+
})
|
|
36
|
+
.option('verbose', {
|
|
37
|
+
describe: 'Print logs',
|
|
38
|
+
}),
|
|
39
|
+
handler: async (argv) => {
|
|
40
|
+
const {
|
|
41
|
+
name,
|
|
42
|
+
'kube-namespace': kubeNamespace,
|
|
43
|
+
'kube-config-path': kubeConfigPath,
|
|
44
|
+
terminateProcess,
|
|
45
|
+
|
|
46
|
+
} = argv;
|
|
47
|
+
|
|
48
|
+
let { 'kube-context-name': kubeContextName } = argv;
|
|
49
|
+
|
|
50
|
+
if (!kubeContextName) {
|
|
51
|
+
kubeContextName = getKubeContext(kubeConfigPath);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!name) {
|
|
55
|
+
throw new Error('Name is a mandatory parameter');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const events = new ProgressEvents();
|
|
59
|
+
const format = 'downloading [{bar}] {percentage}% | {value}/{total}';
|
|
60
|
+
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
|
|
61
|
+
let totalSize;
|
|
62
|
+
events.onStart((size) => {
|
|
63
|
+
progressBar.start(size, 0);
|
|
64
|
+
totalSize = size;
|
|
65
|
+
});
|
|
66
|
+
events.onProgress((progress) => {
|
|
67
|
+
progressBar.update(progress);
|
|
68
|
+
if (progress >= totalSize) {
|
|
69
|
+
console.log('\n');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const exitCode = await sdk.agents.unInstall({
|
|
75
|
+
kubeContextName,
|
|
76
|
+
kubeNamespace,
|
|
77
|
+
kubeConfigPath,
|
|
78
|
+
terminateProcess: false,
|
|
79
|
+
events,
|
|
80
|
+
logFormatting: DefaultLogFormatter,
|
|
81
|
+
});
|
|
82
|
+
if (exitCode === 0) {
|
|
83
|
+
console.log('Agent uninstalled successfully');
|
|
84
|
+
await deleteAgent.handler({ name, id: name });
|
|
85
|
+
}
|
|
86
|
+
if (terminateProcess !== false) {
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
module.exports = unInstallAgentCmd;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const inquirer = require('inquirer').default;
|
|
3
|
+
const YAML = require('yaml');
|
|
4
|
+
const { readFileSync, lstatSync } = require('fs');
|
|
5
|
+
const { resolve } = require('path');
|
|
6
|
+
const { INSTALLATION_DEFAULTS } = require('../hybrid/helper');
|
|
7
|
+
const { getKubeContext } = require('../../helpers/kubernetes');
|
|
8
|
+
|
|
9
|
+
const selectRuntime = async (runtimes) => {
|
|
10
|
+
const ans = await inquirer.prompt({
|
|
11
|
+
type: 'list',
|
|
12
|
+
name: 're',
|
|
13
|
+
message: 'Name of Codefresh runtime-environment to use',
|
|
14
|
+
choices: runtimes,
|
|
15
|
+
});
|
|
16
|
+
return ans.re;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const selectNamespace = async () => {
|
|
20
|
+
const ans = await inquirer.prompt({
|
|
21
|
+
type: 'input',
|
|
22
|
+
name: 'namespace',
|
|
23
|
+
message: 'Name of Kubernetes namespace to use',
|
|
24
|
+
default: INSTALLATION_DEFAULTS.NAMESPACE,
|
|
25
|
+
});
|
|
26
|
+
return ans.namespace;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const selectHost = async () => {
|
|
30
|
+
const ans = await inquirer.prompt({
|
|
31
|
+
type: 'input',
|
|
32
|
+
name: 'host',
|
|
33
|
+
message: 'The hostname that will be used by the app-proxy ingress',
|
|
34
|
+
});
|
|
35
|
+
return ans.host;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const setIfNotDefined = (obj, prop, value) => {
|
|
39
|
+
_.set(obj, prop, _.get(obj, prop, value));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const mergeWithValues = (argv) => {
|
|
43
|
+
if (!argv.values || !lstatSync(resolve(process.cwd(), argv.values)).isFile()) {
|
|
44
|
+
return argv;
|
|
45
|
+
}
|
|
46
|
+
const valuesFileStr = readFileSync(resolve(process.cwd(), argv.values), 'utf8');
|
|
47
|
+
const valuesObj = YAML.parse(valuesFileStr);
|
|
48
|
+
|
|
49
|
+
setIfNotDefined(argv, 'kube-namespace', valuesObj.Namespace || INSTALLATION_DEFAULTS.NAMESPACE);
|
|
50
|
+
setIfNotDefined(argv, 'kube-context-name', valuesObj.Context || getKubeContext());
|
|
51
|
+
setIfNotDefined(argv, 'host', _.get(valuesObj, 'AppProxy.Ingress.Host'));
|
|
52
|
+
setIfNotDefined(argv, 'pathPrefix', _.get(valuesObj, 'AppProxy.Ingress.PathPrefix', ''));
|
|
53
|
+
setIfNotDefined(argv, 'runtime-environment', valuesObj.RuntimeEnvironmentName);
|
|
54
|
+
|
|
55
|
+
return argv;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
selectRuntime,
|
|
60
|
+
mergeWithValues,
|
|
61
|
+
selectNamespace,
|
|
62
|
+
selectHost,
|
|
63
|
+
};
|