about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-28T17·18+0100
committerVincent Ambo <github@tazj.in>2019-10-28T21·31+0100
commit167a0b32630ed86b3a053e56fa499957872d7b38 (patch)
treeeb45026ee9d1d22df0b1ab1fe5c68e20fcd4b0df /tools
parente5bb2fc887f8d4e7216a1dfcbfa81baac2b09cfd (diff)
refactor(server): Pass HTTP request to storage.ServeLayer
The request object is required for some serving methods (e.g. the
filesystem one).
Diffstat (limited to 'tools')
-rw-r--r--tools/nixery/server/builder/builder.go2
-rw-r--r--tools/nixery/server/main.go2
-rw-r--r--tools/nixery/server/storage/gcs.go4
-rw-r--r--tools/nixery/server/storage/storage.go2
4 files changed, 6 insertions, 4 deletions
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index 17ea1b8e6209..021cc662c56d 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -411,7 +411,7 @@ func uploadHashLayer(ctx context.Context, s *State, key string, lw layerWriter)
 		"layer":  key,
 		"sha256": sha256sum,
 		"size":   size,
-	}).Info("uploaded layer")
+	}).Info("created and persisted layer")
 
 	entry := manifest.Entry{
 		Digest: "sha256:" + sha256sum,
diff --git a/tools/nixery/server/main.go b/tools/nixery/server/main.go
index b5d7091ed002..282fe9773a73 100644
--- a/tools/nixery/server/main.go
+++ b/tools/nixery/server/main.go
@@ -175,7 +175,7 @@ func (h *registryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	if len(layerMatches) == 3 {
 		digest := layerMatches[2]
 		storage := h.state.Storage
-		err := storage.ServeLayer(digest, w)
+		err := storage.ServeLayer(digest, r, w)
 		if err != nil {
 			log.WithError(err).WithFields(log.Fields{
 				"layer":   digest,
diff --git a/tools/nixery/server/storage/gcs.go b/tools/nixery/server/storage/gcs.go
index feb6d30d681e..749c7ba150e5 100644
--- a/tools/nixery/server/storage/gcs.go
+++ b/tools/nixery/server/storage/gcs.go
@@ -139,7 +139,7 @@ func (b *GCSBackend) Move(old, new string) error {
 	return nil
 }
 
-func (b *GCSBackend) ServeLayer(digest string, w http.ResponseWriter) error {
+func (b *GCSBackend) ServeLayer(digest string, r *http.Request, w http.ResponseWriter) error {
 	url, err := b.constructLayerUrl(digest)
 	if err != nil {
 		log.WithError(err).WithFields(log.Fields{
@@ -150,6 +150,8 @@ func (b *GCSBackend) ServeLayer(digest string, w http.ResponseWriter) error {
 		return err
 	}
 
+	log.WithField("layer", digest).Info("redirecting layer request to GCS bucket")
+
 	w.Header().Set("Location", url)
 	w.WriteHeader(303)
 	return nil
diff --git a/tools/nixery/server/storage/storage.go b/tools/nixery/server/storage/storage.go
index 15b8355e6ef5..ad10d682e93a 100644
--- a/tools/nixery/server/storage/storage.go
+++ b/tools/nixery/server/storage/storage.go
@@ -30,5 +30,5 @@ type Backend interface {
 
 	// Serve provides a handler function to serve HTTP requests
 	// for layers in the storage backend.
-	ServeLayer(digest string, w http.ResponseWriter) error
+	ServeLayer(digest string, r *http.Request, w http.ResponseWriter) error
 }