@@ -3,10 +3,9 @@ const Command = require('../../Command');
3
3
const _ = require ( 'lodash' ) ;
4
4
const CFError = require ( 'cf-errors' ) ;
5
5
const { prepareKeyValueFromCLIEnvOption, crudFilenameOption } = require ( '../../helpers/general' ) ;
6
- const { pipeline } = require ( '../../../../logic' ) . api ;
7
6
const ObjectID = require ( 'mongodb' ) . ObjectID ;
8
- const { log } = require ( '../../../../logic' ) . api ;
9
- const { workflow } = require ( '../../../../logic' ) . api ;
7
+ const { workflow , pipeline , pipeline2 , log } = require ( '../../../../logic' ) . api ;
8
+ const authManager = require ( '../../../../logic' ) . auth . manager ;
10
9
11
10
12
11
const run = new Command ( {
@@ -69,10 +68,15 @@ const run = new Command({
69
68
const scale = argv [ 'scale' ] ;
70
69
const variablesFromFile = argv [ 'var-file' ] ;
71
70
72
- if ( ! ObjectID . isValid ( pipelineId ) ) {
73
- throw new CFError ( {
74
- message : `Passed pipeline id: ${ pipelineId } is not valid` ,
75
- } ) ;
71
+
72
+ if ( ! authManager . getCurrentContext ( )
73
+ . isBetaFeatEnabled ( ) ) {
74
+ // validate that passed pipeline id an a mongo object id in case of pipeline V1
75
+ if ( ! ObjectID . isValid ( pipelineId ) ) {
76
+ throw new CFError ( {
77
+ message : `Passed pipeline id: ${ pipelineId } is not valid` ,
78
+ } ) ;
79
+ }
76
80
}
77
81
78
82
const executionRequests = [ ] ;
@@ -101,8 +105,15 @@ const run = new Command({
101
105
}
102
106
}
103
107
104
- _ . forEach ( executionRequests , async ( request ) => {
105
- const workflowId = await pipeline . runPipelineById ( request . pipelineId , request . options ) ;
108
+ _ . forEach ( executionRequests , async ( { pipelineId, options } ) => {
109
+ let workflowId ;
110
+ if ( authManager . getCurrentContext ( )
111
+ . isBetaFeatEnabled ( ) ) {
112
+ workflowId = await pipeline2 . runPipelineByName ( pipelineId , options ) ;
113
+ } else {
114
+ workflowId = await pipeline . runPipelineById ( pipelineId , options ) ;
115
+ }
116
+
106
117
if ( executionRequests . length === 1 ) {
107
118
if ( argv . detach ) {
108
119
console . log ( workflowId ) ;
0 commit comments