lib/promauth: add more context to errors returned by Options.NewConfig() in order to simplify troubleshooting

This commit is contained in:
Aliaksandr Valialkin 2023-12-20 21:58:12 +02:00
parent 160cc9debd
commit 01f9edda64
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -582,18 +582,18 @@ func (opts *Options) NewConfig() (*Config, error) {
return nil, fmt.Errorf("cannot simultaneously use `authorization`, `basic_auth, `bearer_token` and `ouath2`")
}
if err := actx.initFromOAuth2Config(baseDir, opts.OAuth2); err != nil {
return nil, err
return nil, fmt.Errorf("cannot initialize oauth2: %w", err)
}
}
var tctx tlsContext
if opts.TLSConfig != nil {
if err := tctx.initFromTLSConfig(baseDir, opts.TLSConfig); err != nil {
return nil, err
return nil, fmt.Errorf("cannot initialize tls: %w", err)
}
}
headers, err := parseHeaders(opts.Headers)
if err != nil {
return nil, err
return nil, fmt.Errorf("cannot parse headers: %w", err)
}
hd := xxhash.New()
for _, kv := range headers {