mirror of
https://github.com/containers/skopeo.git
synced 2025-08-28 11:03:19 +00:00
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.26.0 to 1.29.0. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.26.0...v1.29.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package computestorage
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/Microsoft/hcsshim/internal/oc"
|
|
"github.com/pkg/errors"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// ImportLayer imports a container layer.
|
|
//
|
|
// `layerPath` is a path to a directory to import the layer to. If the directory
|
|
// does not exist it will be automatically created.
|
|
//
|
|
// `sourceFolderpath` is a pre-existing folder that contains the layer to
|
|
// import.
|
|
//
|
|
// `layerData` is the parent layer data.
|
|
func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) {
|
|
title := "hcsshim.ImportLayer"
|
|
ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
|
|
defer span.End()
|
|
defer func() { oc.SetSpanStatus(span, err) }()
|
|
span.AddAttributes(
|
|
trace.StringAttribute("layerPath", layerPath),
|
|
trace.StringAttribute("sourceFolderPath", sourceFolderPath),
|
|
)
|
|
|
|
bytes, err := json.Marshal(layerData)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = hcsImportLayer(layerPath, sourceFolderPath, string(bytes))
|
|
if err != nil {
|
|
return errors.Wrap(err, "failed to import layer")
|
|
}
|
|
return nil
|
|
}
|