Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 7 additions & 9 deletions pkg/ociwclayer/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,35 @@ import (
"path/filepath"

"github.com/Microsoft/go-winio/backuptar"
"github.com/Microsoft/hcsshim"
"github.com/Microsoft/hcsshim/internal/wclayer"
)

var driverInfo = hcsshim.DriverInfo{}

// ExportLayerToTar writes an OCI layer tar stream from the provided on-disk layer.
// The caller must specify the parent layers, if any, ordered from lowest to
// highest layer.
//
// The layer will be mounted for this process, so the caller should ensure that
// it is not currently mounted.
func ExportLayerToTar(ctx context.Context, w io.Writer, path string, parentLayerPaths []string) error {
err := hcsshim.ActivateLayer(driverInfo, path)
err := wclayer.ActivateLayer(ctx, path)
if err != nil {
return err
}
defer func() {
_ = hcsshim.DeactivateLayer(driverInfo, path)
_ = wclayer.DeactivateLayer(ctx, path)
}()

// Prepare and unprepare the layer to ensure that it has been initialized.
err = hcsshim.PrepareLayer(driverInfo, path, parentLayerPaths)
err = wclayer.PrepareLayer(ctx, path, parentLayerPaths)
if err != nil {
return err
}
err = hcsshim.UnprepareLayer(driverInfo, path)
err = wclayer.UnprepareLayer(ctx, path)
if err != nil {
return err
}

r, err := hcsshim.NewLayerReader(driverInfo, path, parentLayerPaths)
r, err := wclayer.NewLayerReader(ctx, path, parentLayerPaths)
if err != nil {
return err
}
Expand All @@ -52,7 +50,7 @@ func ExportLayerToTar(ctx context.Context, w io.Writer, path string, parentLayer
return cerr
}

func writeTarFromLayer(ctx context.Context, r hcsshim.LayerReader, w io.Writer) error {
func writeTarFromLayer(ctx context.Context, r wclayer.LayerReader, w io.Writer) error {
t := tar.NewWriter(w)
for {
select {
Expand Down
6 changes: 3 additions & 3 deletions pkg/ociwclayer/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

winio "github.com/Microsoft/go-winio"
"github.com/Microsoft/go-winio/backuptar"
"github.com/Microsoft/hcsshim"
"github.com/Microsoft/hcsshim/internal/wclayer"
)

const whiteoutPrefix = ".wh."
Expand Down Expand Up @@ -43,7 +43,7 @@ func ImportLayerFromTar(ctx context.Context, r io.Reader, path string, parentLay
if err != nil {
return 0, err
}
w, err := hcsshim.NewLayerWriter(hcsshim.DriverInfo{}, path, parentLayerPaths)
w, err := wclayer.NewLayerWriter(ctx, path, parentLayerPaths)
if err != nil {
return 0, err
}
Expand All @@ -58,7 +58,7 @@ func ImportLayerFromTar(ctx context.Context, r io.Reader, path string, parentLay
return n, nil
}

func writeLayerFromTar(ctx context.Context, r io.Reader, w hcsshim.LayerWriter, root string) (int64, error) {
func writeLayerFromTar(ctx context.Context, r io.Reader, w wclayer.LayerWriter, root string) (int64, error) {
t := tar.NewReader(r)
hdr, err := t.Next()
totalSize := int64(0)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.