@@ -165,10 +165,16 @@ func RunSteps(ctx context.Context, opts *RunStepsOpts) (stepResults []execution.
165165 continue
166166 }
167167
168+ resolvedContainer , err := renderStepContainer (step .Container , & stepContext )
169+ if err != nil {
170+ return nil , errors .Wrapf (err , "failed to resolve image for step %d" , i + 1 )
171+ }
172+ step .Container = resolvedContainer
173+
168174 // We need to grab the digest for the exact image we're using.
169175 img , err := opts .EnsureImage (ctx , step .Container )
170176 if err != nil {
171- return nil , err
177+ return nil , errors . Wrapf ( err , "failed to pull image for step %d: %s" , i + 1 , step . Container )
172178 }
173179 digest , err := img .Digest (ctx )
174180 if err != nil {
@@ -241,6 +247,27 @@ func RunSteps(ctx context.Context, opts *RunStepsOpts) (stepResults []execution.
241247 return stepResults , err
242248}
243249
250+ func renderStepContainer (container string , stepContext * template.StepContext ) (string , error ) {
251+ if container == "" {
252+ return "" , nil
253+ }
254+
255+ var out bytes.Buffer
256+ if err := template .RenderStepTemplate ("step-container" , container , & out , stepContext ); err != nil {
257+ return "" , err
258+ }
259+
260+ resolved := out .String ()
261+ if strings .TrimSpace (resolved ) == "" {
262+ return "" , errors .New ("empty image" )
263+ }
264+ if strings .Contains (resolved , "${{" ) {
265+ return "" , errors .Errorf ("unresolved template in image %q" , resolved )
266+ }
267+
268+ return resolved , nil
269+ }
270+
244271const workDir = "/work"
245272
246273func executeSingleStep (
0 commit comments