createlayer.go 760 B

1234567891011121314151617181920212223242526272829
  1. //go:build windows
  2. package wclayer
  3. import (
  4. "context"
  5. "github.com/Microsoft/hcsshim/internal/hcserror"
  6. "github.com/Microsoft/hcsshim/internal/oc"
  7. "go.opencensus.io/trace"
  8. )
  9. // CreateLayer creates a new, empty, read-only layer on the filesystem based on
  10. // the parent layer provided.
  11. func CreateLayer(ctx context.Context, path, parent string) (err error) {
  12. title := "hcsshim::CreateLayer"
  13. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  14. defer span.End()
  15. defer func() { oc.SetSpanStatus(span, err) }()
  16. span.AddAttributes(
  17. trace.StringAttribute("path", path),
  18. trace.StringAttribute("parent", parent))
  19. err = createLayer(&stdDriverInfo, path, parent)
  20. if err != nil {
  21. return hcserror.New(err, title, "")
  22. }
  23. return nil
  24. }