mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
feat: check container config before update (#925)
* feat: check container config before restart * fix: only skip when hostconfig and config differ * fix: update test mocks to not fail tests * test: add verify config tests
This commit is contained in:
parent
fdf6e46e7b
commit
12467712a1
6 changed files with 151 additions and 13 deletions
|
@ -258,3 +258,32 @@ func (c Container) HasImageInfo() bool {
|
|||
func (c Container) ImageInfo() *types.ImageInspect {
|
||||
return c.imageInfo
|
||||
}
|
||||
|
||||
// VerifyConfiguration checks the container and image configurations for nil references to make sure
|
||||
// that the container can be recreated once deleted
|
||||
func (c Container) VerifyConfiguration() error {
|
||||
if c.imageInfo == nil {
|
||||
return errorNoImageInfo
|
||||
}
|
||||
|
||||
containerInfo := c.ContainerInfo()
|
||||
if containerInfo == nil {
|
||||
return errorInvalidConfig
|
||||
}
|
||||
|
||||
containerConfig := containerInfo.Config
|
||||
if containerConfig == nil {
|
||||
return errorInvalidConfig
|
||||
}
|
||||
|
||||
hostConfig := containerInfo.HostConfig
|
||||
if hostConfig == nil {
|
||||
return errorInvalidConfig
|
||||
}
|
||||
|
||||
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil {
|
||||
return errorNoExposedPorts
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue