@@ -3,8 +3,6 @@ package bundlereader
33import (
44 "bufio"
55 "context"
6- "crypto/tls"
7- "crypto/x509"
86 "encoding/base64"
97 "fmt"
108 "io/fs"
@@ -179,7 +177,7 @@ func loadDirectory(ctx context.Context, opts loadOpts, dir directory) ([]fleet.B
179177 if opts .compress || ! utf8 .Valid (data ) {
180178 content , err := content .Base64GZ (data )
181179 if err != nil {
182- return nil , err
180+ return nil , fmt . Errorf ( "decoding compressed base64 data: %w" , err )
183181 }
184182 r .Content = content
185183 r .Encoding = "base64+gz"
@@ -211,7 +209,7 @@ func GetContent(ctx context.Context, base, source, version string, auth Auth, di
211209 if hasOCIURL .MatchString (source ) {
212210 source , err = downloadOCIChart (source , version , temp , auth )
213211 if err != nil {
214- return nil , err
212+ return nil , fmt . Errorf ( "downloading OCI chart from %q: %w" , orgSource , err )
215213 }
216214 }
217215
@@ -275,7 +273,7 @@ func GetContent(ctx context.Context, base, source, version string, auth Auth, di
275273 }
276274
277275 if _ , err := client .Get (ctx , req ); err != nil {
278- return nil , err
276+ return nil , fmt . Errorf ( "retrieving file from %q: %w" , source , err )
279277 }
280278
281279 files := map [string ][]byte {}
@@ -312,7 +310,7 @@ func GetContent(ctx context.Context, base, source, version string, auth Auth, di
312310 // try to update possible dependencies.
313311 if ! disableDepsUpdate && helmupdater .ChartYAMLExists (path ) {
314312 if err = helmupdater .UpdateHelmDependencies (path ); err != nil {
315- return err
313+ return fmt . Errorf ( "updating helm dependencies: %w" , err )
316314 }
317315 }
318316 // Skip .fleetignore'd and hidden directories
@@ -432,7 +430,7 @@ func downloadOCIChart(name, version, path string, auth Auth) (string, error) {
432430
433431func newHttpGetter (auth Auth ) * getter.HttpGetter {
434432 httpGetter := & getter.HttpGetter {
435- Client : & http. Client {} ,
433+ Client : getHTTPClient ( auth ) ,
436434 }
437435
438436 if auth .Username != "" && auth .Password != "" {
@@ -441,25 +439,6 @@ func newHttpGetter(auth Auth) *getter.HttpGetter {
441439 httpGetter .Header = header
442440 }
443441
444- transport := http .DefaultTransport .(* http.Transport ).Clone ()
445- if auth .CABundle != nil {
446- pool , err := x509 .SystemCertPool ()
447- if err != nil {
448- pool = x509 .NewCertPool ()
449- }
450- pool .AppendCertsFromPEM (auth .CABundle )
451- transport .TLSClientConfig = & tls.Config {
452- RootCAs : pool ,
453- MinVersion : tls .VersionTLS12 ,
454- InsecureSkipVerify : auth .InsecureSkipVerify , // nolint:gosec
455- }
456- } else if auth .InsecureSkipVerify {
457- transport .TLSClientConfig = & tls.Config {
458- InsecureSkipVerify : auth .InsecureSkipVerify , // nolint:gosec
459- }
460- }
461- httpGetter .Client .Transport = transport
462-
463442 return httpGetter
464443}
465444
0 commit comments