...
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 ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerData LayerData, options ExportLayerOptions) (err error) {
24 title := "hcsshim::ExportLayer"
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("exportFolderPath", exportFolderPath),
31 )
32
33 ldBytes, err := json.Marshal(layerData)
34 if err != nil {
35 return err
36 }
37
38 oBytes, err := json.Marshal(options)
39 if err != nil {
40 return err
41 }
42
43 err = hcsExportLayer(layerPath, exportFolderPath, string(ldBytes), string(oBytes))
44 if err != nil {
45 return errors.Wrap(err, "failed to export layer")
46 }
47 return nil
48 }
49
View as plain text