createscratchlayer.go 1004 B

123456789101112131415161718192021222324252627282930313233343536
  1. //go:build windows
  2. package wclayer
  3. import (
  4. "context"
  5. "strings"
  6. "github.com/Microsoft/hcsshim/internal/hcserror"
  7. "github.com/Microsoft/hcsshim/internal/oc"
  8. "go.opencensus.io/trace"
  9. )
  10. // CreateScratchLayer creates and populates new read-write layer for use by a container.
  11. // This requires the full list of paths to all parent layers up to the base
  12. func CreateScratchLayer(ctx context.Context, path string, parentLayerPaths []string) (err error) {
  13. title := "hcsshim::CreateScratchLayer"
  14. ctx, span := oc.StartSpan(ctx, title)
  15. defer span.End()
  16. defer func() { oc.SetSpanStatus(span, err) }()
  17. span.AddAttributes(
  18. trace.StringAttribute("path", path),
  19. trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", ")))
  20. // Generate layer descriptors
  21. layers, err := layerPathsToDescriptors(ctx, parentLayerPaths)
  22. if err != nil {
  23. return err
  24. }
  25. err = createSandboxLayer(&stdDriverInfo, path, 0, layers)
  26. if err != nil {
  27. return hcserror.New(err, title, "")
  28. }
  29. return nil
  30. }