Use cachekey not digest for COPY --from src

* use the cachekey of the src stage rather than the digest
for COPY --from commands as they are reproducible unlike digests
* track digest to cache keys and stage indexes to digest
* add extra debug logging for troubleshooting cachekey building issues
* convert Sha256 hashes to hex encoded strings rather than plain strings
for easier human reading
This commit is contained in:
Cole Wippern
2019-12-10 08:45:13 -08:00
parent 7b4b768edf
commit b19214ad1e
3 changed files with 63 additions and 100 deletions
+3 -2
View File
@@ -18,6 +18,7 @@ package executor
import (
"crypto/sha256"
"fmt"
"os"
"path/filepath"
"strings"
@@ -75,7 +76,7 @@ func (s *CompositeCache) AddPath(p string) error {
return err
}
s.keys = append(s.keys, string(sha.Sum(nil)))
s.keys = append(s.keys, fmt.Sprintf("%x", sha.Sum(nil)))
return nil
}
@@ -98,5 +99,5 @@ func HashDir(p string) (string, error) {
return "", err
}
return string(sha.Sum(nil)), nil
return fmt.Sprintf("%x", sha.Sum(nil)), nil
}