1
0
mirror of https://github.com/ko-build/ko.git synced 2025-02-07 19:30:23 +02:00

Make --insecure-registry work with TLS registries whose certs we can't verify. (#398)

* Make --insecure-registry work with TLS registries whose certs we can't verify.

* Don't error if we can't disable TLS checking when insecure.
This commit is contained in:
Evan Anderson 2021-07-28 13:23:45 -07:00 committed by GitHub
parent 18096666c9
commit f04730dc84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@
package publish
import (
"crypto/tls"
"log"
"net/http"
"path"
@ -105,6 +106,17 @@ func WithTagOnly(tagOnly bool) Option {
func Insecure(b bool) Option {
return func(i *defaultOpener) error {
i.insecure = b
t, ok := i.t.(*http.Transport)
if !ok {
return nil
}
t = t.Clone()
if t.TLSClientConfig == nil {
t.TLSClientConfig = &tls.Config{} //nolint: gosec
}
t.TLSClientConfig.InsecureSkipVerify = b //nolint: gosec
i.t = t
return nil
}
}