Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion lib/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"os"
"path"
"testing"
"time"

ispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/umoci"
"github.com/opencontainers/umoci/mutate"
"github.com/opencontainers/umoci/oci/casext"
stackeroci "github.com/project-stacker/stacker/oci"
"github.com/project-stacker/stacker/squashfs"
Expand All @@ -36,14 +38,35 @@ func createImage(dir string, tag string) error {
return err
}

descPaths, err := oci.ResolveReference(context.Background(), tag)
if err != nil {
return err
}

mutator, err := mutate.New(oci, descPaths[0])
if err != nil {
return err
}

// need *something* in the layer, why not just recursively include the
// OCI image for maximum confusion :)
layer, err := squashfs.MakeSquashfs(dir, path.Join(dir, "oci"), nil)
if err != nil {
return err
}

_, err = stackeroci.AddBlobNoCompression(oci, tag, layer)
now := time.Now()
history := &ispec.History{
Created: &now,
CreatedBy: fmt.Sprintf("stacker test suite %s", tag),
EmptyLayer: false,
}
_, err = mutator.Add(context.Background(), stackeroci.MediaTypeLayerSquashfs, layer, history, mutate.NoopCompressor)
if err != nil {
return err
}

_, err = mutator.Commit(context.Background())
if err != nil {
return err
}
Expand Down