func (c Container) ImageInfo() *types.ImageInspect {
	return c.imageInfo
}
ImageInfo fetches the ImageInspect data of the current container
package container
import (
	"fmt"
	"strconv"
	"strings"
	"github.com/containrrr/watchtower/internal/util"
	wt "github.com/containrrr/watchtower/pkg/types"
	"github.com/docker/docker/api/types"
	dockercontainer "github.com/docker/docker/api/types/container"
)
func NewContainer(containerInfo *types.ContainerJSON, imageInfo *types.ImageInspect) *Container {
	return &Container{
		containerInfo: containerInfo,
		imageInfo:     imageInfo,
	}
}
type Container struct {
	LinkedToRestarting bool
	Stale              bool
	containerInfo *types.ContainerJSON
	imageInfo     *types.ImageInspect
}
func (c Container) ContainerInfo() *types.ContainerJSON {
	return c.containerInfo
}
func (c Container) ID() wt.ContainerID {
	return wt.ContainerID(c.containerInfo.ID)
}
func (c Container) IsRunning() bool {
	return c.containerInfo.State.Running
}
func (c Container) IsRestarting() bool {
	return c.containerInfo.State.Restarting
}
func (c Container) Name() string {
	return c.containerInfo.Name
}
func (c Container) ImageID() wt.ImageID {
	return wt.ImageID(c.imageInfo.ID)
}
func (c Container) SafeImageID() wt.ImageID {
	if c.imageInfo == nil {
		return ""
	}
	return wt.ImageID(c.imageInfo.ID)
}
func (c Container) ImageName() string {
	imageName, ok := c.getLabelValue(zodiacLabel)
	if !ok {
		imageName = c.containerInfo.Config.Image
	}
	if !strings.Contains(imageName, ":") {
		imageName = fmt.Sprintf("%s:latest", imageName)
	}
	return imageName
}
func (c Container) Enabled() (bool, bool) {
	rawBool, ok := c.getLabelValue(enableLabel)
	if !ok {
		return false, false
	}
	parsedBool, err := strconv.ParseBool(rawBool)
	if err != nil {
		return false, false
	}
	return parsedBool, true
}
func (c Container) IsMonitorOnly() bool {
	rawBool, ok := c.getLabelValue(monitorOnlyLabel)
	if !ok {
		return false
	}
	parsedBool, err := strconv.ParseBool(rawBool)
	if err != nil {
		return false
	}
	return parsedBool
}
func (c Container) Scope() (string, bool) {
	rawString, ok := c.getLabelValue(scope)
	if !ok {
		return "", false
	}
	return rawString, true
}
func (c Container) Links() []string {
	var links []string
	dependsOnLabelValue := c.getLabelValueOrEmpty(dependsOnLabel)
	if dependsOnLabelValue != "" {
		links := strings.Split(dependsOnLabelValue, ",")
		return links
	}
	if (c.containerInfo != nil) && (c.containerInfo.HostConfig != nil) {
		for _, link := range c.containerInfo.HostConfig.Links {
			name := strings.Split(link, ":")[0]
			links = append(links, name)
		}
	}
	return links
}
func (c Container) ToRestart() bool {
	return c.Stale || c.LinkedToRestarting
}
func (c Container) IsWatchtower() bool {
	return ContainsWatchtowerLabel(c.containerInfo.Config.Labels)
}
func (c Container) PreUpdateTimeout() int {
	var minutes int
	var err error
	val := c.getLabelValueOrEmpty(preUpdateTimeoutLabel)
	minutes, err = strconv.Atoi(val)
	if err != nil || val == "" {
		return 1
	}
	return minutes
}
func (c Container) StopSignal() string {
	return c.getLabelValueOrEmpty(signalLabel)
}
func (c Container) runtimeConfig() *dockercontainer.Config {
	config := c.containerInfo.Config
	hostConfig := c.containerInfo.HostConfig
	imageConfig := c.imageInfo.Config
	if config.WorkingDir == imageConfig.WorkingDir {
		config.WorkingDir = ""
	}
	if config.User == imageConfig.User {
		config.User = ""
	}
	if hostConfig.NetworkMode.IsContainer() {
		config.Hostname = ""
	}
	if util.SliceEqual(config.Entrypoint, imageConfig.Entrypoint) {
		config.Entrypoint = nil
		if util.SliceEqual(config.Cmd, imageConfig.Cmd) {
			config.Cmd = nil
		}
	}
	config.Env = util.SliceSubtract(config.Env, imageConfig.Env)
	config.Labels = util.StringMapSubtract(config.Labels, imageConfig.Labels)
	config.Volumes = util.StructMapSubtract(config.Volumes, imageConfig.Volumes)
	for k := range config.ExposedPorts {
		if _, ok := imageConfig.ExposedPorts[k]; ok {
			delete(config.ExposedPorts, k)
		}
	}
	for p := range c.containerInfo.HostConfig.PortBindings {
		config.ExposedPorts[p] = struct{}{}
	}
	config.Image = c.ImageName()
	return config
}
func (c Container) hostConfig() *dockercontainer.HostConfig {
	hostConfig := c.containerInfo.HostConfig
	for i, link := range hostConfig.Links {
		name := link[0:strings.Index(link, ":")]
		alias := link[strings.LastIndex(link, "/"):]
		hostConfig.Links[i] = fmt.Sprintf("%s:%s", name, alias)
	}
	return hostConfig
}
func (c Container) HasImageInfo() bool {
	return c.imageInfo != nil
}