Skip to content

Commit e81fd25

Browse files
Itai GendlerItai Gendler
authored andcommitted
Update pipeline V2 output entity
1 parent 48b3aef commit e81fd25

File tree

8 files changed

+49
-15
lines changed

8 files changed

+49
-15
lines changed

examples/pipeline2-url.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: new-pipeline
2-
account: 59d33c4e9f75220a3710b2ee
1+
name: new-pipeline-url
2+
#account: 59d33c4e9f75220a3710b2ee
33
metadata:
44
labels:
55
repo: github:ArikMaor/ping-server
@@ -9,7 +9,7 @@ spec:
99
repo: ArikMaor/ping-server
1010
events: [push, pullrequest]
1111
branchRegex: '.'
12-
contexts: ['lala']
12+
contexts: []
1313
variables:
1414
- key: PORT
1515
value: 3000
@@ -19,4 +19,4 @@ spec:
1919
encrypted: true
2020
source:
2121
location: url
22-
url: https://raw.githubusercontent.csom/ArikMaor/ping-server/master/codefresh.yml
22+
url: https://raw.githubusercontent.com/codefresh-io/cli/master/codefresh.yml

examples/pipeline2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: new-pipeline
2-
account: 59d33c4e9f75220a3710b2ee
2+
#account: 59d33c4e9f75220a3710b2ee
33
metadata:
44
labels:
55
repo: github:ArikMaor/ping-server
@@ -9,7 +9,7 @@ spec:
99
repo: ArikMaor/ping-server
1010
events: [push, pullrequest]
1111
branchRegex: '.'
12-
contexts: ['lala']
12+
contexts: []
1313
variables:
1414
- key: PORT
1515
value: 3000

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ const run = new Command({
8080
}
8181
}
8282

83+
let pipelineVersion = 'v1';
84+
if (authManager.getCurrentContext()
85+
.isBetaFeatEnabled()) {
86+
try {
87+
await pipeline.getPipelineById(pipelineId);
88+
} catch (err) {
89+
try {
90+
await pipeline2.getPipelineByName(pipelineId);
91+
pipelineVersion = 'v2';
92+
} catch (err) {
93+
throw new CFError({
94+
message: `Passed pipeline id: ${pipelineId} does not exist`,
95+
});
96+
}
97+
}
98+
}
99+
100+
83101
const executionRequests = [];
84102
const executionRequestTemplate = {
85103
pipelineId,
@@ -106,10 +124,10 @@ const run = new Command({
106124

107125
_.forEach(executionRequests, async ({ pipelineId, options }) => {
108126
let workflowId;
109-
if (!ObjectID.isValid(pipelineId)) {
110-
workflowId = await pipeline2.runPipelineByName(pipelineId, options);
111-
} else {
127+
if (pipelineVersion === 'v1') {
112128
workflowId = await pipeline.runPipelineById(pipelineId, options);
129+
} else {
130+
workflowId = await pipeline2.runPipelineByName(pipelineId, options);
113131
}
114132

115133
if (executionRequests.length === 1) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const createRoot = require('../root/create.cmd');
99
const command = new Command({
1010
betaCommand: true,
1111
command: 'pipeline2 [name]',
12+
aliases: ['pip2'],
1213
parent: createRoot,
1314
cliDocs: {
1415
description: 'Create a pipeline',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const deleteRoot = require('../root/delete.cmd');
1010
const command = new Command({
1111
betaCommand: true,
1212
command: 'pipeline2 [name]',
13+
aliases: ['pip2'],
1314
parent: deleteRoot,
1415
cliDocs: {
1516
description: 'Delete a pipeline',

lib/interface/cli/commands/pipeline2/replace.cmd.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const replaceRoot = require('../root/replace.cmd');
99
const command = new Command({
1010
betaCommand: true,
1111
command: 'pipeline2 [name]',
12+
aliases: ['pip2'],
1213
parent: replaceRoot,
1314
cliDocs: {
1415
description: 'Replace a pipeline',

lib/logic/api/pipeline2.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ const CFError = require('cf-errors'); // eslint-disable-line
33
const { sendHttpRequest } = require('./helper');
44
const Pipeline = require('../entities/Pipeline2');
55

6+
const _extractFieldsForPipelineEntity = pipeline => ({
7+
id: pipeline._id,
8+
name: pipeline.name,
9+
spec: pipeline.spec,
10+
});
11+
612
const getAll = async () => {
713
const options = {
814
url: '/api/pipelines/new',
915
method: 'GET',
1016
};
1117

12-
const pipelines = await sendHttpRequest(options);
13-
return pipelines.map(p => new Pipeline(p));
18+
const result = await sendHttpRequest(options);
19+
const pipelines = [];
20+
_.forEach(result, (pipeline) => {
21+
const data = _extractFieldsForPipelineEntity(pipeline);
22+
pipelines.push(new Pipeline(data));
23+
});
24+
25+
return pipelines;
1426
};
1527

1628
const getPipelineByName = async (name) => {
@@ -19,8 +31,9 @@ const getPipelineByName = async (name) => {
1931
method: 'GET',
2032
};
2133

22-
const pipeline = await sendHttpRequest(options);
23-
return new Pipeline(pipeline);
34+
const result = await sendHttpRequest(options);
35+
const data = _extractFieldsForPipelineEntity(result);
36+
return new Pipeline(data);
2437
};
2538

2639
const createPipeline = async (data) => {

lib/logic/entities/Pipeline2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class Pipeline2 extends Entity {
55
super();
66
this.entityType = 'pipeline2';
77
this.info = data;
8-
this.defaultColumns = ['id', 'name', 'imageName'];
9-
this.wideColumns = ['id', 'name', 'imageName'];
8+
this.defaultColumns = ['id', 'name'];
9+
this.wideColumns = this.defaultColumns.concat([]);
1010
}
1111
}
1212

0 commit comments

Comments
 (0)