grantvmaccess.go 706 B

12345678910111213141516171819202122232425262728
  1. //go:build windows
  2. package wclayer
  3. import (
  4. "context"
  5. "github.com/Microsoft/hcsshim/internal/hcserror"
  6. "github.com/Microsoft/hcsshim/internal/oc"
  7. "go.opencensus.io/trace"
  8. )
  9. // GrantVmAccess adds access to a file for a given VM
  10. func GrantVmAccess(ctx context.Context, vmid string, filepath string) (err error) {
  11. title := "hcsshim::GrantVmAccess"
  12. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  13. defer span.End()
  14. defer func() { oc.SetSpanStatus(span, err) }()
  15. span.AddAttributes(
  16. trace.StringAttribute("vm-id", vmid),
  17. trace.StringAttribute("path", filepath))
  18. err = grantVmAccess(vmid, filepath)
  19. if err != nil {
  20. return hcserror.New(err, title, "")
  21. }
  22. return nil
  23. }