Browse code

Fix 'tcp+tls' protocol not being accepted

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2016/02/09 02:29:01
Showing 2 changed files
... ...
@@ -11,7 +11,7 @@ var (
11 11
 	validPrefixes = map[string][]string{
12 12
 		"url":       {"http://", "https://"},
13 13
 		"git":       {"git://", "github.com/", "git@"},
14
-		"transport": {"tcp://", "udp://", "unix://"},
14
+		"transport": {"tcp://", "tcp+tls://", "udp://", "unix://"},
15 15
 	}
16 16
 	urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
17 17
 )
... ...
@@ -35,7 +35,7 @@ func IsGitTransport(str string) bool {
35 35
 	return IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@")
36 36
 }
37 37
 
38
-// IsTransportURL returns true if the provided str is a transport (tcp, udp, unix) URL.
38
+// IsTransportURL returns true if the provided str is a transport (tcp, tcp+tls, udp, unix) URL.
39 39
 func IsTransportURL(str string) bool {
40 40
 	return checkURL(str, "transport")
41 41
 }
... ...
@@ -18,6 +18,12 @@ var (
18 18
 	invalidGitUrls = []string{
19 19
 		"http://github.com/docker/docker.git:#branch",
20 20
 	}
21
+	transportUrls = []string{
22
+		"tcp://example.com",
23
+		"tcp+tls://example.com",
24
+		"udp://example.com",
25
+		"unix:///example",
26
+	}
21 27
 )
22 28
 
23 29
 func TestValidGitTransport(t *testing.T) {
... ...
@@ -53,3 +59,11 @@ func TestIsGIT(t *testing.T) {
53 53
 		}
54 54
 	}
55 55
 }
56
+
57
+func TestIsTransport(t *testing.T) {
58
+	for _, url := range transportUrls {
59
+		if IsTransportURL(url) == false {
60
+			t.Fatalf("%q should be detected as valid Transport url", url)
61
+		}
62
+	}
63
+}