about summary refs log tree commit diff
path: root/tools/nixery/server
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-03T12·08+0100
committerVincent Ambo <github@tazj.in>2019-10-03T12·21+0100
commit1124b8c236a2f01a1eec2420131627d29f678c9d (patch)
tree9e7b46b8a72fdcc888e09d3cd839abca128744be /tools/nixery/server
parentfeba42e40933fe932b1ca330d2c919ae018a9a7f (diff)
fix(server): Do not invoke layer build if no layers are missing
This previously invoked a Nix derivation that spent a few seconds on
making an empty object in JSON ...
Diffstat (limited to 'tools/nixery/server')
-rw-r--r--tools/nixery/server/builder/builder.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index e622f815a423..81dbd26db188 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -277,6 +277,11 @@ func prepareLayers(ctx context.Context, s *State, image *Image, result *ImageRes
 
 // Builds remaining layers (those not already cached) via Nix.
 func buildLayers(s *State, image *Image, grouped []layers.Layer) (map[string]string, error) {
+	result := make(map[string]string)
+	if len(grouped) == 0 {
+		return result, nil
+	}
+
 	srcType, srcArgs := s.Cfg.Pkgs.Render(image.Tag)
 	args := []string{
 		"--argstr", "srcType", srcType,
@@ -312,7 +317,6 @@ func buildLayers(s *State, image *Image, grouped []layers.Layer) (map[string]str
 	}
 	log.Printf("Finished layer preparation for '%s' via Nix\n", image.Name)
 
-	result := make(map[string]string)
 	err = json.Unmarshal(output, &result)
 	if err != nil {
 		return nil, err