Quellcode durchsuchen

client: WithTLSClientConfig, WithTLSClientConfigFromEnv: inline vars

Remove intermediate variables.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn vor 2 Jahren
Ursprung
Commit
6846c63252
1 geänderte Dateien mit 4 neuen und 6 gelöschten Zeilen
  1. 4 6
      client/options.go

+ 4 - 6
client/options.go

@@ -135,13 +135,12 @@ func WithScheme(scheme string) Opt {
 // WithTLSClientConfig applies a TLS config to the client transport.
 // WithTLSClientConfig applies a TLS config to the client transport.
 func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt {
 func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt {
 	return func(c *Client) error {
 	return func(c *Client) error {
-		opts := tlsconfig.Options{
+		config, err := tlsconfig.Client(tlsconfig.Options{
 			CAFile:             cacertPath,
 			CAFile:             cacertPath,
 			CertFile:           certPath,
 			CertFile:           certPath,
 			KeyFile:            keyPath,
 			KeyFile:            keyPath,
 			ExclusiveRootPools: true,
 			ExclusiveRootPools: true,
-		}
-		config, err := tlsconfig.Client(opts)
+		})
 		if err != nil {
 		if err != nil {
 			return errors.Wrap(err, "failed to create tls config")
 			return errors.Wrap(err, "failed to create tls config")
 		}
 		}
@@ -170,13 +169,12 @@ func WithTLSClientConfigFromEnv() Opt {
 		if dockerCertPath == "" {
 		if dockerCertPath == "" {
 			return nil
 			return nil
 		}
 		}
-		options := tlsconfig.Options{
+		tlsc, err := tlsconfig.Client(tlsconfig.Options{
 			CAFile:             filepath.Join(dockerCertPath, "ca.pem"),
 			CAFile:             filepath.Join(dockerCertPath, "ca.pem"),
 			CertFile:           filepath.Join(dockerCertPath, "cert.pem"),
 			CertFile:           filepath.Join(dockerCertPath, "cert.pem"),
 			KeyFile:            filepath.Join(dockerCertPath, "key.pem"),
 			KeyFile:            filepath.Join(dockerCertPath, "key.pem"),
 			InsecureSkipVerify: os.Getenv(EnvTLSVerify) == "",
 			InsecureSkipVerify: os.Getenv(EnvTLSVerify) == "",
-		}
-		tlsc, err := tlsconfig.Client(options)
+		})
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}