Signed-off-by: Lorenzo Fontana <fontanalorenzo@me.com>
| ... | ... |
@@ -98,9 +98,9 @@ RUN cd /usr/local/go/src \ |
| 98 | 98 |
./make.bash --no-clean 2>&1; \ |
| 99 | 99 |
done |
| 100 | 100 |
|
| 101 |
-# We still support compiling with older Go, so need to grab older "gofmt" |
|
| 102 |
-ENV GOFMT_VERSION 1.3.3 |
|
| 103 |
-RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt
|
|
| 101 |
+# This has been commented out and kept as reference because we don't support compiling with older Go anymore. |
|
| 102 |
+# ENV GOFMT_VERSION 1.3.3 |
|
| 103 |
+# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt
|
|
| 104 | 104 |
|
| 105 | 105 |
# Update this sha when we upgrade to go 1.5.0 |
| 106 | 106 |
ENV GO_TOOLS_COMMIT 069d2f3bcb68257b627205f0486d6cc69a231ff9 |
| ... | ... |
@@ -1,45 +1,11 @@ |
| 1 | 1 |
package requestdecorator |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "encoding/base64" |
|
| 5 | 4 |
"net/http" |
| 6 | 5 |
"strings" |
| 7 | 6 |
"testing" |
| 8 | 7 |
) |
| 9 | 8 |
|
| 10 |
-// The following 2 functions are here for 1.3.3 support |
|
| 11 |
-// After we drop 1.3.3 support we can use the functions supported |
|
| 12 |
-// in go v1.4.0 + |
|
| 13 |
-// BasicAuth returns the username and password provided in the request's |
|
| 14 |
-// Authorization header, if the request uses HTTP Basic Authentication. |
|
| 15 |
-// See RFC 2617, Section 2. |
|
| 16 |
-func basicAuth(r *http.Request) (username, password string, ok bool) {
|
|
| 17 |
- auth := r.Header.Get("Authorization")
|
|
| 18 |
- if auth == "" {
|
|
| 19 |
- return |
|
| 20 |
- } |
|
| 21 |
- return parseBasicAuth(auth) |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-// parseBasicAuth parses an HTTP Basic Authentication string. |
|
| 25 |
-// "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" returns ("Aladdin", "open sesame", true).
|
|
| 26 |
-func parseBasicAuth(auth string) (username, password string, ok bool) {
|
|
| 27 |
- const prefix = "Basic " |
|
| 28 |
- if !strings.HasPrefix(auth, prefix) {
|
|
| 29 |
- return |
|
| 30 |
- } |
|
| 31 |
- c, err := base64.StdEncoding.DecodeString(auth[len(prefix):]) |
|
| 32 |
- if err != nil {
|
|
| 33 |
- return |
|
| 34 |
- } |
|
| 35 |
- cs := string(c) |
|
| 36 |
- s := strings.IndexByte(cs, ':') |
|
| 37 |
- if s < 0 {
|
|
| 38 |
- return |
|
| 39 |
- } |
|
| 40 |
- return cs[:s], cs[s+1:], true |
|
| 41 |
-} |
|
| 42 |
- |
|
| 43 | 9 |
func TestUAVersionInfo(t *testing.T) {
|
| 44 | 10 |
uavi := NewUAVersionInfo("foo", "bar")
|
| 45 | 11 |
if !uavi.isValid() {
|
| ... | ... |
@@ -147,7 +113,7 @@ func TestAuthDecorator(t *testing.T) {
|
| 147 | 147 |
t.Fatal(err) |
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
- username, password, ok := basicAuth(reqDecorated) |
|
| 150 |
+ username, password, ok := reqDecorated.BasicAuth() |
|
| 151 | 151 |
if !ok {
|
| 152 | 152 |
t.Fatalf("Cannot retrieve basic auth info from request")
|
| 153 | 153 |
} |
| ... | ... |
@@ -189,7 +155,7 @@ func TestRequestFactory(t *testing.T) {
|
| 189 | 189 |
t.Fatal(err) |
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 |
- username, password, ok := basicAuth(req) |
|
| 192 |
+ username, password, ok := req.BasicAuth() |
|
| 193 | 193 |
if !ok {
|
| 194 | 194 |
t.Fatalf("Cannot retrieve basic auth info from request")
|
| 195 | 195 |
} |
| ... | ... |
@@ -220,7 +186,7 @@ func TestRequestFactoryNewRequestWithDecorators(t *testing.T) {
|
| 220 | 220 |
t.Fatal(err) |
| 221 | 221 |
} |
| 222 | 222 |
|
| 223 |
- username, password, ok := basicAuth(req) |
|
| 223 |
+ username, password, ok := req.BasicAuth() |
|
| 224 | 224 |
if !ok {
|
| 225 | 225 |
t.Fatalf("Cannot retrieve basic auth info from request")
|
| 226 | 226 |
} |
| ... | ... |
@@ -45,7 +45,7 @@ need to package Docker your way, without denaturing it in the process. |
| 45 | 45 |
To build Docker, you will need the following: |
| 46 | 46 |
|
| 47 | 47 |
* A recent version of Git and Mercurial |
| 48 |
-* Go version 1.3 or later |
|
| 48 |
+* Go version 1.4 or later |
|
| 49 | 49 |
* A clean checkout of the source added to a valid [Go |
| 50 | 50 |
workspace](https://golang.org/doc/code.html#Workspaces) under the path |
| 51 | 51 |
*src/github.com/docker/docker* (unless you plan to use `AUTO_GOPATH`, |