...

Source file src/github.com/Microsoft/hcsshim/computestorage/attach.go

Documentation: github.com/Microsoft/hcsshim/computestorage

     1  //go:build windows
     2  
     3  package computestorage
     4  
     5  import (
     6  	"context"
     7  	"encoding/json"
     8  
     9  	"github.com/Microsoft/hcsshim/internal/oc"
    10  	"github.com/pkg/errors"
    11  	"go.opencensus.io/trace"
    12  )
    13  
    14  // AttachLayerStorageFilter sets up the layer storage filter on a writable
    15  // container layer.
    16  //
    17  // `layerPath` is a path to a directory the writable layer is mounted. If the
    18  // path does not end in a `\` the platform will append it automatically.
    19  //
    20  // `layerData` is the parent read-only layer data.
    21  func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData LayerData) (err error) {
    22  	title := "hcsshim::AttachLayerStorageFilter"
    23  	ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
    24  	defer span.End()
    25  	defer func() { oc.SetSpanStatus(span, err) }()
    26  	span.AddAttributes(
    27  		trace.StringAttribute("layerPath", layerPath),
    28  	)
    29  
    30  	bytes, err := json.Marshal(layerData)
    31  	if err != nil {
    32  		return err
    33  	}
    34  
    35  	err = hcsAttachLayerStorageFilter(layerPath, string(bytes))
    36  	if err != nil {
    37  		return errors.Wrap(err, "failed to attach layer storage filter")
    38  	}
    39  	return nil
    40  }
    41  

View as plain text