From 03f1bf46bab527b80f3b32fba78b7a7ac0b0bc42 Mon Sep 17 00:00:00 2001 From: jonjohnsonjr Date: Tue, 13 Jul 2021 11:26:18 -0700 Subject: [PATCH] Don't overwrite WithTransport option (#1077) Missed this in review. We clobber the HTTPHeaders immediately after by having two WithTransport options. --- cmd/crane/cmd/root.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/crane/cmd/root.go b/cmd/crane/cmd/root.go index e6c0a769b..d0c038b82 100644 --- a/cmd/crane/cmd/root.go +++ b/cmd/crane/cmd/root.go @@ -67,18 +67,19 @@ func New(use, short string, options []crane.Option) *cobra.Command { transport := http.DefaultTransport.(*http.Transport).Clone() transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: insecure} + 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 { logs.Debug.Printf("failed to read config file: %v", err) } else if len(cf.HTTPHeaders) != 0 { - options = append(options, crane.WithTransport(&headerTransport{ - inner: transport, + rt = &headerTransport{ + inner: rt, httpHeaders: cf.HTTPHeaders, - })) + } } - options = append(options, crane.WithTransport(transport)) + options = append(options, crane.WithTransport(rt)) }, }