Skip to content

Commit

Permalink
Don't overwrite WithTransport option (#1077)
Browse files Browse the repository at this point in the history
Missed this in review. We clobber the HTTPHeaders immediately after by
having two WithTransport options.
  • Loading branch information
jonjohnsonjr committed Jul 13, 2021
1 parent b448aba commit 03f1bf4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/crane/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
},
}

Expand Down

0 comments on commit 03f1bf4

Please sign in to comment.