about summary refs log tree commit diff
path: root/tools/nixery/main.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-03T00·18+0100
committerVincent Ambo <github@tazj.in>2019-08-03T00·25+0100
commit3347c38ba7b79f0251ca16c332867d4488976ac5 (patch)
tree9195c0b4c1f6d8e5ce84544784511c1e1f11859f /tools/nixery/main.go
parentecee1ec1b888bb2ee745e4255158c829b78c3d3d (diff)
fix(go): Registry API acknowledgement URI has a trailing slash
Previously the acknowledgement calls from Docker were receiving a
404 (which apparently doesn't bother it?!). This corrects the URL,
which meant that acknowledgement had to move inside of the
registryHandler.
Diffstat (limited to 'tools/nixery/main.go')
-rw-r--r--tools/nixery/main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/nixery/main.go b/tools/nixery/main.go
index 54dd8ab4d1..a78250d4c4 100644
--- a/tools/nixery/main.go
+++ b/tools/nixery/main.go
@@ -367,6 +367,11 @@ type registryHandler struct {
 }
 
 func (h *registryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+	// Acknowledge that we speak V2 with an empty response
+	if r.RequestURI == "/v2/" {
+		return
+	}
+
 	// Serve the manifest (straight from Nix)
 	manifestMatches := manifestRegex.FindStringSubmatch(r.RequestURI)
 	if len(manifestMatches) == 3 {
@@ -436,12 +441,7 @@ func main() {
 
 	log.Printf("Starting Kubernetes Nix controller on port %s\n", cfg.port)
 
-	// Acknowledge that we speak V2
-	http.HandleFunc("/v2", func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprintln(w)
-	})
-
-	// All other /v2/ requests belong to the registry handler.
+	// All /v2/ requests belong to the registry handler.
 	http.Handle("/v2/", &registryHandler{
 		cfg:    cfg,
 		ctx:    &ctx,