k3s/vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go

23 lines
556 B
Go
Raw Normal View History

2019-01-12 04:58:27 +00:00
package wclayer
import (
2020-08-10 17:43:49 +00:00
"context"
2019-01-12 04:58:27 +00:00
"path/filepath"
2019-09-30 23:25:17 +00:00
"github.com/Microsoft/go-winio/pkg/guid"
2020-08-10 17:43:49 +00:00
"github.com/Microsoft/hcsshim/internal/oc"
"go.opencensus.io/trace"
2019-01-12 04:58:27 +00:00
)
// LayerID returns the layer ID of a layer on disk.
2020-08-10 17:43:49 +00:00
func LayerID(ctx context.Context, path string) (_ guid.GUID, err error) {
title := "hcsshim::LayerID"
ctx, span := trace.StartSpan(ctx, title)
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(trace.StringAttribute("path", path))
2019-01-12 04:58:27 +00:00
_, file := filepath.Split(path)
2020-08-10 17:43:49 +00:00
return NameToGuid(ctx, file)
2019-01-12 04:58:27 +00:00
}