diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 1d242863..fc55870e 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -265,11 +265,12 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage } } + fp := p.GetPackage().HashFingerprint() if buildertaggedImage == "" { - buildertaggedImage = cs.ImageRepository + "-" + p.GetPackage().GetFingerPrint() + "-builder" + buildertaggedImage = cs.ImageRepository + "-" + fp + "-builder" } if packageImage == "" { - packageImage = cs.ImageRepository + "-" + p.GetPackage().GetFingerPrint() + packageImage = cs.ImageRepository + "-" + fp } Info(pkgTag, "Generating :whale: definition for builder image from", image) diff --git a/pkg/package/package.go b/pkg/package/package.go index e2b36ac5..a3a09308 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -17,8 +17,10 @@ package pkg import ( "bytes" + "crypto/md5" "encoding/json" "fmt" + "io" "path/filepath" "sort" "strings" @@ -88,6 +90,7 @@ type Package interface { String() string HumanReadableString() string + HashFingerprint() string } type Tree interface { @@ -174,6 +177,12 @@ func (p *DefaultPackage) GetFingerPrint() string { return fmt.Sprintf("%s-%s-%s", p.Name, p.Category, p.Version) } +func (p *DefaultPackage) HashFingerprint() string { + h := md5.New() + io.WriteString(h, p.GetFingerPrint()) + return fmt.Sprintf("%x", h.Sum(nil)) +} + func (p *DefaultPackage) HumanReadableString() string { return fmt.Sprintf("%s/%s-%s", p.Category, p.Name, p.Version) }