layerid.go 573 B

123456789101112131415161718192021222324
  1. //go:build windows
  2. package wclayer
  3. import (
  4. "context"
  5. "path/filepath"
  6. "github.com/Microsoft/go-winio/pkg/guid"
  7. "github.com/Microsoft/hcsshim/internal/oc"
  8. "go.opencensus.io/trace"
  9. )
  10. // LayerID returns the layer ID of a layer on disk.
  11. func LayerID(ctx context.Context, path string) (_ guid.GUID, err error) {
  12. title := "hcsshim::LayerID"
  13. ctx, span := oc.StartSpan(ctx, title)
  14. defer span.End()
  15. defer func() { oc.SetSpanStatus(span, err) }()
  16. span.AddAttributes(trace.StringAttribute("path", path))
  17. _, file := filepath.Split(path)
  18. return NameToGuid(ctx, file)
  19. }