Skip to content

Commit

Permalink
Fixed Broken Unit tests in Kraken (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Gaurav Kumar <gauravk@uber.com>
  • Loading branch information
gkeesh7 and gauravkuber committed Sep 23, 2024
1 parent ed62423 commit fd35b87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/backend/registrybackend/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ func (a *authenticator) Authenticate(repo string) ([]httputil.SendOption, error)
return opts, nil
}

if !config.EnableHTTPFallback {
if config.EnableHTTPFallback {
opts = append(opts, httputil.EnableHTTPFallback())
} else {
opts = append(opts, httputil.DisableHTTPFallback())
}

if !a.shouldAuth() {
opts = append(opts, httputil.SendTLSTransport(a.roundTripper))
return opts, nil
Expand Down
7 changes: 7 additions & 0 deletions utils/httputil/httputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ func DisableHTTPFallback() SendOption {
}
}

// EnableHTTPFallback enables http fallback when https request fails.
func EnableHTTPFallback() SendOption {
return func(o *sendOptions) {
o.httpFallbackDisabled = false
}
}

// SendTLS sets the transport with TLS config for the HTTP client.
func SendTLS(config *tls.Config) SendOption {
return func(o *sendOptions) {
Expand Down

0 comments on commit fd35b87

Please sign in to comment.