Skip to content

Commit c167fce

Browse files
author
Oleg Sucharevich
authored
deprecate create and delete runtime-environment through CLI, move to … (#269)
* deprecate create and delete runtime-environment through CLI, move to Venona
1 parent 975a499 commit c167fce

File tree

3 files changed

+12
-110
lines changed

3 files changed

+12
-110
lines changed

lib/interface/cli/commands/runtimeEnvironments/create.cmd.js

Lines changed: 5 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
1-
const debug = require('debug')('codefresh:cli:create:context');
2-
const _ = require('lodash');
31
const Command = require('../../Command');
4-
const fs = require('fs');
5-
const { spawn } = require('child_process');
6-
const rp = require('request-promise');
72
const createRoot = require('../root/create.cmd');
8-
const authManager = require('../../../../logic/auth').manager; // eslint-disable-line
9-
const { cluster } = require('../../../../logic').api;
10-
const CFError = require('cf-errors');
11-
12-
const { CODEFRESH_PATH } = require('../../defaults');
13-
const scriptUrl = 'https://raw.githubusercontent.com/codefresh-io/k8s-dind-config/master/codefresh-k8s-configure.sh';
14-
let filePath = `${CODEFRESH_PATH}/runtime/codefresh-k8s-configure.sh`;
15-
const dirPath = `${CODEFRESH_PATH}/runtime`;
16-
17-
18-
const callToScript = (k8sScript) => {
19-
k8sScript.stdout.pipe(process.stdout);
20-
k8sScript.stderr.pipe(process.stderr);
21-
process.stdin.pipe(k8sScript.stdin);
22-
k8sScript.on('exit', (code) => {
23-
fs.unlink('filePath', (error) => {
24-
if (error) {
25-
throw error;
26-
}
27-
console.log('finish');
28-
});
29-
process.exit(code);
30-
});
31-
};
323

4+
const DEPRECATION_MESSAGE = 'Create runtime-environment is been deprecated. Please use Venona to create a runtime-environment';
5+
const VENONA_REPO_URL = 'https://github.com/codefresh-io/venona';
336

347
const command = new Command({
358
command: 'runtime-environments [cluster]',
@@ -41,67 +14,9 @@ const command = new Command({
4114
title: 'Create Runtime-Environments',
4215
weight: 100,
4316
},
44-
builder: (yargs) => {
45-
return yargs
46-
.option('cluster', {
47-
describe: 'codefresh cluster integration name',
48-
alias: 'c',
49-
required: true,
50-
})
51-
.option('namespace', {
52-
describe: 'namespace',
53-
alias: 'n',
54-
default: 'codefresh',
55-
})
56-
.option('kube-context', {
57-
describe: 'kubectl context name',
58-
alias: 'kc',
59-
})
60-
.option('gcloud', {
61-
describe: 'set if your cluster provider is gcloud',
62-
type: Boolean,
63-
})
64-
.example('codefresh create re --cluster prod --namespace codefresh --kube-context kubeCodefresh', 'Creating a runtime environment which configured to cluster prod and namespace codefresh');
65-
},
66-
handler: async (argv) => {
67-
const currentContext = authManager.getCurrentContext();
68-
const { namespace } = argv;
69-
const clusterName = argv.cluster;
70-
const context = argv['kube-context'] || '';
71-
const gcloud = argv.gcloud || '';
72-
const clusters = await cluster.getAllClusters();
73-
const validCluster = _.find(clusters, (c) => {
74-
return _.isEqual(c.info.name, clusterName);
75-
});
76-
if (validCluster) {
77-
if (!process.env.LOCAL) {
78-
if (!fs.existsSync(CODEFRESH_PATH)) {
79-
fs.mkdirSync(CODEFRESH_PATH);
80-
fs.mkdirSync(dirPath);
81-
} else if (!fs.existsSync(dirPath)) {
82-
fs.mkdirSync(dirPath);
83-
}
84-
const options = {
85-
url: scriptUrl,
86-
method: 'GET',
87-
};
88-
const response = await rp(options);
89-
fs.writeFile(filePath, response, (err) => {
90-
if (err) {
91-
throw err;
92-
}
93-
fs.chmodSync(filePath, '644');
94-
const k8sScript = spawn('bash', [filePath, '--api-token', currentContext.token, '--api-host', currentContext.url, '--namespace', namespace, '--image-tag', 'master', '--remote', '--context', context, '--gcloud', gcloud, clusterName]);
95-
callToScript(k8sScript);
96-
});
97-
} else {
98-
filePath = './codefresh-k8s-configure.sh';
99-
const k8sScript = spawn('bash', [filePath, '--api-token', currentContext.token, '--api-host', currentContext.url, '--namespace', namespace,'--context', context, '--image-tag', 'master','--gcloud', gcloud, clusterName]);
100-
callToScript(k8sScript);
101-
}
102-
} else {
103-
throw new CFError(`No cluster exists with the name: ${clusterName}`);
104-
}
17+
handler: async () => {
18+
console.log(`${DEPRECATION_MESSAGE} ${VENONA_REPO_URL}`);
19+
process.exit(1);
10520
},
10621
});
10722

lib/interface/cli/commands/runtimeEnvironments/delete.cmd.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
const debug = require('debug')('codefresh:cli:create:pipelines2');
21
const Command = require('../../Command');
3-
const CFError = require('cf-errors');
4-
const _ = require('lodash');
5-
const { runtimeEnvironments } = require('../../../../logic/index').api;
62
const deleteRoot = require('../root/delete.cmd');
73

4+
const DEPRECATION_MESSAGE = 'Create runtime-environment is been deprecated. Please use Venona to delete a runtime-environment';
5+
const VENONA_REPO_URL = 'https://github.com/codefresh-io/venona';
6+
87

98
const command = new Command({
109
command: 'runtime-environments name',
@@ -15,21 +14,9 @@ const command = new Command({
1514
category: 'Runtime-Environments',
1615
title: 'Delete Runtime-Environments',
1716
},
18-
builder: (yargs) => {
19-
return yargs
20-
.positional('name', {
21-
describe: 'Runtime environment name',
22-
})
23-
.option('force', {
24-
describe: 'Delete runtime environment in force mode',
25-
type: 'boolean',
26-
});
27-
},
28-
handler: async (argv) => {
29-
const { name, force } = argv;
30-
31-
await runtimeEnvironments.deleteRuntimeEnvironmentByNameForAccount(name, force);
32-
console.log(`Runtime-Environment '${name}' deleted.`);
17+
handler: async () => {
18+
console.log(`${DEPRECATION_MESSAGE} ${VENONA_REPO_URL}`);
19+
process.exit(1);
3320
},
3421
});
3522

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.9.30",
3+
"version": "0.10.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)