Browse code

builder/remotecontext: allow ssh:// urls for remote context

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

Sebastiaan van Stijn authored on 2019/11/06 06:58:58
Showing 2 changed files
... ...
@@ -209,7 +209,7 @@ func isGitTransport(str string) bool {
209 209
 	}
210 210
 
211 211
 	switch getScheme(str) {
212
-	case "git", "http", "https":
212
+	case "git", "http", "https", "ssh":
213 213
 		return true
214 214
 	}
215 215
 
... ...
@@ -83,6 +83,32 @@ func TestParseRemoteURL(t *testing.T) {
83 83
 				subdir: "mydir/mysubdir/",
84 84
 			},
85 85
 		},
86
+		{
87
+			doc: "ssh, no url-fragment",
88
+			url: "ssh://github.com/user/repo.git",
89
+			expected: gitRepo{
90
+				remote: "ssh://github.com/user/repo.git",
91
+				ref:    "master",
92
+			},
93
+		},
94
+		{
95
+			doc: "ssh, with url-fragment",
96
+			url: "ssh://github.com/user/repo.git#mybranch:mydir/mysubdir/",
97
+			expected: gitRepo{
98
+				remote: "ssh://github.com/user/repo.git",
99
+				ref:    "mybranch",
100
+				subdir: "mydir/mysubdir/",
101
+			},
102
+		},
103
+		{
104
+			doc: "ssh, with url-fragment and user",
105
+			url: "ssh://foo%40barcorp.com@github.com/user/repo.git#mybranch:mydir/mysubdir/",
106
+			expected: gitRepo{
107
+				remote: "ssh://foo%40barcorp.com@github.com/user/repo.git",
108
+				ref:    "mybranch",
109
+				subdir: "mydir/mysubdir/",
110
+			},
111
+		},
86 112
 	}
87 113
 
88 114
 	for _, tc := range tests {