mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-09 01:11:45 +02:00
code review comments
This commit is contained in:
@@ -27,10 +27,11 @@ import (
|
||||
)
|
||||
|
||||
type LayeredMap struct {
|
||||
layers []map[string]string
|
||||
whiteouts []map[string]string
|
||||
added []map[string]string
|
||||
hasher func(string) (string, error)
|
||||
layers []map[string]string
|
||||
whiteouts []map[string]string
|
||||
added []map[string]string
|
||||
hasher func(string) (string, error)
|
||||
// cacheHasher doesn't include mtime in it's hash so that filesystem cache keys are stable
|
||||
cacheHasher func(string) (string, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,15 @@ func Test_CacheKey(t *testing.T) {
|
||||
"a": "apple",
|
||||
"b": "bat",
|
||||
"c": "cat",
|
||||
"d": "dog",
|
||||
"e": "egg",
|
||||
},
|
||||
map2: map[string]string{
|
||||
"c": "cat",
|
||||
"d": "dog",
|
||||
"b": "bat",
|
||||
"a": "apple",
|
||||
"e": "egg",
|
||||
},
|
||||
equal: true,
|
||||
},
|
||||
@@ -67,11 +71,8 @@ func Test_CacheKey(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("error getting key for map 2: %v", err)
|
||||
}
|
||||
if test.equal && k1 != k2 {
|
||||
t.Fatalf("keys differ.\nExpected\n%+v\nActual\n%+v", k1, k2)
|
||||
}
|
||||
if !test.equal && k1 == k2 {
|
||||
t.Fatal("keys are the same, expected different keys")
|
||||
if test.equal != (k1 == k2) {
|
||||
t.Fatalf("unexpected result: \nExpected\n%s\nActual\n%s\n", k1, k2)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+4
-1
@@ -122,5 +122,8 @@ func MtimeHasher() func(string) (string, error) {
|
||||
func SHA256(r io.Reader) (string, error) {
|
||||
hasher := sha256.New()
|
||||
_, err := io.Copy(hasher, r)
|
||||
return hex.EncodeToString(hasher.Sum(make([]byte, 0, hasher.Size()))), err
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return hex.EncodeToString(hasher.Sum(make([]byte, 0, hasher.Size()))), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user