Skip to content

Commit

Permalink
Remove unused error response from WithSSLCertPool
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Jun 7, 2024
1 parent 5d6e1a8 commit 220ade0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
7 changes: 1 addition & 6 deletions cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ func newClient(params paramscmd.API, opts ...api.Option) (*api.Client, error) {

opts = append(opts, withSSLCert)
} else if !params.DisableSSLVerify {
withSSLCert, err := api.WithSSLCertPool(api.CACerts())
if err != nil {
return nil, fmt.Errorf("failed to set up ssl cert pool option on api client: %s", err)
}

opts = append(opts, withSSLCert)
opts = append(opts, api.WithSSLCertPool(api.CACerts()))
}

if params.ProxyURL != "" {
Expand Down
14 changes: 8 additions & 6 deletions pkg/api/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func WithAuth(auth BasicAuth) (Option, error) {
// WithDisableSSLVerify disables verification of insecure certificates.
func WithDisableSSLVerify() Option {
return func(c *Client) {
var transport = LazyCreateNewTransport(c)
transport := LazyCreateNewTransport(c)

Check warning on line 40 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L40

Added line #L40 was not covered by tests

tlsConfig := transport.TLSClientConfig
tlsConfig.InsecureSkipVerify = true
Expand Down Expand Up @@ -110,7 +110,7 @@ func WithProxy(proxyURL string) (Option, error) {
}

return func(c *Client) {
var transport = LazyCreateNewTransport(c)
transport := LazyCreateNewTransport(c)
transport.Proxy = http.ProxyURL(u)
c.client.Transport = transport
}, nil
Expand All @@ -126,19 +126,21 @@ func WithSSLCertFile(filepath string) (Option, error) {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)

return WithSSLCertPool(caCertPool)
return WithSSLCertPool(caCertPool), nil

Check warning on line 129 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L129

Added line #L129 was not covered by tests
}

// WithSSLCertPool overrides the default CA cert pool to trust specified cert pool.
func WithSSLCertPool(caCertPool *x509.CertPool) (Option, error) {
func WithSSLCertPool(caCertPool *x509.CertPool) Option {

Check warning on line 133 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L133

Added line #L133 was not covered by tests
return func(c *Client) {
var transport = LazyCreateNewTransport(c)
transport := LazyCreateNewTransport(c)

Check warning on line 136 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L135-L136

Added lines #L135 - L136 were not covered by tests
tlsConfig := transport.TLSClientConfig
tlsConfig.RootCAs = caCertPool

Check warning on line 139 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L139

Added line #L139 was not covered by tests
transport.TLSClientConfig = tlsConfig

c.client.Transport = transport
}, nil
}

Check warning on line 143 in pkg/api/option.go

View check run for this annotation

Codecov / codecov/patch

pkg/api/option.go#L143

Added line #L143 was not covered by tests
}

// WithTimeout configures a timeout for all requests.
Expand Down
2 changes: 1 addition & 1 deletion pkg/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestWithFiltering(t *testing.T) {
func TestWithLengthValidator(t *testing.T) {
opt := filter.WithLengthValidator()
h := opt(func(_ []heartbeat.Heartbeat) ([]heartbeat.Result, error) {
return []heartbeat.Result{}, errors.New("this will should never be called")
return []heartbeat.Result{}, errors.New("this should never be called")
})

result, err := h([]heartbeat.Heartbeat{})
Expand Down

0 comments on commit 220ade0

Please sign in to comment.