Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow remote.DefaultTransport to be overridden by an http.RoundTripper #1449

Merged
merged 2 commits into from Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions cmd/crane/cmd/root.go
Expand Up @@ -70,12 +70,16 @@ func New(use, short string, options []crane.Option) *cobra.Command {

options = append(options, crane.WithPlatform(platform.platform))

transport := remote.DefaultTransport.Clone()
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: insecure, //nolint: gosec
rt := remote.DefaultTransport
if t, ok := remote.DefaultTransport.(interface {
Clone() *http.Transport
}); ok {
t := t.Clone()
t.TLSClientConfig = &tls.Config{
InsecureSkipVerify: insecure, //nolint: gosec
}
}

var rt http.RoundTripper = transport
// Add any http headers if they are set in the config file.
cf, err := config.Load(os.Getenv("DOCKER_CONFIG"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/remote/options.go
Expand Up @@ -84,7 +84,7 @@ const (

// DefaultTransport is based on http.DefaultTransport with modifications
// documented inline below.
var DefaultTransport = &http.Transport{
var DefaultTransport http.RoundTripper = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
// By default we wrap the transport in retries, so reduce the
Expand Down