@@ -145,10 +145,15 @@ func GetPipelineRunAsUser() *int64 {
145145	return  & runAsUser 
146146}
147147
148- func  (c  * workflowCompiler ) containerDriverTask (name  string , inputs  containerDriverInputs ) (* wfapi.DAGTask , * containerDriverOutputs ) {
148+ func  (c  * workflowCompiler ) containerDriverTask (name  string , inputs  containerDriverInputs ) (* wfapi.DAGTask , * containerDriverOutputs , error ) {
149+ 	template , err  :=  c .addContainerDriverTemplate ()
150+ 	if  err  !=  nil  {
151+ 		return  nil , nil , err 
152+ 	}
153+ 
149154	dagTask  :=  & wfapi.DAGTask {
150155		Name :     name ,
151- 		Template : c . addContainerDriverTemplate () ,
156+ 		Template : template ,
152157		Arguments : wfapi.Arguments {
153158			Parameters : []wfapi.Parameter {
154159				{Name : paramComponent , Value : wfapi .AnyStringPtr (inputs .component )},
@@ -176,44 +181,44 @@ func (c *workflowCompiler) containerDriverTask(name string, inputs containerDriv
176181		cached :       taskOutputParameter (name , paramCachedDecision ),
177182		condition :    taskOutputParameter (name , paramCondition ),
178183	}
179- 	return  dagTask , outputs 
184+ 	return  dagTask , outputs ,  nil 
180185}
181186
182- func  (c  * workflowCompiler ) addContainerDriverTemplate () string  {
187+ func  (c  * workflowCompiler ) addContainerDriverTemplate () ( string ,  error )  {
183188	name  :=  "system-container-driver" 
184189	_ , ok  :=  c .templates [name ]
185190	if  ok  {
186- 		return  name 
187- 	}
188- 
189- 	args   :=  [] string { 
190- 		 "--type" ,  "CONTAINER" , 
191- 		 "--pipeline_name" ,  c . spec . GetPipelineInfo (). GetName (), 
192- 		 "--run_id" ,  runID (), 
193- 		"--run_name"  ,  runResourceName () ,
194- 		"--run_display_name"  ,  c . job . DisplayName ,
195- 		"--dag_execution_id"  ,  inputValue ( paramParentDagID ),
196- 		"--component"  ,  inputValue ( paramComponent ),
197- 		"--task"  ,  inputValue ( paramTask ) ,
198- 		"--task_name"  ,  inputValue (paramTaskName ),
199- 		"--container"  ,  inputValue (paramContainer ),
200- 		"--iteration_index"  ,  inputValue (paramIterationIndex ),
201- 		"--cached_decision_path"  ,  outputPath ( paramCachedDecision ),
202- 		"--pod_spec_patch_path"  ,  outputPath ( paramPodSpecPatch ),
203- 		"--condition_path"  ,  outputPath ( paramCondition ),
204- 		"--kubernetes_config"  ,  inputValue ( paramKubernetesConfig ),
205- 		"--http_proxy"  ,  proxy . GetConfig (). GetHttpProxy ( ),
206- 		"--https_proxy"  ,  proxy . GetConfig (). GetHttpsProxy ( ),
207- 		"--no_proxy"  ,  proxy . GetConfig (). GetNoProxy ( ),
208- 	} 
209- 	if   c . cacheDisabled  { 
210- 		args   =   append ( args ,  "--cache_disabled" ) 
211- 	} 
212- 	if   value ,  ok   :=   os . LookupEnv ( PipelineLogLevelEnvVar );  ok  { 
213- 		args   =   append ( args ,  "--log_level" ,  value ) 
214- 	}
215- 	if  value ,  ok   :=   os . LookupEnv ( PublishLogsEnvVar );  ok  {
216- 		args   =   append ( args ,  "--publish_logs" ,  value )
191+ 		return  name ,  nil 
192+ 	}
193+ 
194+ 	logLevel ,  _   :=  os . LookupEnv ( PipelineLogLevelEnvVar ) 
195+ 	publishLogs ,  _   :=   os . LookupEnv ( PublishLogsEnvVar ) 
196+ 
197+ 	driverPlugin ,  err   :=   driverPlugin ( map [ string ] interface {}{ 
198+ 		"type"  :                  "CONTAINER" ,
199+ 		"pipeline_name"  :         c . spec . GetPipelineInfo (). GetName () ,
200+ 		"run_id"  :                runID ( ),
201+ 		"run_name"  :              runResourceName ( ),
202+ 		"run_display_name"  :      c . job . DisplayName ,
203+ 		"dag_execution_id"  :      inputValue (paramParentDagID ),
204+ 		"component"  :             inputValue (paramComponent ),
205+ 		"task"  :                  inputValue (paramTask ),
206+ 		"task_name"  :             inputValue ( paramTaskName ),
207+ 		"container"  :             inputValue ( paramContainer ),
208+ 		"iteration_index"  :       inputValue ( paramIterationIndex ),
209+ 		"cached_decision_path"  :  outputPath ( paramCachedDecision ),
210+ 		"pod_spec_patch_path"  :   outputPath ( paramPodSpecPatch ),
211+ 		"condition_path"  :        outputPath ( paramCondition ),
212+ 		"kubernetes_config"  :     inputValue ( paramKubernetesConfig ),
213+ 		 "http_proxy" :            proxy . GetConfig (). GetHttpProxy (), 
214+ 		 "https_proxy" :           proxy . GetConfig (). GetHttpsProxy (), 
215+ 		"no_proxy" :              proxy . GetConfig (). GetNoProxy (), 
216+ 		 "cache_disabled" :        c . cacheDisabled , 
217+ 		 "log_level" :             logLevel , 
218+ 		"publish_logs" :          publishLogs , 
219+ 	}) 
220+ 	if  err   !=   nil  {
221+ 		return   "" ,  fmt . Errorf ( "failed to create container driver template: %w" ,  err )
217222	}
218223
219224	t  :=  & wfapi.Template {
@@ -231,22 +236,16 @@ func (c *workflowCompiler) addContainerDriverTemplate() string {
231236		},
232237		Outputs : wfapi.Outputs {
233238			Parameters : []wfapi.Parameter {
234- 				{Name : paramPodSpecPatch , ValueFrom : & wfapi.ValueFrom {Path : "/tmp/outputs/ pod-spec-patch" , Default : wfapi .AnyStringPtr ("" )}},
235- 				{Name : paramCachedDecision , Default : wfapi .AnyStringPtr ("false" ), ValueFrom : & wfapi.ValueFrom {Path : "/tmp/outputs/ cached-decision" , Default : wfapi .AnyStringPtr ("false" )}},
236- 				{Name : paramCondition , ValueFrom : & wfapi.ValueFrom {Path : "/tmp/outputs/ condition" , Default : wfapi .AnyStringPtr ("true" )}},
239+ 				{Name : paramPodSpecPatch , ValueFrom : & wfapi.ValueFrom {JSONPath : "$. pod-spec-patch" , Default : wfapi .AnyStringPtr ("" )}},
240+ 				{Name : paramCachedDecision , Default : wfapi .AnyStringPtr ("false" ), ValueFrom : & wfapi.ValueFrom {JSONPath : "$. cached-decision" , Default : wfapi .AnyStringPtr ("false" )}},
241+ 				{Name : paramCondition , ValueFrom : & wfapi.ValueFrom {JSONPath : "$. condition" , Default : wfapi .AnyStringPtr ("true" )}},
237242			},
238243		},
239- 		Container : & k8score.Container {
240- 			Image :     c .driverImage ,
241- 			Command :   c .driverCommand ,
242- 			Args :      args ,
243- 			Resources : driverResources ,
244- 			Env :       proxy .GetConfig ().GetEnvVars (),
245- 		},
244+ 		Plugin : driverPlugin ,
246245	}
247246	c .templates [name ] =  t 
248247	c .wf .Spec .Templates  =  append (c .wf .Spec .Templates , * t )
249- 	return  name 
248+ 	return  name ,  nil 
250249}
251250
252251type  containerExecutorInputs  struct  {
0 commit comments