( out io.Writer, certFile, keyFile, caFile string, insecureSkipTLSVerify bool, username, password string, )
| 440 | } |
| 441 | |
| 442 | func newRegistryClientWithTLS( |
| 443 | out io.Writer, certFile, keyFile, caFile string, insecureSkipTLSVerify bool, username, password string, |
| 444 | ) (*registry.Client, error) { |
| 445 | tlsConf, err := tlsutil.NewTLSConfig( |
| 446 | tlsutil.WithInsecureSkipVerify(insecureSkipTLSVerify), |
| 447 | tlsutil.WithCertKeyPairFiles(certFile, keyFile), |
| 448 | tlsutil.WithCAFile(caFile), |
| 449 | ) |
| 450 | |
| 451 | if err != nil { |
| 452 | return nil, fmt.Errorf("can't create TLS config for client: %w", err) |
| 453 | } |
| 454 | |
| 455 | // Create a new registry client |
| 456 | registryClient, err := registry.NewClient( |
| 457 | registry.ClientOptDebug(settings.Debug), |
| 458 | registry.ClientOptEnableCache(true), |
| 459 | registry.ClientOptWriter(out), |
| 460 | registry.ClientOptCredentialsFile(settings.RegistryConfig), |
| 461 | registry.ClientOptHTTPClient(&http.Client{ |
| 462 | Transport: &http.Transport{ |
| 463 | TLSClientConfig: tlsConf, |
| 464 | Proxy: http.ProxyFromEnvironment, |
| 465 | }, |
| 466 | }), |
| 467 | registry.ClientOptBasicAuth(username, password), |
| 468 | ) |
| 469 | if err != nil { |
| 470 | return nil, err |
| 471 | } |
| 472 | return registryClient, nil |
| 473 | } |
| 474 | |
| 475 | type CommandError struct { |
| 476 | error |
no test coverage detected
searching dependent graphs…