layerexists.go 786 B

123456789101112131415161718192021222324252627282930
  1. package hcsshim
  2. import "github.com/Sirupsen/logrus"
  3. // LayerExists will return true if a layer with the given id exists and is known
  4. // to the system.
  5. func LayerExists(info DriverInfo, id string) (bool, error) {
  6. title := "hcsshim::LayerExists "
  7. logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
  8. // Convert info to API calling convention
  9. infop, err := convertDriverInfo(info)
  10. if err != nil {
  11. logrus.Error(err)
  12. return false, err
  13. }
  14. // Call the procedure itself.
  15. var exists uint32
  16. err = layerExists(&infop, id, &exists)
  17. if err != nil {
  18. err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
  19. logrus.Error(err)
  20. return false, err
  21. }
  22. logrus.Debugf(title+"succeeded flavour=%d id=%s exists=%d", info.Flavour, id, exists)
  23. return exists != 0, nil
  24. }