...
1
2
3 package computestorage
4
5 import (
6 "context"
7 "encoding/json"
8
9 "github.com/Microsoft/hcsshim/internal/oc"
10 "github.com/pkg/errors"
11 "go.opencensus.io/trace"
12 )
13
14
15
16
17
18
19
20
21
22
23 func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) {
24 title := "hcsshim::ImportLayer"
25 ctx, span := oc.StartSpan(ctx, title)
26 defer span.End()
27 defer func() { oc.SetSpanStatus(span, err) }()
28 span.AddAttributes(
29 trace.StringAttribute("layerPath", layerPath),
30 trace.StringAttribute("sourceFolderPath", sourceFolderPath),
31 )
32
33 bytes, err := json.Marshal(layerData)
34 if err != nil {
35 return err
36 }
37
38 err = hcsImportLayer(layerPath, sourceFolderPath, string(bytes))
39 if err != nil {
40 return errors.Wrap(err, "failed to import layer")
41 }
42 return nil
43 }
44
View as plain text