File tree Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Expand file tree Collapse file tree 8 files changed +49
-15
lines changed Original file line number Diff line number Diff line change 1- name : new-pipeline
2- account : 59d33c4e9f75220a3710b2ee
1+ name : new-pipeline-url
2+ # account: 59d33c4e9f75220a3710b2ee
33metadata :
44 labels :
55 repo : github:ArikMaor/ping-server
99 repo : ArikMaor/ping-server
1010 events : [push, pullrequest]
1111 branchRegex : ' .'
12- contexts : ['lala' ]
12+ contexts : []
1313 variables :
1414 - key : PORT
1515 value : 3000
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
Original file line number Diff line number Diff line change 11name : new-pipeline
2- account : 59d33c4e9f75220a3710b2ee
2+ # account: 59d33c4e9f75220a3710b2ee
33metadata :
44 labels :
55 repo : github:ArikMaor/ping-server
99 repo : ArikMaor/ping-server
1010 events : [push, pullrequest]
1111 branchRegex : ' .'
12- contexts : ['lala' ]
12+ contexts : []
1313 variables :
1414 - key : PORT
1515 value : 3000
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const createRoot = require('../root/create.cmd');
99const command = new Command ( {
1010 betaCommand : true ,
1111 command : 'pipeline2 [name]' ,
12+ aliases : [ 'pip2' ] ,
1213 parent : createRoot ,
1314 cliDocs : {
1415 description : 'Create a pipeline' ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const deleteRoot = require('../root/delete.cmd');
1010const command = new Command ( {
1111 betaCommand : true ,
1212 command : 'pipeline2 [name]' ,
13+ aliases : [ 'pip2' ] ,
1314 parent : deleteRoot ,
1415 cliDocs : {
1516 description : 'Delete a pipeline' ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const replaceRoot = require('../root/replace.cmd');
99const command = new Command ( {
1010 betaCommand : true ,
1111 command : 'pipeline2 [name]' ,
12+ aliases : [ 'pip2' ] ,
1213 parent : replaceRoot ,
1314 cliDocs : {
1415 description : 'Replace a pipeline' ,
Original file line number Diff line number Diff line change @@ -3,14 +3,26 @@ const CFError = require('cf-errors'); // eslint-disable-line
33const { sendHttpRequest } = require ( './helper' ) ;
44const Pipeline = require ( '../entities/Pipeline2' ) ;
55
6+ const _extractFieldsForPipelineEntity = pipeline => ( {
7+ id : pipeline . _id ,
8+ name : pipeline . name ,
9+ spec : pipeline . spec ,
10+ } ) ;
11+
612const 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
1628const 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
2639const createPipeline = async ( data ) => {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments