2015-05-27 13:15:14 -07:00
|
|
|
package hcsshim
|
|
|
|
|
2017-07-26 15:03:47 -07:00
|
|
|
import "github.com/sirupsen/logrus"
|
2015-05-27 13:15:14 -07:00
|
|
|
|
2015-08-27 15:46:00 -07:00
|
|
|
// LayerExists will return true if a layer with the given id exists and is known
|
|
|
|
// to the system.
|
2015-05-27 13:15:14 -07:00
|
|
|
func LayerExists(info DriverInfo, id string) (bool, error) {
|
|
|
|
title := "hcsshim::LayerExists "
|
2015-10-12 16:34:03 -07:00
|
|
|
logrus.Debugf(title+"Flavour %d ID %s", info.Flavour, id)
|
2015-05-27 13:15:14 -07:00
|
|
|
|
|
|
|
// Convert info to API calling convention
|
|
|
|
infop, err := convertDriverInfo(info)
|
|
|
|
if err != nil {
|
|
|
|
logrus.Error(err)
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the procedure itself.
|
2016-02-01 23:09:35 +00:00
|
|
|
var exists uint32
|
2015-05-27 13:15:14 -07:00
|
|
|
|
2016-02-01 23:09:35 +00:00
|
|
|
err = layerExists(&infop, id, &exists)
|
|
|
|
if err != nil {
|
|
|
|
err = makeErrorf(err, title, "id=%s flavour=%d", id, info.Flavour)
|
2015-05-27 13:15:14 -07:00
|
|
|
logrus.Error(err)
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
2015-10-12 16:34:03 -07:00
|
|
|
logrus.Debugf(title+"succeeded flavour=%d id=%s exists=%d", info.Flavour, id, exists)
|
2016-02-01 23:09:35 +00:00
|
|
|
return exists != 0, nil
|
2015-05-27 13:15:14 -07:00
|
|
|
}
|