...
1
2
3 package wclayer
4
5 import (
6 "context"
7 "strings"
8 "sync"
9
10 "github.com/Microsoft/hcsshim/internal/hcserror"
11 "github.com/Microsoft/hcsshim/internal/oc"
12 "go.opencensus.io/trace"
13 )
14
15 var prepareLayerLock sync.Mutex
16
17
18
19
20
21
22 func PrepareLayer(ctx context.Context, path string, parentLayerPaths []string) (err error) {
23 title := "hcsshim::PrepareLayer"
24 ctx, span := oc.StartSpan(ctx, title)
25 defer span.End()
26 defer func() { oc.SetSpanStatus(span, err) }()
27 span.AddAttributes(
28 trace.StringAttribute("path", path),
29 trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", ")))
30
31
32 layers, err := layerPathsToDescriptors(ctx, parentLayerPaths)
33 if err != nil {
34 return err
35 }
36
37
38
39 prepareLayerLock.Lock()
40 defer prepareLayerLock.Unlock()
41 err = prepareLayer(&stdDriverInfo, path, layers)
42 if err != nil {
43 return hcserror.New(err, title, "")
44 }
45 return nil
46 }
47
View as plain text