From 102a3a451bf62110bee68bc25d6d7f7ebeafcc08 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Fri, 5 May 2023 22:00:58 +0000 Subject: [PATCH] test: add some more compose tests Signed-off-by: Ramkumar Chinchani --- pkg/oci/oci.go | 6 +++--- pkg/overlay/overlay.go | 3 ++- test/import.bats | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/oci/oci.go b/pkg/oci/oci.go index 080a7d07..7ab68cf5 100644 --- a/pkg/oci/oci.go +++ b/pkg/oci/oci.go @@ -85,7 +85,7 @@ func UpdateImageConfig(oci casext.Engine, name string, newConfig ispec.Image, ne return desc, nil } -func unpackOne(ociDir string, bundlePath string, digest digest.Digest, isSquashfs bool) error { +func UnpackOne(ociDir string, bundlePath string, digest digest.Digest, isSquashfs bool) error { if isSquashfs { return squashfs.ExtractSingleSquash( path.Join(ociDir, "blobs", "sha256", digest.Encoded()), @@ -134,7 +134,7 @@ func Unpack(ociLayout, tag string, pathfunc func(digest.Digest) string) (int, er // don't really need to do this in parallel, but what // the hell. pool.Add(func(ctx context.Context) error { - return unpackOne(ociLayout, contents, digest, true) + return UnpackOne(ociLayout, contents, digest, true) }) } else { switch layer.MediaType { @@ -151,7 +151,7 @@ func Unpack(ociLayout, tag string, pathfunc func(digest.Digest) string) (int, er // shifting, we can use the fancier features of context // cancelling in the thread pool... pool.Add(func(ctx context.Context) error { - return unpackOne(ociLayout, contents, digest, false) + return UnpackOne(ociLayout, contents, digest, false) }) default: return -1, errors.Errorf("unknown media type %s", layer.MediaType) diff --git a/pkg/overlay/overlay.go b/pkg/overlay/overlay.go index cbc212f4..cdfe30b3 100644 --- a/pkg/overlay/overlay.go +++ b/pkg/overlay/overlay.go @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "golang.org/x/sys/unix" "stackerbuild.io/stacker/pkg/mount" + "stackerbuild.io/stacker/pkg/oci" "stackerbuild.io/stacker/pkg/squashfs" "stackerbuild.io/stacker/pkg/types" ) @@ -184,7 +185,7 @@ func (o *overlay) snapshot(source string, target string) error { // We have done an unsquashfs of this atom continue } - if err := unpackOne(cacheDir, contents, digest, true); err != nil { + if err := oci.UnpackOne(cacheDir, contents, digest, true); err != nil { return errors.Wrapf(err, "Failed mounting %#v", layer) } } diff --git a/test/import.bats b/test/import.bats index dfbc49c7..54a6bd8e 100644 --- a/test/import.bats +++ b/test/import.bats @@ -405,6 +405,21 @@ cimg-import: dest: / run: | [ -d /var/lib/apk ] + +compose-img: + from: + type: oci + url: $CENTOS_OCI + import: + - path: docker://ghcr.io/homebrew/core/openssl/1.1:1.1.1k + dest: / + - path: docker://ghcr.io/homebrew/core/curl:8.0.1 + dest: / + - path: docker://ghcr.io/homebrew/core/ca-certificates:2022-10-11 + dest: / + run: | + [ -f /curl/8.0.1/bin/curl ] + [ -f /ca-certificates/2022-10-11/share/ca-certificates/cacert.pem ] EOF stacker build }