destroylayer.go 729 B

12345678910111213141516171819202122232425262728293031
  1. package wclayer
  2. import (
  3. "github.com/Microsoft/hcsshim/internal/hcserror"
  4. "github.com/sirupsen/logrus"
  5. )
  6. // DestroyLayer will remove the on-disk files representing the layer with the given
  7. // path, including that layer's containing folder, if any.
  8. func DestroyLayer(path string) (err error) {
  9. title := "hcsshim::DestroyLayer"
  10. fields := logrus.Fields{
  11. "path": path,
  12. }
  13. logrus.WithFields(fields).Debug(title)
  14. defer func() {
  15. if err != nil {
  16. fields[logrus.ErrorKey] = err
  17. logrus.WithFields(fields).Error(err)
  18. } else {
  19. logrus.WithFields(fields).Debug(title + " - succeeded")
  20. }
  21. }()
  22. err = destroyLayer(&stdDriverInfo, path)
  23. if err != nil {
  24. return hcserror.New(err, title+" - failed", "")
  25. }
  26. return nil
  27. }