feat(clean): log removed/untagged images (#1466)

This commit is contained in:
nils måsén 2023-04-15 12:56:51 +02:00 committed by GitHub
parent dd1ec09668
commit 0a5bd54fb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 143 additions and 9 deletions

View file

@ -0,0 +1,24 @@
package util
import (
"bytes"
"fmt"
"math/rand"
)
// GenerateRandomSHA256 generates a random 64 character SHA 256 hash string
func GenerateRandomSHA256() string {
return GenerateRandomPrefixedSHA256()[7:]
}
// GenerateRandomPrefixedSHA256 generates a random 64 character SHA 256 hash string, prefixed with `sha256:`
func GenerateRandomPrefixedSHA256() string {
hash := make([]byte, 32)
_, _ = rand.Read(hash)
sb := bytes.NewBufferString("sha256:")
sb.Grow(64)
for _, h := range hash {
_, _ = fmt.Fprintf(sb, "%02x", h)
}
return sb.String()
}