2018-09-05 14:54:38 -04:00
|
|
|
package wclayer
|
|
|
|
|
|
|
|
import (
|
2020-05-09 11:16:54 -04:00
|
|
|
"context"
|
2018-09-05 14:54:38 -04:00
|
|
|
"path/filepath"
|
|
|
|
|
2020-01-06 12:15:00 -05:00
|
|
|
"github.com/Microsoft/go-winio/pkg/guid"
|
2020-05-09 11:16:54 -04:00
|
|
|
"github.com/Microsoft/hcsshim/internal/oc"
|
|
|
|
"go.opencensus.io/trace"
|
2018-09-05 14:54:38 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// LayerID returns the layer ID of a layer on disk.
|
2020-05-09 11:16:54 -04: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))
|
|
|
|
|
2018-09-05 14:54:38 -04:00
|
|
|
_, file := filepath.Split(path)
|
2020-05-09 11:16:54 -04:00
|
|
|
return NameToGuid(ctx, file)
|
2018-09-05 14:54:38 -04:00
|
|
|
}
|