...

Source file src/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go

Documentation: github.com/Microsoft/hcsshim/internal/wclayer

     1  //go:build windows
     2  
     3  package wclayer
     4  
     5  import (
     6  	"context"
     7  
     8  	"github.com/Microsoft/hcsshim/internal/hcserror"
     9  	"github.com/Microsoft/hcsshim/internal/oc"
    10  	"go.opencensus.io/trace"
    11  )
    12  
    13  // LayerExists will return true if a layer with the given id exists and is known
    14  // to the system.
    15  func LayerExists(ctx context.Context, path string) (_ bool, err error) {
    16  	title := "hcsshim::LayerExists"
    17  	ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
    18  	defer span.End()
    19  	defer func() { oc.SetSpanStatus(span, err) }()
    20  	span.AddAttributes(trace.StringAttribute("path", path))
    21  
    22  	// Call the procedure itself.
    23  	var exists uint32
    24  	err = layerExists(&stdDriverInfo, path, &exists)
    25  	if err != nil {
    26  		return false, hcserror.New(err, title, "")
    27  	}
    28  	span.AddAttributes(trace.BoolAttribute("layer-exists", exists != 0))
    29  	return exists != 0, nil
    30  }
    31  

View as plain text