Use packageImage as builder image fingerprint

This allows to have an unique identifier for the builder image id against
different depgraphs combinations. The package fingerprint is not enough,
as an atom could have a difference deptree depending on the requires
constraints.

TODO: Don't use the full image name, but only the hash as a salt
(currently the salt contains ALSO a reference of the image-repository,
as such it doesn't allow to port a tree in a different docker registry)
This commit is contained in:
Ettore Di Giacinto
2020-06-23 18:44:29 +02:00
parent ee3b59348e
commit 16e9d7b20c
4 changed files with 25 additions and 10 deletions

View File

@@ -105,7 +105,7 @@ type Package interface {
String() string
HumanReadableString() string
HashFingerprint() string
HashFingerprint(string) string
Clone() Package
}
@@ -205,9 +205,9 @@ func (p *DefaultPackage) GetFingerPrint() string {
return fmt.Sprintf("%s-%s-%s", p.Name, p.Category, p.Version)
}
func (p *DefaultPackage) HashFingerprint() string {
func (p *DefaultPackage) HashFingerprint(salt string) string {
h := md5.New()
io.WriteString(h, p.GetFingerPrint())
io.WriteString(h, fmt.Sprintf("%s-%s",p.GetFingerPrint(),salt))
return fmt.Sprintf("%x", h.Sum(nil))
}