This repository was archived by the owner on May 22, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -237,22 +237,30 @@ func (e *Export) ExtractLayers() error {
237
237
return nil
238
238
}
239
239
240
- func (e * Export ) FirstFrom ( ) * ExportedImage {
240
+ func (e * Export ) firstLayer ( pattern string ) * ExportedImage {
241
241
root := e .Root ()
242
242
for {
243
243
if root == nil {
244
244
break
245
245
}
246
246
247
247
cmd := strings .Join (root .LayerConfig .ContainerConfig .Cmd , " " )
248
- if strings .Contains (cmd , "#(nop) ADD file" ) {
248
+ if strings .Contains (cmd , pattern ) {
249
249
break
250
250
}
251
251
root = e .ChildOf (root .LayerConfig .Id )
252
252
}
253
253
return root
254
254
}
255
255
256
+ func (e * Export ) FirstFrom () * ExportedImage {
257
+ return e .firstLayer ("#(nop) ADD file" )
258
+ }
259
+
260
+ func (e * Export ) FirstSquash () * ExportedImage {
261
+ return e .firstLayer ("#(squash)" )
262
+ }
263
+
256
264
// Root returns the top layer in the export
257
265
func (e * Export ) Root () * ExportedImage {
258
266
return e .ChildOf ("" )
Original file line number Diff line number Diff line change @@ -95,7 +95,11 @@ func main() {
95
95
96
96
}
97
97
98
- start := export .FirstFrom ()
98
+ start := export .FirstSquash ()
99
+ // Can't find a previously squashed layer, use first FROM
100
+ if start == nil {
101
+ start = export .FirstFrom ()
102
+ }
99
103
// Can't find a FROM, default to root
100
104
if start == nil {
101
105
start = export .Root ()
You can’t perform that action at this time.
0 commit comments