Browse code

Move UAStringKey to dockerversion pkg

Removes grpc dependency from client

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/12/23 06:51:47
Showing 3 changed files
... ...
@@ -14,9 +14,6 @@ import (
14 14
 // APIVersionKey is the client's requested API version.
15 15
 const APIVersionKey = "api-version"
16 16
 
17
-// UAStringKey is used as key type for user-agent string in net/context struct
18
-const UAStringKey = "upstream-user-agent"
19
-
20 17
 // APIFunc is an adapter to allow the use of ordinary functions as Docker API endpoints.
21 18
 // Any function that has the appropriate signature can be registered as an API endpoint (e.g. getVersion).
22 19
 type APIFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"github.com/docker/docker/api/server/httputils"
13 13
 	"github.com/docker/docker/api/server/middleware"
14 14
 	"github.com/docker/docker/api/server/router"
15
+	"github.com/docker/docker/dockerversion"
15 16
 	"github.com/gorilla/mux"
16 17
 	"golang.org/x/net/context"
17 18
 )
... ...
@@ -128,7 +129,7 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
128 128
 		// apply to all requests. Data that is specific to the
129 129
 		// immediate function being called should still be passed
130 130
 		// as 'args' on the function call.
131
-		ctx := context.WithValue(context.Background(), httputils.UAStringKey, r.Header.Get("User-Agent"))
131
+		ctx := context.WithValue(context.Background(), dockerversion.UAStringKey, r.Header.Get("User-Agent"))
132 132
 		handlerFunc := s.handlerWithGlobalMiddlewares(handler)
133 133
 
134 134
 		vars := mux.Vars(r)
... ...
@@ -4,12 +4,14 @@ import (
4 4
 	"fmt"
5 5
 	"runtime"
6 6
 
7
-	"github.com/docker/docker/api/server/httputils"
8 7
 	"github.com/docker/docker/pkg/parsers/kernel"
9 8
 	"github.com/docker/docker/pkg/useragent"
10 9
 	"golang.org/x/net/context"
11 10
 )
12 11
 
12
+// UAStringKey is used as key type for user-agent string in net/context struct
13
+const UAStringKey = "upstream-user-agent"
14
+
13 15
 // DockerUserAgent is the User-Agent the Docker client uses to identify itself.
14 16
 // In accordance with RFC 7231 (5.5.3) is of the form:
15 17
 //    [docker client's UA] UpstreamClient([upstream client's UA])
... ...
@@ -37,9 +39,9 @@ func DockerUserAgent(ctx context.Context) string {
37 37
 func getUserAgentFromContext(ctx context.Context) string {
38 38
 	var upstreamUA string
39 39
 	if ctx != nil {
40
-		var ki interface{} = ctx.Value(httputils.UAStringKey)
40
+		var ki interface{} = ctx.Value(UAStringKey)
41 41
 		if ki != nil {
42
-			upstreamUA = ctx.Value(httputils.UAStringKey).(string)
42
+			upstreamUA = ctx.Value(UAStringKey).(string)
43 43
 		}
44 44
 	}
45 45
 	return upstreamUA