Skip to content

Commit 424a311

Browse files
author
Prince Rachit Sinha
committed
[image-builder-bob] Support Google Artifact registry
1 parent fe904f9 commit 424a311

File tree

1 file changed

+7
-1
lines changed
  • components/image-builder-bob/pkg/proxy

1 file changed

+7
-1
lines changed

components/image-builder-bob/pkg/proxy/proxy.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy {
171171
//
172172
// @link https://golang.org/src/net/http/httputil/reverseproxy.go
173173
r.Header.Set("X-Forwarded-For", "127.0.0.1")
174-
174+
if strings.Contains(r.URL.Path, "artifacts-uploads") {
175+
str := strings.SplitN(r.URL.Path, "/artifacts-uploads", 2)
176+
r.URL.Path = "/artifacts-uploads" + str[1]
177+
}
175178
auth, ok := r.Context().Value(authKey).(docker.Authorizer)
176179
if !ok || auth == nil {
177180
return
@@ -187,6 +190,9 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy {
187190
// Some registries return a Location header which we must rewrite to still push
188191
// through this proxy.
189192
if loc := r.Header.Get("Location"); loc != "" {
193+
// We don't want / prefix for relative URL
194+
// As we already add a suffix of / when rewriting the url
195+
loc = strings.TrimPrefix(loc, "/")
190196
lurl, err := url.Parse(loc)
191197
if err != nil {
192198
return err

0 commit comments

Comments
 (0)