@@ -139,8 +139,25 @@ func TestConfig_Analyze(t *testing.T) {
139
139
DecompressedLayerID : "sha256:24df0d4e20c0f42d3703bf1f1db2bdd77346c7956f74f423603d651e8e5ae8a7" ,
140
140
LayerInfo : types.LayerInfo {
141
141
SchemaVersion : 1 ,
142
- Applications : []types.Application {{Type : "composer" , FilePath : "php-app/composer.lock" , Libraries : []depTypes.Library {{Name : "guzzlehttp/guzzle" , Version : "6.2.0" }, {Name : "guzzlehttp/promises" , Version : "v1.3.1" }, {Name : "guzzlehttp/psr7" , Version : "1.5.2" }, {Name : "laravel/installer" , Version : "v2.0.1" }, {Name : "pear/log" , Version : "1.13.1" }, {Name : "pear/pear_exception" , Version : "v1.0.0" }, {Name : "psr/http-message" , Version : "1.0.1" }, {Name : "ralouphie/getallheaders" , Version : "2.0.5" }, {Name : "symfony/console" , Version : "v4.2.7" }, {Name : "symfony/contracts" , Version : "v1.0.2" }, {Name : "symfony/filesystem" , Version : "v4.2.7" }, {Name : "symfony/polyfill-ctype" , Version : "v1.11.0" }, {Name : "symfony/polyfill-mbstring" , Version : "v1.11.0" }, {Name : "symfony/process" , Version : "v4.2.7" }}}},
143
- OpaqueDirs : []string {"php-app/" },
142
+ Applications : []types.Application {{Type : "composer" , FilePath : "php-app/composer.lock" ,
143
+ Libraries : []types.LibraryInfo {
144
+ {Library : depTypes.Library {Name : "guzzlehttp/guzzle" , Version : "6.2.0" }},
145
+ {Library : depTypes.Library {Name : "guzzlehttp/promises" , Version : "v1.3.1" }},
146
+ {Library : depTypes.Library {Name : "guzzlehttp/psr7" , Version : "1.5.2" }},
147
+ {Library : depTypes.Library {Name : "laravel/installer" , Version : "v2.0.1" }},
148
+ {Library : depTypes.Library {Name : "pear/log" , Version : "1.13.1" }},
149
+ {Library : depTypes.Library {Name : "pear/pear_exception" , Version : "v1.0.0" }},
150
+ {Library : depTypes.Library {Name : "psr/http-message" , Version : "1.0.1" }},
151
+ {Library : depTypes.Library {Name : "ralouphie/getallheaders" , Version : "2.0.5" }},
152
+ {Library : depTypes.Library {Name : "symfony/console" , Version : "v4.2.7" }},
153
+ {Library : depTypes.Library {Name : "symfony/contracts" , Version : "v1.0.2" }},
154
+ {Library : depTypes.Library {Name : "symfony/filesystem" , Version : "v4.2.7" }},
155
+ {Library : depTypes.Library {Name : "symfony/polyfill-ctype" , Version : "v1.11.0" }},
156
+ {Library : depTypes.Library {Name : "symfony/polyfill-mbstring" , Version : "v1.11.0" }},
157
+ {Library : depTypes.Library {Name : "symfony/process" , Version : "v4.2.7" }},
158
+ },
159
+ }},
160
+ OpaqueDirs : []string {"php-app/" },
144
161
},
145
162
},
146
163
},
@@ -209,8 +226,9 @@ func TestConfig_Analyze(t *testing.T) {
209
226
mockCache .ApplyPutLayerExpectations (tt .putLayerExpectations )
210
227
mockCache .ApplyPutImageExpectations (tt .putImageExpectations )
211
228
212
- d , err := docker .NewDockerArchiveExtractor (context .Background (), tt .imagePath , types.DockerOption {})
229
+ d , cleanup , err := docker .NewDockerArchiveExtractor (context .Background (), tt .imagePath , types.DockerOption {})
213
230
require .NoError (t , err , tt .name )
231
+ defer cleanup ()
214
232
215
233
ac := analyzer .New (d , mockCache )
216
234
got , err := ac .Analyze (context .Background ())
@@ -265,6 +283,7 @@ func TestApplier_ApplyLayers(t *testing.T) {
265
283
FilePath : "var/lib/dpkg/status.d/tzdata" ,
266
284
Packages : []types.Package {
267
285
{
286
+ LayerID : "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02" ,
268
287
Name : "tzdata" ,
269
288
Version : "2019a-0+deb9u1" ,
270
289
SrcName : "tzdata" ,
@@ -313,14 +332,18 @@ func TestApplier_ApplyLayers(t *testing.T) {
313
332
{
314
333
Type : "composer" ,
315
334
FilePath : "php-app/composer.lock" ,
316
- Libraries : []depTypes. Library {
335
+ Libraries : []types. LibraryInfo {
317
336
{
318
- Name : "guzzlehttp/guzzle" ,
319
- Version : "6.2.0" ,
337
+ Library : depTypes.Library {
338
+ Name : "guzzlehttp/guzzle" ,
339
+ Version : "6.2.0" ,
340
+ },
320
341
},
321
342
{
322
- Name : "symfony/process" ,
323
- Version : "v4.2.7" ,
343
+ Library : depTypes.Library {
344
+ Name : "symfony/process" ,
345
+ Version : "v4.2.7" ,
346
+ },
324
347
},
325
348
},
326
349
},
@@ -347,14 +370,33 @@ func TestApplier_ApplyLayers(t *testing.T) {
347
370
Name : "9.9" ,
348
371
},
349
372
Packages : []types.Package {
350
- {Name : "libc6" , Version : "2.24-11+deb9u4" , SrcName : "glibc" , SrcVersion : "2.24-11+deb9u4" },
351
- {Name : "tzdata" , Version : "2019a-0+deb9u1" , SrcName : "tzdata" , SrcVersion : "2019a-0+deb9u1" },
373
+ {
374
+ Name : "libc6" , Version : "2.24-11+deb9u4" , SrcName : "glibc" , SrcVersion : "2.24-11+deb9u4" ,
375
+ LayerID : "sha256:dffd9992ca398466a663c87c92cfea2a2db0ae0cf33fcb99da60eec52addbfc5" ,
376
+ },
377
+ {
378
+ Name : "tzdata" , Version : "2019a-0+deb9u1" , SrcName : "tzdata" , SrcVersion : "2019a-0+deb9u1" ,
379
+ LayerID : "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02" ,
380
+ },
352
381
},
353
382
Applications : []types.Application {
354
383
{
355
384
Type : "composer" , FilePath : "php-app/composer.lock" ,
356
- Libraries : []depTypes.Library {{Name : "guzzlehttp/guzzle" , Version : "6.2.0" },
357
- {Name : "symfony/process" , Version : "v4.2.7" },
385
+ Libraries : []types.LibraryInfo {
386
+ {
387
+ Library : depTypes.Library {
388
+ Name : "guzzlehttp/guzzle" ,
389
+ Version : "6.2.0" ,
390
+ },
391
+ LayerID : "sha256:24df0d4e20c0f42d3703bf1f1db2bdd77346c7956f74f423603d651e8e5ae8a7" ,
392
+ },
393
+ {
394
+ Library : depTypes.Library {
395
+ Name : "symfony/process" ,
396
+ Version : "v4.2.7" ,
397
+ },
398
+ LayerID : "sha256:24df0d4e20c0f42d3703bf1f1db2bdd77346c7956f74f423603d651e8e5ae8a7" ,
399
+ },
358
400
},
359
401
},
360
402
},
@@ -384,11 +426,11 @@ func TestApplier_ApplyLayers(t *testing.T) {
384
426
{
385
427
FilePath : "lib/apk/db/installed" ,
386
428
Packages : []types.Package {
387
- {Name : "musl" , Version : "1.1.22-r3" },
388
- {Name : "busybox" , Version : "1.30.1-r3" },
389
- {Name : "openssl" , Version : "1.1.1d-r2" },
390
- {Name : "libcrypto1.1" , Version : "1.1.1d-r2" },
391
- {Name : "libssl1.1" , Version : "1.1.1d-r2" },
429
+ {Name : "musl" , Version : "1.1.22-r3" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
430
+ {Name : "busybox" , Version : "1.30.1-r3" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
431
+ {Name : "openssl" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
432
+ {Name : "libcrypto1.1" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
433
+ {Name : "libssl1.1" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
392
434
},
393
435
},
394
436
},
@@ -424,11 +466,11 @@ func TestApplier_ApplyLayers(t *testing.T) {
424
466
Name : "3.10.4" ,
425
467
},
426
468
Packages : []types.Package {
427
- {Name : "busybox" , Version : "1.30.1-r3" },
428
- {Name : "libcrypto1.1" , Version : "1.1.1d-r2" },
429
- {Name : "libssl1.1" , Version : "1.1.1d-r2" },
430
- {Name : "musl" , Version : "1.1.22-r3" },
431
- {Name : "openssl" , Version : "1.1.1d-r2" },
469
+ {Name : "busybox" , Version : "1.30.1-r3" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
470
+ {Name : "libcrypto1.1" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
471
+ {Name : "libssl1.1" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
472
+ {Name : "musl" , Version : "1.1.22-r3" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
473
+ {Name : "openssl" , Version : "1.1.1d-r2" , LayerID : "sha256:531743b7098cb2aaf615641007a129173f63ed86ca32fe7b5a246a1c47286028" },
432
474
},
433
475
HistoryPackages : []types.Package {
434
476
{Name : "musl" , Version : "1.1.23" },
@@ -544,7 +586,7 @@ func TestApplier_ApplyLayers(t *testing.T) {
544
586
})
545
587
for _ , app := range got .Applications {
546
588
sort .Slice (app .Libraries , func (i , j int ) bool {
547
- return app .Libraries [i ].Name < app .Libraries [j ].Name
589
+ return app .Libraries [i ].Library . Name < app .Libraries [j ]. Library .Name
548
590
})
549
591
}
550
592
assert .Equal (t , tt .want , got )
0 commit comments