Skip to content

Commit

Permalink
test: add some more compose tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha committed Sep 11, 2023
1 parent 64a6d2f commit 102a3a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/import.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 102a3a4

Please sign in to comment.