func (list *ContainerImageList) ContainsImage(img *ContainerImage, checkVersion bool) *ContainerImage {
	if img.KustomizeImage != nil {
		if kustomizeMatch := list.ContainsImage(img.KustomizeImage, checkVersion); kustomizeMatch != nil {
			return kustomizeMatch
		}
	}
	for _, image := range *list {
		if img.ImageName == image.ImageName && image.RegistryURL == img.RegistryURL {
			if !checkVersion || image.ImageTag.TagName == img.ImageTag.TagName {
				return image
			}
		}
	}
	return nil
}
ContainsImage checks whether img is contained in a list of images
package image
import (
	"strings"
	"time"
	"github.com/argoproj-labs/argocd-image-updater/pkg/tag"
	"github.com/distribution/distribution/v3/reference"
)
type ContainerImage struct {
	RegistryURL           string
	ImageName             string
	ImageTag              *tag.ImageTag
	ImageAlias            string
	HelmParamImageName    string
	HelmParamImageVersion string
	KustomizeImage        *ContainerImage
	original              string
}
type ContainerImageList []*ContainerImage
func NewFromIdentifier(identifier string) *ContainerImage {
	imgRef := identifier
	alias := ""
	if strings.Contains(identifier, "=") {
		n := strings.SplitN(identifier, "=", 2)
		imgRef = n[1]
		alias = n[0]
	}
	if parsed, err := reference.ParseNormalizedNamed(imgRef); err == nil {
		img := ContainerImage{}
		img.RegistryURL = reference.Domain(parsed)
		if img.RegistryURL == "docker.io" && !strings.HasPrefix(imgRef, "docker.io") {
			img.RegistryURL = ""
		}
		img.ImageAlias = alias
		img.ImageName = reference.Path(parsed)
		if !strings.HasPrefix(imgRef, "library/") {
			img.ImageName = strings.TrimPrefix(img.ImageName, "library/")
		}
		if digested, ok := parsed.(reference.Digested); ok {
			img.ImageTag = &tag.ImageTag{
				TagDigest: string(digested.Digest()),
			}
		} else if tagged, ok := parsed.(reference.Tagged); ok {
			img.ImageTag = &tag.ImageTag{
				TagName: tagged.Tag(),
			}
		}
		img.original = identifier
		return &img
	}
	img := ContainerImage{}
	img.RegistryURL = getRegistryFromIdentifier(identifier)
	img.ImageAlias, img.ImageName, img.ImageTag = getImageTagFromIdentifier(identifier)
	img.original = identifier
	return &img
}
func (img *ContainerImage) String() string {
	str := ""
	if img.ImageAlias != "" {
		str += img.ImageAlias
		str += "="
	}
	str += img.GetFullNameWithTag()
	return str
}
func (img *ContainerImage) GetFullNameWithoutTag() string {
	str := ""
	if img.RegistryURL != "" {
		str += img.RegistryURL + "/"
	}
	str += img.ImageName
	return str
}
func (img *ContainerImage) GetFullNameWithTag() string {
	str := ""
	if img.RegistryURL != "" {
		str += img.RegistryURL + "/"
	}
	str += img.ImageName
	if img.ImageTag != nil {
		if img.ImageTag.TagDigest != "" {
			str += "@"
			str += img.ImageTag.TagDigest
		} else if img.ImageTag.TagName != "" {
			str += ":"
			str += img.ImageTag.TagName
		}
	}
	return str
}
func (img *ContainerImage) Original() string {
	return img.original
}
func (img *ContainerImage) IsUpdatable(newTag, tagSpec string) bool {
	return false
}
func (img *ContainerImage) WithTag(newTag *tag.ImageTag) *ContainerImage {
	nimg := &ContainerImage{}
	nimg.RegistryURL = img.RegistryURL
	nimg.ImageName = img.ImageName
	nimg.ImageTag = newTag
	nimg.ImageAlias = img.ImageAlias
	nimg.HelmParamImageName = img.HelmParamImageName
	nimg.HelmParamImageVersion = img.HelmParamImageVersion
	return nimg
}
func (img *ContainerImage) DiffersFrom(other *ContainerImage, checkVersion bool) bool {
	return img.RegistryURL != other.RegistryURL || img.ImageName != other.ImageName || (checkVersion && img.ImageTag.TagName != other.ImageTag.TagName)
}