codefresh 1.3.6 → 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 +1 -10
  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,11 +1,6 @@
1
- /* eslint-disable max-len */
2
1
  const _ = require('lodash');
3
- const cliProgress = require('cli-progress');
4
2
  const Command = require('../../Command');
5
3
  const { sdk } = require('../../../../logic');
6
- const ProgressEvents = require('../../helpers/progressEvents');
7
- const { getKubeContext } = require('../../helpers/kubernetes');
8
- const { DefaultLogFormatter } = require('../hybrid/helper');
9
4
 
10
5
  async function attachInPlatform(argv) {
11
6
  const {
@@ -47,66 +42,10 @@ async function attachInPlatform(argv) {
47
42
  }
48
43
  }
49
44
 
50
- async function attachInCluster(argv) {
51
- const {
52
- runtimeName,
53
- runtimeKubeConfigPath,
54
- runtimeKubeContextName = getKubeContext(runtimeKubeConfigPath),
55
- runtimeKubeNamespace,
56
- agentKubeConfigPath,
57
- agentKubeContextName = runtimeKubeContextName,
58
- agentKubeNamespace,
59
- runtimeKubeServiceAccount,
60
- restartAgent,
61
- verbose,
62
- } = argv;
63
- if (_.isNull(runtimeName) || _.isUndefined(runtimeName) || runtimeName === '') {
64
- throw new Error('runtime name is mandatory');
65
- }
66
-
67
- if (!runtimeKubeNamespace) {
68
- throw new Error('runtime-kube-namespace is mandatory parameter');
69
- }
70
-
71
- // call venonactl to attach
72
- const events = new ProgressEvents();
73
- const format = 'downloading [{bar}] {percentage}% | {value}/{total}';
74
- const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
75
- let totalSize;
76
- events.onStart((size) => {
77
- progressBar.start(size, 0);
78
- totalSize = size;
79
- });
80
- events.onProgress((progress) => {
81
- progressBar.update(progress);
82
- if (progress >= totalSize) {
83
- console.log('\n');
84
- }
85
- });
86
- await sdk.runtime.attach({
87
- runtimeName,
88
- kubeConfigPath: runtimeKubeConfigPath,
89
- kubeContextName: runtimeKubeContextName,
90
- kubeNamespace: runtimeKubeNamespace,
91
- kubeServiceAccount: runtimeKubeServiceAccount,
92
- agentKubeConfigPath,
93
- agentKubeContextName,
94
- agentKubeNamespace,
95
- verbose,
96
- restartAgent,
97
- terminateProcess: false,
98
- events,
99
- logFormatting: DefaultLogFormatter,
100
- });
101
- if (!restartAgent) {
102
- console.log('Please restart agent\'s pod in order that changes will take effect');
103
- }
104
- }
105
-
106
45
  const attachRuntimeCmd = new Command({
107
46
  root: true,
108
47
  command: 'attach runtime',
109
- description: 'Attach a runtime to agent',
48
+ description: 'Attach a runtime to agent in the Codefresh platform',
110
49
  usage: 'attach runtime',
111
50
  webDocs: {
112
51
  category: 'Runtime-Environments',
@@ -124,56 +63,17 @@ const attachRuntimeCmd = new Command({
124
63
  .option('agent-id', {
125
64
  describe: 'Agent\'s ID',
126
65
  })
127
- .option('runtime-kube-context-name', {
128
- describe: 'Runtime kubernetes context',
129
- })
130
- .option('runtime-kube-namespace', {
131
- describe: 'Runtime\'s namespace',
132
- })
133
- .option('runtime-kube-config-path', {
134
- describe: 'Path to kubeconfig file for runtime (default is $HOME/.kube/config)',
135
- })
136
- .option('agent-kube-context-name', {
137
- describe: 'Agent kubernetes context',
138
- })
139
- .option('agent-kube-namespace', {
140
- describe: 'Agent\'s namespace',
141
- })
142
- .option('agent-kube-service-account', {
143
- describe: 'The service account to use for the agent pod',
144
- })
145
- .option('agent-kube-config-path', {
146
- describe: 'Path to kubeconfig file for the agent (default is $HOME/.kube/config)',
147
- })
148
- .option('restart-agent', {
149
- describe: 'restart agent afte install - default false',
150
- })
151
66
  .option('platform-only', {
152
- describe: 'Set to true to attach runtime to agent on the platform side only',
153
- })
154
- .option('verbose', {
155
- describe: 'Print logs',
67
+ describe: 'Deprecated, has no effect: runtime is always attached on the platform side only',
156
68
  }),
157
69
  handler: async (argv) => {
158
- const {
159
- runtimeKubeNamespace,
160
- platformOnly,
161
- terminateProcess,
162
- } = argv;
163
- if (!runtimeKubeNamespace && !platformOnly) {
164
- throw new Error('runtime-kube-namespace is mandatory parameter');
165
- }
70
+ const { terminateProcess } = argv;
166
71
 
167
72
  await attachInPlatform(argv);
168
- if (!platformOnly) {
169
- await attachInCluster(argv);
170
- }
171
73
 
172
74
  if (terminateProcess || terminateProcess === undefined) {
173
75
  process.exit();
174
76
  }
175
-
176
- return 0;
177
77
  },
178
78
  });
179
79
 
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable max-len */
2
- const cliProgress = require('cli-progress');
3
2
  const colors = require('colors');
4
3
  const _ = require('lodash');
5
4
  const Command = require('../../Command');
@@ -7,9 +6,8 @@ const { sdk } = require('../../../../logic');
7
6
  const attachRuntimeCmd = require('./attach.cmd');
8
7
  const installRoot = require('../root/install.cmd');
9
8
  const { getKubeContext } = require('../../helpers/kubernetes');
10
- const ProgressEvents = require('../../helpers/progressEvents');
11
9
  const createClusterCmd = require('../cluster/create.cmd');
12
- const { DefaultLogFormatter, INSTALLATION_DEFAULTS } = require('../hybrid/helper');
10
+ const { INSTALLATION_DEFAULTS } = require('../hybrid/helper');
13
11
 
14
12
  const defaultNamespace = 'codefresh';
15
13
  const defaultStorageClassPrefix = 'dind-local-volumes-runner';
@@ -121,103 +119,19 @@ async function createClusterInPlatform(argv) {
121
119
  }
122
120
  }
123
121
 
124
- async function installRuntimeInCluster(argv, runtimeName) {
125
- const {
126
- storageClassName,
127
- dryRun,
128
- inCluster,
129
- kubeNodeSelector,
130
- setValue,
131
- setFile,
132
- attachRuntime,
133
- dockerRegistry,
134
- runtimeKubeConfigPath,
135
- runtimeKubeContextName = getKubeContext(runtimeKubeConfigPath),
136
- runtimeKubeNamespace = defaultNamespace,
137
- token = sdk.config.context.token,
138
- verbose,
139
- } = argv;
140
-
141
- const apiHost = sdk.config.context.url;
142
-
143
- // install RE on cluster
144
- const runtimeEvents = new ProgressEvents();
145
- const runtimeFormat = 'downloading runtime installer [{bar}] {percentage}% | {value}/{total}';
146
- const runtimmrProgressBar = new cliProgress.SingleBar({ stopOnComplete: true, format: runtimeFormat }, cliProgress.Presets.shades_classic);
147
- let runtimeTotalSize;
148
- runtimeEvents.onStart((size) => {
149
- console.log('Downloading runtime installer:\n');
150
- runtimmrProgressBar.start(size, 0);
151
- runtimeTotalSize = size;
152
- });
153
- runtimeEvents.onProgress((progress) => {
154
- runtimmrProgressBar.update(progress);
155
- if (progress >= runtimeTotalSize) {
156
- console.log('\n');
157
- }
158
- });
159
-
160
- const installRuntimeExitCode = await sdk.runtime.install({
161
- apiHost,
162
- name: runtimeName,
163
- storageClassName: storageClassName && storageClassName.startsWith('dind-local-volumes') ? undefined : storageClassName,
164
- kubeConfigPath: runtimeKubeConfigPath,
165
- kubeContextName: runtimeKubeContextName,
166
- kubeNamespace: runtimeKubeNamespace,
167
- kubeNodeSelector,
168
- token,
169
- inCluster,
170
- dockerRegistry,
171
- setValue,
172
- setFile,
173
- terminateProcess: !attachRuntime,
174
- events: runtimeEvents,
175
- dryRun,
176
- verbose,
177
- logFormatting: DefaultLogFormatter,
178
- });
179
- // attach RE to agent in codefresh
180
-
181
- if (installRuntimeExitCode !== 0) {
182
- throw new Error(`Runtime environment installation failed with exit code: ${installRuntimeExitCode}`);
183
- }
184
- }
185
-
186
- async function attachRuntimeToAgent(argv, runtimeName) {
187
- const {
188
- agentName,
189
- runtimeKubeConfigPath,
190
- runtimeKubeContextName = getKubeContext(runtimeKubeConfigPath),
191
- runtimeKubeNamespace = defaultNamespace,
192
- agentKubeConfigPath = runtimeKubeConfigPath,
193
- agentKubeContextName = runtimeKubeContextName,
194
- agentKubeNamespace,
195
- platformOnly,
196
- } = argv;
197
-
198
- const attachRuntimeStatusCode = await attachRuntimeCmd.handler({
122
+ async function attachRuntimeToAgent(agentName, runtimeName) {
123
+ await attachRuntimeCmd.handler({
199
124
  agentName,
200
125
  runtimeName,
201
- runtimeKubeConfigPath,
202
- runtimeKubeContextName,
203
- runtimeKubeNamespace,
204
- agentKubeConfigPath,
205
- agentKubeContextName,
206
- agentKubeNamespace,
207
- restartAgent: true,
208
- platformOnly,
209
126
  terminateProcess: false,
210
127
  });
211
- if (attachRuntimeStatusCode !== 0) {
212
- throw new Error(`Attach runtime failed with exit code ${attachRuntimeStatusCode}`);
213
- }
214
128
  }
215
129
 
216
130
  const installRuntimeCmd = new Command({
217
131
  root: false,
218
132
  parent: installRoot,
219
133
  command: 'runtime',
220
- description: 'Install and create a runtime on kubernetes cluster',
134
+ description: 'Create a runtime in the Codefresh platform',
221
135
  webDocs: {
222
136
  category: 'Runtime-Environments',
223
137
  title: 'Install Runtime-Environment',
@@ -228,31 +142,12 @@ const installRuntimeCmd = new Command({
228
142
  .option('runtime-name', {
229
143
  describe: 'The name of the runtime to install',
230
144
  })
231
- .option('token', {
232
- describe: 'Agent\'s token',
233
- })
234
145
  .option('agent-name', {
235
146
  describe: 'Agent\'s name',
236
147
  })
237
148
  .option('storage-class-name', {
238
149
  describe: 'Set a name of your custom storage class, note: this will not install volume provisioning components',
239
150
  })
240
- .option('docker-registry', {
241
- describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
242
- type: 'string',
243
- })
244
- .option('set-value', {
245
- describe: 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes',
246
- })
247
- .option('set-file', {
248
- describe: 'Set values for templates from file, example: --set-file Storage.GoogleServiceAccount=/path/to/service-account.json',
249
- })
250
- .option('dry-run', {
251
- describe: 'Set to true to simulate installation',
252
- })
253
- .option('in-cluster', {
254
- describe: 'Set flag if runner is been installed from inside a cluster',
255
- })
256
151
  .option('kube-node-selector', {
257
152
  describe: 'The kubernetes node selector "key=value" to be used by runner build resources (default is no node selector) (string)',
258
153
  })
@@ -269,16 +164,7 @@ const installRuntimeCmd = new Command({
269
164
  describe: 'The kubernetes metadata.annotations as "key=value" to be used by runner build resources (default is no node selector)',
270
165
  })
271
166
  .option('attach-runtime', {
272
- describe: 'if set to true, auto attach runtime to agent (need to provide ....)',
273
- })
274
- .option('agent-kube-config-path', {
275
- describe: 'Path to kubeconfig file for the agent (default is $HOME/.kube/config) (on attach)',
276
- })
277
- .option('agent-kube-context-name', {
278
- describe: 'Agent kubernetes context (on attach)',
279
- })
280
- .option('agent-kube-namespace', {
281
- describe: 'Agent\'s namespace (on attach)',
167
+ describe: 'if set to true, auto attach runtime to agent (need to provide --agent-name)',
282
168
  })
283
169
  .option('cluster-service-account', {
284
170
  describe: 'service account for cluster default is default',
@@ -293,28 +179,20 @@ const installRuntimeCmd = new Command({
293
179
  description: 'If set to true, will skip cluster integration creation for this runtime',
294
180
  })
295
181
  .option('platform-only', {
296
- describe: 'Set to true to create runtime on the platform side only',
297
- })
298
- .option('verbose', {
299
- describe: 'Print logs',
182
+ describe: 'Deprecated, has no effect: runtime is always created on the platform side only',
300
183
  }),
301
184
  handler: async (argv) => {
302
185
  const {
303
186
  runtimeName,
187
+ agentName,
304
188
  skipReCreation,
305
189
  skipClusterCreation,
306
190
  attachRuntime,
307
191
  runtimeKubeConfigPath,
308
192
  runtimeKubeContextName = getKubeContext(runtimeKubeConfigPath),
309
193
  runtimeKubeNamespace = defaultNamespace,
310
- agentKubeNamespace,
311
- platformOnly,
312
194
  } = argv;
313
195
 
314
- if (attachRuntime && !agentKubeNamespace) {
315
- throw new Error('agent-kube-namespace is a mandatory parameter');
316
- }
317
-
318
196
  const finalName = runtimeName || await newRuntimeName(runtimeKubeContextName, runtimeKubeNamespace);
319
197
 
320
198
  if (!skipReCreation) {
@@ -325,12 +203,8 @@ const installRuntimeCmd = new Command({
325
203
  await createClusterInPlatform(argv);
326
204
  }
327
205
 
328
- if (!platformOnly) {
329
- await installRuntimeInCluster(argv, finalName);
330
- }
331
-
332
206
  if (attachRuntime) {
333
- await attachRuntimeToAgent(argv, finalName);
207
+ await attachRuntimeToAgent(agentName, finalName);
334
208
  } else {
335
209
  console.log('Please run agent attach in order to link agent and runtime');
336
210
  }
@@ -1 +1 @@
1
- {"codefresh":{"analyze":{},"completion":{},"completions":{"alias":"completion"},"tag":{},"untag":{},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"attach":{},"annotate":{"image":{},"img":{"alias":"image"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"assign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"add":{"repository":{},"repo":{"alias":"repository"}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/create.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"download":{"audit":{}},"generate":{"image-pull-secret":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"runtime-environment-base-images":{"__optionHandlers":["../commands/root/get.completion.js"]},"re-base-images":{"alias":"runtime-environment-base-images"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"install":{"runtime":{},"agent":{},"app-proxy":{},"monitor":{},"gitops":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"delete":{},"execute-test-pipeline":{},"info":{},"init":{},"upgrade":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"unassign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"uninstall":{"agent":{},"app-proxy":{},"runtime":{},"monitor":{},"gitops":{}},"upgrade":{"app-proxy":{},"gitops":{}},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"logs":{},"restart":{},"terminate":{},"wait":{}}}
1
+ {"codefresh":{"analyze":{},"completion":{},"completions":{"alias":"completion"},"tag":{},"untag":{},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"add":{"repository":{},"repo":{"alias":"repository"}},"annotate":{"image":{},"img":{"alias":"image"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"assign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]}},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]}},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"}},"download":{"audit":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"runtime-environment-base-images":{"__optionHandlers":["../commands/root/get.completion.js"]},"re-base-images":{"alias":"runtime-environment-base-images"},"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"generate":{"image-pull-secret":{}},"install":{"runtime":{},"agent":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"execute-test-pipeline":{},"info":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"unassign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"upgrade":{},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"attach":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"logs":{},"restart":{},"terminate":{},"wait":{}}}
@@ -1,17 +1,16 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
- const { KubeConfig, Client } = require('kubernetes-client');
4
- const Request = require('kubernetes-client/backends/request');
5
- const _ = require('lodash');
3
+ const yaml = require('js-yaml');
6
4
  const { homedir } = require('os');
7
5
 
6
+ // same context name @kubernetes/client-node assigns when loading config from the service account
7
+ const IN_CLUSTER_CONTEXT = 'inClusterContext';
8
+
8
9
  const isInCluster = () => fs.existsSync('/var/run/secrets/kubernetes.io/serviceaccount');
9
10
 
10
- const _getKubeConfig = (kubeconfigPath) => {
11
- const kc = new KubeConfig();
11
+ const getKubeContext = (kubeconfigPath) => {
12
12
  if (isInCluster()) {
13
- kc.loadFromCluster();
14
- return kc;
13
+ return IN_CLUSTER_CONTEXT;
15
14
  }
16
15
 
17
16
  const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir(), '.kube', 'config');
@@ -19,43 +18,10 @@ const _getKubeConfig = (kubeconfigPath) => {
19
18
  throw new Error(`kubeconfig not found at: ${kubePath}, make sure the $KUBECONFIG environment variable is set correctly`);
20
19
  }
21
20
 
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'));
21
+ const kubeconfig = yaml.load(fs.readFileSync(kubePath, 'utf8'));
22
+ return kubeconfig && kubeconfig['current-context'];
54
23
  };
55
24
 
56
25
  module.exports = {
57
26
  getKubeContext,
58
- getAllKubeContexts,
59
- getAllNamespaces,
60
- isInCluster,
61
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codefresh",
3
- "version": "1.3.6",
3
+ "version": "2.0.0",
4
4
  "description": "Codefresh command line utility",
5
5
  "main": "index.js",
6
6
  "preferGlobal": true,
@@ -33,7 +33,6 @@
33
33
  "resolutions": {
34
34
  "json-schema": "^0.4.0",
35
35
  "ansi-regex": "^5.0.1",
36
- "kubernetes-client/@kubernetes/client-node": "^0.22.2",
37
36
  "tough-cookie": "^4.1.3",
38
37
  "openid-client": "^4.9.0",
39
38
  "**/request/form-data": "^2.5.5",
@@ -42,7 +41,6 @@
42
41
  "**/swagger-client/cookie": "^0.7.0"
43
42
  },
44
43
  "dependencies": {
45
- "adm-zip": "^0.6.0",
46
44
  "ajv": "^6.14.0",
47
45
  "bluebird": "^3.5.1",
48
46
  "cf-errors": "^0.1.16",
@@ -57,18 +55,13 @@
57
55
  "diff": "^3.5.0",
58
56
  "dockerode": "^2.5.7",
59
57
  "draftlog": "^1.0.12",
60
- "figlet": "^1.4.0",
61
58
  "filesize": "^3.5.11",
62
- "firebase": "git+https://github.com/codefresh-io/firebase.git#80b2ed883ff281cd67b53bd0f6a0bbd6f330fed5",
63
59
  "flat": "^5.0.2",
64
- "inquirer": "^12.11.1",
65
60
  "js-yaml": "^4.3.0",
66
61
  "kefir": "^3.8.1",
67
- "kubernetes-client": "^9.0.0",
68
62
  "lodash": "^4.17.23",
69
63
  "moment": "^2.29.4",
70
64
  "mongodb": "^4.17.2",
71
- "node-forge": "^1.3.0",
72
65
  "ora": "^5.4.1",
73
66
  "recursive-readdir": "^2.2.3",
74
67
  "request": "^2.88.0",
@@ -77,13 +70,11 @@
77
70
  "rimraf": "^2.6.2",
78
71
  "semver": "^7.5.4",
79
72
  "tar-stream": "^2.2.0",
80
- "yaml": "^1.10.0",
81
73
  "yargs": "^15.4.1",
82
74
  "yargs-parser": "^13.0.0",
83
75
  "zip": "^1.2.0"
84
76
  },
85
77
  "devDependencies": {
86
- "@types/node-forge": "^1.0.1",
87
78
  "@yao-pkg/pkg": "^6.25.0",
88
79
  "eslint": "^7.32.0",
89
80
  "eslint-config-airbnb-base": "^15.0.0",
@@ -1,92 +0,0 @@
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;