Skip to content

Commit

Permalink
Merge pull request #932 from cvgw/u/cvgw/issue-925_fix_pull_insecure
Browse files Browse the repository at this point in the history
Fix #925 broken insecure pull
  • Loading branch information
tejal29 committed Dec 23, 2019
2 parents 732b270 + 328847f commit eafb802
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/util/image_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ func remoteImage(image string, opts *config.KanikoOptions) (v1.Image, error) {
return nil, err
}

rOpts, err := prepareRemoteRequest(ref, opts)
if err != nil {
return nil, err
}

return remote.Image(ref, rOpts...)
}

func prepareRemoteRequest(ref name.Reference, opts *config.KanikoOptions) ([]remote.Option, error) {
registryName := ref.Context().RegistryStr()
if opts.InsecurePull || opts.InsecureRegistries.Contains(registryName) {
newReg, err := name.NewRegistry(registryName, name.WeakValidation, name.Insecure)
Expand All @@ -124,13 +115,23 @@ func prepareRemoteRequest(ref name.Reference, opts *config.KanikoOptions) ([]rem
}
}

rOpts := remoteOptions(registryName, opts)
if err != nil {
return nil, err
}

return remote.Image(ref, rOpts...)
}

func remoteOptions(registryName string, opts *config.KanikoOptions) []remote.Option {
tr := http.DefaultTransport.(*http.Transport)
if opts.SkipTLSVerifyPull || opts.SkipTLSVerifyRegistries.Contains(registryName) {
tr.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
}
return []remote.Option{remote.WithTransport(tr), remote.WithAuthFromKeychain(creds.GetKeychain())}, nil

return []remote.Option{remote.WithTransport(tr), remote.WithAuthFromKeychain(creds.GetKeychain())}
}

func cachedImage(opts *config.KanikoOptions, image string) (v1.Image, error) {
Expand Down

0 comments on commit eafb802

Please sign in to comment.