@@ -214,15 +214,16 @@ func extractCopyCommands(nodes []*parser.Node, onlyLastImage bool, cfg Config) (
214
214
switch node .Value {
215
215
case command .From :
216
216
from := fromInstruction (node )
217
+ if from .as != "" {
218
+ // Stage names are case insensitive
219
+ stages [strings .ToLower (from .as )] = true
220
+ }
221
+
217
222
if from .image == "" {
218
223
// some build args like artifact dependencies are not available until the first build sequence has completed.
219
224
// skip check if there are unavailable images
220
225
continue
221
226
}
222
- if from .as != "" {
223
- // Stage names are case insensitive
224
- stages [strings .ToLower (from .as )] = true
225
- }
226
227
227
228
// If `from` references a previous stage, then the `workdir`
228
229
// was already changed.
@@ -324,15 +325,13 @@ func expandOnbuildInstructions(nodes []*parser.Node, cfg Config) ([]*parser.Node
324
325
expandedNodes = append (expandedNodes , nodes [n :m + 1 ]... )
325
326
n = m + 1
326
327
327
- if from .image == "" {
328
- // some build args like artifact dependencies are not available until the first build sequence has completed.
329
- // skip check if there are unavailable images
330
- continue
331
- }
332
-
333
328
var onbuildNodes []* parser.Node
334
329
if ons , found := onbuildNodesCache [strings .ToLower (from .image )]; found {
335
330
onbuildNodes = ons
331
+ } else if from .image == "" {
332
+ // some build args like artifact dependencies are not available until the first build sequence has completed.
333
+ // skip check if there are unavailable images
334
+ onbuildNodes = []* parser.Node {}
336
335
} else if ons , err := parseOnbuild (from .image , cfg ); err == nil {
337
336
onbuildNodes = ons
338
337
} else if warnMsg , ok := sErrors .IsOldImageManifestProblem (err ); ok && warnMsg != "" {
0 commit comments