about summary refs log tree commit diff
path: root/tools/nixery/server/builder/builder.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-09-09T15·41+0100
committerVincent Ambo <github@tazj.in>2019-09-10T10·32+0100
commit4a58b0ab4d21473723834dec651c876da2dec220 (patch)
treecf24e5ee5c658390085d2244332f44783ba48b51 /tools/nixery/server/builder/builder.go
parent051eb77b3de81d9393e5c5443c06b62b6abf1535 (diff)
feat(server): Cache built manifests to the GCS bucket
Caches manifests under `manifests/$cacheKey` in the GCS bucket and
introduces two-tiered retrieval of manifests from the caches (local
first, bucket second).

There is some cleanup to be done in this code, but the initial version
works.
Diffstat (limited to 'tools/nixery/server/builder/builder.go')
-rw-r--r--tools/nixery/server/builder/builder.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index cfe03511f68e..dd26ccc310aa 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -109,8 +109,8 @@ func convenienceNames(packages []string) []string {
 
 // Call out to Nix and request that an image be built. Nix will, upon success,
 // return a manifest for the container image.
-func BuildImage(ctx *context.Context, cfg *config.Config, cache *BuildCache, image *Image, bucket *storage.BucketHandle) (*BuildResult, error) {
-	resultFile, cached := cache.manifestFromCache(cfg.Pkgs, image)
+func BuildImage(ctx *context.Context, cfg *config.Config, cache *LocalCache, image *Image, bucket *storage.BucketHandle) (*BuildResult, error) {
+	resultFile, cached := manifestFromCache(ctx, bucket, cfg.Pkgs, cache, image)
 
 	if !cached {
 		packages, err := json.Marshal(image.Packages)
@@ -158,7 +158,7 @@ func BuildImage(ctx *context.Context, cfg *config.Config, cache *BuildCache, ima
 		log.Println("Finished Nix image build")
 
 		resultFile = strings.TrimSpace(string(stdout))
-		cache.cacheManifest(cfg.Pkgs, image, resultFile)
+		cacheManifest(ctx, bucket, cfg.Pkgs, cache, image, resultFile)
 	}
 
 	buildOutput, err := ioutil.ReadFile(resultFile)