processimage.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //go:build windows
  2. package wclayer
  3. import (
  4. "context"
  5. "os"
  6. "github.com/Microsoft/hcsshim/internal/oc"
  7. "go.opencensus.io/trace"
  8. )
  9. // ProcessBaseLayer post-processes a base layer that has had its files extracted.
  10. // The files should have been extracted to <path>\Files.
  11. func ProcessBaseLayer(ctx context.Context, path string) (err error) {
  12. title := "hcsshim::ProcessBaseLayer"
  13. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  14. defer span.End()
  15. defer func() { oc.SetSpanStatus(span, err) }()
  16. span.AddAttributes(trace.StringAttribute("path", path))
  17. err = processBaseImage(path)
  18. if err != nil {
  19. return &os.PathError{Op: title, Path: path, Err: err}
  20. }
  21. return nil
  22. }
  23. // ProcessUtilityVMImage post-processes a utility VM image that has had its files extracted.
  24. // The files should have been extracted to <path>\Files.
  25. func ProcessUtilityVMImage(ctx context.Context, path string) (err error) {
  26. title := "hcsshim::ProcessUtilityVMImage"
  27. ctx, span := oc.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
  28. defer span.End()
  29. defer func() { oc.SetSpanStatus(span, err) }()
  30. span.AddAttributes(trace.StringAttribute("path", path))
  31. err = processUtilityImage(path)
  32. if err != nil {
  33. return &os.PathError{Op: title, Path: path, Err: err}
  34. }
  35. return nil
  36. }