Skip to content

Commit eee64b1

Browse files
olegz-codefreshziv-codefresh
authored andcommitted
New options for run pipeline (cpu,memory, disk, runtime-name, pack-na… (#372)
1 parent 3948c28 commit eee64b1

File tree

4 files changed

+50
-57
lines changed

4 files changed

+50
-57
lines changed

lib/interface/cli/commands/pipeline/run.base.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,26 @@ class RunBaseCommand {
1111
this.argv = argv;
1212
this.executionRequests = [];
1313
}
14+
1415
async run() {
1516
await this.preRunRequest();
17+
const { debug, skip, only, trigger, cpu, memory, branch, sha, disk } = this.argv;
1618
const variablesFromFile = this.argv['var-file'];
1719
const pipelineName = this.argv.name;
18-
const { branch, sha } = this.argv;
1920
const noCache = this.argv['no-cache'];
21+
const runtimeName = this.argv['runtime-name'];
2022
const enableNotifications = this.argv['enable-notifications'];
2123
const resetVolume = this.argv['reset-volume'];
2224
const userYamlDescriptor = this.argv.yaml;
2325
const contexts = this.argv.context;
2426
const noCfCache = this.argv['no-cf-cache'];
25-
const trigger = this.argv['trigger'];
26-
const only = this.argv['only'];
27-
const skip = this.argv['skip'];
28-
const debug = this.argv['debug'];
27+
const packName = this.argv['pack-name'];
28+
2929
if (process.env.CF_BUILD_ID) {
3030
this.argv.annotation.push(`cf_predecessor=${process.env.CF_BUILD_ID}`);
3131
}
32-
const annotations = prepareKeyValueFromCLIEnvOption(this.argv.annotation);
33-
34-
3532

33+
const annotations = prepareKeyValueFromCLIEnvOption(this.argv.annotation);
3634
const executionRequestTemplate = {
3735
pipelineName,
3836
options: {
@@ -48,8 +46,14 @@ class RunBaseCommand {
4846
skip,
4947
annotations,
5048
debug,
49+
cpu,
50+
memory,
51+
disk,
52+
runtimeName,
53+
packName,
5154
},
5255
};
56+
5357
if (variablesFromFile) {
5458
_.forEach(variablesFromFile, (variables) => {
5559
const request = _.cloneDeep(executionRequestTemplate);
@@ -78,6 +82,7 @@ class RunBaseCommand {
7882
async runImpl() {
7983
throw new Error('To be implemented in the derived class');
8084
}
85+
8186
// eslint-disable-next-line class-methods-use-this
8287
async preRunAll() {
8388
const pipelineName = this.argv.name;
@@ -109,21 +114,26 @@ class RunBaseCommand {
109114
});
110115
}
111116
}
117+
112118
// eslint-disable-next-line class-methods-use-this
113119
get isParalel() {
114120
return true;
115121
}
122+
116123
// eslint-disable-next-line class-methods-use-this
117124
async preRunRequest() {
118125
return Promise.resolve();
119126
}
127+
120128
// eslint-disable-next-line class-methods-use-this
121129
async postRunRequest() {
122130
return Promise.resolve();
123131
}
132+
124133
// eslint-disable-next-line class-methods-use-this
125134
async postRunAll() {
126135
return Promise.resolve();
127136
}
128137
}
138+
129139
module.exports = RunBaseCommand;

lib/interface/cli/commands/pipeline/run.cf.js

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,21 @@ const { followLogs } = require('../../helpers/logs');
55
function _buildBody(data) {
66
const body = {
77
options: {},
8+
userMachineConfig: {},
89
};
910

10-
if (data.branch) {
11-
body.branch = data.branch;
12-
}
13-
14-
if (data.variables) {
15-
body.variables = data.variables;
16-
}
17-
18-
if (data.noCache) {
19-
body.options.noCache = data.noCache;
20-
}
21-
22-
if (data.noCfCache) {
23-
body.options.noCfCache = data.noCfCache;
24-
}
25-
26-
if (data.enableNotifications) {
27-
body.options.enableNotifications = data.enableNotifications;
28-
}
29-
30-
if (data.resetVolume) {
31-
body.options.resetVolume = data.resetVolume;
32-
}
33-
34-
if (data.annotations) {
35-
body.annotations = data.annotations;
36-
}
37-
38-
if (data.sha) {
39-
body.sha = data.sha;
40-
}
11+
['branch', 'variables', 'annotations', 'sha', 'userYamlDescriptor', 'contexts', 'trigger']
12+
.filter(property => data[property])
13+
.forEach(property => Object.assign(body, { [property]: data[property] }));
4114

42-
if (data.userYamlDescriptor) {
43-
body.userYamlDescriptor = data.userYamlDescriptor;
44-
}
15+
['noCache', 'noCfCache', 'enableNotifications', 'resetVolume', 'skip', 'only']
16+
.filter(property => data[property])
17+
.forEach(property => Object.assign(body.options, { [property]: data[property] }));
4518

46-
if (data.contexts) {
47-
body.contexts = data.contexts;
48-
}
19+
['cpu', 'memory', 'disk', 'runtimeName', 'packName']
20+
.filter(property => data[property])
21+
.forEach(property => Object.assign(body.userMachineConfig, { [property]: data[property] }));
4922

50-
if (data.trigger) {
51-
body.trigger = data.trigger;
52-
}
53-
if (data.skip) {
54-
body.options.skip = data.skip;
55-
}
56-
if (data.only) {
57-
body.options.only = data.only;
58-
}
5923
return body;
6024
}
6125

lib/interface/cli/commands/pipeline/run.cmd.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ const run = new Command({
3434
.positional('name', {
3535
describe: 'Pipeline name',
3636
})
37+
.option('memory', {
38+
describe: 'Mention machine memory sizes during pipeline run',
39+
coerce: value => `${value}Mi`,
40+
})
41+
.option('cpu', {
42+
describe: 'Mention machine cpu sizes during pipeline run',
43+
coerce: value => `${value}m`,
44+
})
45+
.option('disk', {
46+
describe: 'Mention machine disk space sizes during pipeline run',
47+
coerce: value => `${value}Gi`,
48+
})
49+
.option('pack-name', {
50+
describe: 'Resources size (`small`, `medium` or `large`)',
51+
choices: ['small', 'medium', 'large'],
52+
})
53+
.option('runtime-name', {
54+
describe: 'Runtime environment for run pipeline',
55+
})
3756
.option('sha', {
3857
describe: 'Set commit sha',
3958
alias: 's',
@@ -90,11 +109,11 @@ const run = new Command({
90109
})
91110
.option('only', {
92111
describe: 'run only specifc steps',
93-
array: true
112+
array: true,
94113
})
95114
.option('skip', {
96115
describe: 'skip specifc steps',
97-
array: true
116+
array: true,
98117
})
99118
.option('debug', {
100119
describe: 'debug mode',

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.37.2",
3+
"version": "0.37.5",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)