1
0
Fork 0
mirror of https://github.com/imjasonh/kontain.me synced 2026-07-08 00:55:14 +00:00

md5ify cache keys

This commit is contained in:
Jason Hall 2021-01-02 10:33:12 -05:00
parent 06e4bad278
commit 42d9b1af1b
6 changed files with 12 additions and 10 deletions

View file

@ -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.

View file

@ -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) {

View file

@ -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.

View file

@ -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

View file

@ -97,7 +97,7 @@ resource "google_project_service" "datastore" {
service = "datastore.googleapis.com"
}
// Deploy image to each region.
// Deploy each service with its image.
resource "google_cloud_run_service" "services" {
for_each = var.services
name = each.key

View file

@ -4,6 +4,7 @@ set -euxo pipefail
### buildpack
time crane validate --remote=buildpack.kontain.me/googlecloudplatform/buildpack-samples/sample-go:ed393d
time crane validate --remote=buildpack.kontain.me/googlecloudplatform/buildpack-samples/sample-go:ed393d
### flatten
@ -18,8 +19,8 @@ time crane validate --remote=kaniko.kontain.me/dockersamples/node-bulletin-board
### ko
time crane validate --remote=ko.kontain.me/github.com/google/ko/cmd/ko
time crane validate --remote=ko.kontain.me/github.com/google/ko/cmd/ko
#time crane validate --remote=ko.kontain.me/github.com/google/ko/cmd/ko
#time crane validate --remote=ko.kontain.me/github.com/google/ko/cmd/ko
### mirror