destroy.go 713 B

12345678910111213141516171819202122232425262728
  1. //go:build windows
  2. package computestorage
  3. import (
  4. "context"
  5. "github.com/Microsoft/hcsshim/internal/oc"
  6. "github.com/pkg/errors"
  7. "go.opencensus.io/trace"
  8. )
  9. // DestroyLayer deletes a container layer.
  10. //
  11. // `layerPath` is a path to a directory containing the layer to export.
  12. func DestroyLayer(ctx context.Context, layerPath string) (err error) {
  13. title := "hcsshim::DestroyLayer"
  14. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  15. defer span.End()
  16. defer func() { oc.SetSpanStatus(span, err) }()
  17. span.AddAttributes(trace.StringAttribute("layerPath", layerPath))
  18. err = hcsDestroyLayer(layerPath)
  19. if err != nil {
  20. return errors.Wrap(err, "failed to destroy layer")
  21. }
  22. return nil
  23. }