mirror of
https://github.com/imjasonh/kontain.me
synced 2026-07-20 13:09:22 +00:00
md5ify cache keys
This commit is contained in:
parent
06e4bad278
commit
42d9b1af1b
6 changed files with 12 additions and 10 deletions
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
|
@ -168,7 +169,8 @@ func (s *server) serveBuildpackManifest(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
|
||||
func cacheKey(path, revision string) string {
|
||||
return fmt.Sprintf("kaniko-%s-%s", strings.ReplaceAll(path, "/", "_"), revision)
|
||||
ck := []byte(fmt.Sprintf("%s-%s", strings.ReplaceAll(path, "/", "_"), revision))
|
||||
return fmt.Sprintf("buildpack-%x", md5.Sum(ck))
|
||||
}
|
||||
|
||||
// Resolves a ref (branch, tag, PR, commit) into its SHA.
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@ func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
func cacheKey(orig string) string {
|
||||
return fmt.Sprintf("flatten-%s", orig)
|
||||
}
|
||||
func cacheKey(orig string) string { return fmt.Sprintf("flatten-%s", orig) }
|
||||
|
||||
// flatten.kontain.me/ubuntu -> flatten ubuntu and serve
|
||||
func (s *server) serveFlattenManifest(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -162,7 +162,8 @@ func (s *server) serveKanikoManifest(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func cacheKey(path, revision string) string {
|
||||
return fmt.Sprintf("buildpack-%s-%s", strings.ReplaceAll(path, "/", "_"), revision)
|
||||
ck := fmt.Sprintf("%s-%s", strings.ReplaceAll(path, "/", "_"), revision)
|
||||
return fmt.Sprintf("kaniko-%x", ck)
|
||||
}
|
||||
|
||||
// Resolves a ref (branch, tag, PR, commit) into its SHA.
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func cacheKey(name string) string {
|
||||
ck := []byte(fmt.Sprintf("wait-%s", strings.ReplaceAll(name, "/", "_")))
|
||||
return fmt.Sprintf("%x", md5.Sum(ck))
|
||||
ck := []byte(strings.ReplaceAll(name, "/", "_"))
|
||||
return fmt.Sprintf("wait-%x", md5.Sum(ck))
|
||||
}
|
||||
|
||||
// wait.kontain.me/(name):5s -> enqueue task to generate random manifest in 5s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue