@@ -206,7 +206,30 @@ func (s *DeploymentPluginServiceServer[Config, DeployTargetConfig]) ExecuteStage
206
206
stageID : request .GetInput ().GetStage ().GetId (),
207
207
logPersister : lp ,
208
208
}
209
- return executeStage (ctx , s .base , & s .config , nil , client , request , s .logger ) // TODO: pass the deployTargets
209
+
210
+ // Get the deploy targets set on the deployment from the piped plugin config.
211
+ dtNames := request .GetInput ().GetDeployment ().GetDeployTargets (s .commonFields .config .Name )
212
+ deployTargets := make ([]* DeployTarget [DeployTargetConfig ], 0 , len (dtNames ))
213
+ for _ , name := range dtNames {
214
+ dt := s .commonFields .config .FindDeployTarget (name )
215
+ if dt == nil {
216
+ return nil , status .Errorf (codes .Internal , "the deploy target %s is not found in the piped plugin config" , name )
217
+ }
218
+
219
+ // TODO: cache the unmarshaled config to avoid unmarshaling it multiple times.
220
+ var sdkDt DeployTargetConfig
221
+ if err := json .Unmarshal (dt .Config , & sdkDt ); err != nil {
222
+ return nil , status .Errorf (codes .Internal , "failed to unmarshal deploy target config: %v" , err )
223
+ }
224
+
225
+ deployTargets = append (deployTargets , & DeployTarget [DeployTargetConfig ]{
226
+ Name : name ,
227
+ Labels : dt .Labels ,
228
+ Config : sdkDt ,
229
+ })
230
+ }
231
+
232
+ return executeStage (ctx , s .base , & s .config , deployTargets , client , request , s .logger )
210
233
}
211
234
212
235
// StagePluginServiceServer is the gRPC server that handles requests from the piped.
0 commit comments