@@ -357,33 +357,33 @@ func nonZeroCount[T comparable](values ...T) int {
357
357
func (c * HTTPClientConfig ) Validate () error {
358
358
// Backwards compatibility with the bearer_token field.
359
359
if len (c .BearerToken ) > 0 && len (c .BearerTokenFile ) > 0 {
360
- return fmt . Errorf ("at most one of bearer_token & bearer_token_file must be configured" )
360
+ return errors . New ("at most one of bearer_token & bearer_token_file must be configured" )
361
361
}
362
362
if (c .BasicAuth != nil || c .OAuth2 != nil ) && (len (c .BearerToken ) > 0 || len (c .BearerTokenFile ) > 0 ) {
363
- return fmt . Errorf ("at most one of basic_auth, oauth2, bearer_token & bearer_token_file must be configured" )
363
+ return errors . New ("at most one of basic_auth, oauth2, bearer_token & bearer_token_file must be configured" )
364
364
}
365
365
if c .BasicAuth != nil && nonZeroCount (string (c .BasicAuth .Username ) != "" , c .BasicAuth .UsernameFile != "" , c .BasicAuth .UsernameRef != "" ) > 1 {
366
- return fmt . Errorf ("at most one of basic_auth username, username_file & username_ref must be configured" )
366
+ return errors . New ("at most one of basic_auth username, username_file & username_ref must be configured" )
367
367
}
368
368
if c .BasicAuth != nil && nonZeroCount (string (c .BasicAuth .Password ) != "" , c .BasicAuth .PasswordFile != "" , c .BasicAuth .PasswordRef != "" ) > 1 {
369
- return fmt . Errorf ("at most one of basic_auth password, password_file & password_ref must be configured" )
369
+ return errors . New ("at most one of basic_auth password, password_file & password_ref must be configured" )
370
370
}
371
371
if c .Authorization != nil {
372
372
if len (c .BearerToken ) > 0 || len (c .BearerTokenFile ) > 0 {
373
- return fmt . Errorf ("authorization is not compatible with bearer_token & bearer_token_file" )
373
+ return errors . New ("authorization is not compatible with bearer_token & bearer_token_file" )
374
374
}
375
375
if nonZeroCount (string (c .Authorization .Credentials ) != "" , c .Authorization .CredentialsFile != "" , c .Authorization .CredentialsRef != "" ) > 1 {
376
- return fmt . Errorf ("at most one of authorization credentials & credentials_file must be configured" )
376
+ return errors . New ("at most one of authorization credentials & credentials_file must be configured" )
377
377
}
378
378
c .Authorization .Type = strings .TrimSpace (c .Authorization .Type )
379
379
if len (c .Authorization .Type ) == 0 {
380
380
c .Authorization .Type = "Bearer"
381
381
}
382
382
if strings .ToLower (c .Authorization .Type ) == "basic" {
383
- return fmt . Errorf (`authorization type cannot be set to "basic", use "basic_auth" instead` )
383
+ return errors . New (`authorization type cannot be set to "basic", use "basic_auth" instead` )
384
384
}
385
385
if c .BasicAuth != nil || c .OAuth2 != nil {
386
- return fmt . Errorf ("at most one of basic_auth, oauth2 & authorization must be configured" )
386
+ return errors . New ("at most one of basic_auth, oauth2 & authorization must be configured" )
387
387
}
388
388
} else {
389
389
if len (c .BearerToken ) > 0 {
@@ -399,16 +399,16 @@ func (c *HTTPClientConfig) Validate() error {
399
399
}
400
400
if c .OAuth2 != nil {
401
401
if c .BasicAuth != nil {
402
- return fmt . Errorf ("at most one of basic_auth, oauth2 & authorization must be configured" )
402
+ return errors . New ("at most one of basic_auth, oauth2 & authorization must be configured" )
403
403
}
404
404
if len (c .OAuth2 .ClientID ) == 0 {
405
- return fmt . Errorf ("oauth2 client_id must be configured" )
405
+ return errors . New ("oauth2 client_id must be configured" )
406
406
}
407
407
if len (c .OAuth2 .TokenURL ) == 0 {
408
- return fmt . Errorf ("oauth2 token_url must be configured" )
408
+ return errors . New ("oauth2 token_url must be configured" )
409
409
}
410
410
if nonZeroCount (len (c .OAuth2 .ClientSecret ) > 0 , len (c .OAuth2 .ClientSecretFile ) > 0 , len (c .OAuth2 .ClientSecretRef ) > 0 ) > 1 {
411
- return fmt . Errorf ("at most one of oauth2 client_secret, client_secret_file & client_secret_ref must be configured" )
411
+ return errors . New ("at most one of oauth2 client_secret, client_secret_file & client_secret_ref must be configured" )
412
412
}
413
413
}
414
414
if err := c .ProxyConfig .Validate (); err != nil {
@@ -735,7 +735,7 @@ func (s *FileSecret) Fetch(ctx context.Context) (string, error) {
735
735
}
736
736
737
737
func (s * FileSecret ) Description () string {
738
- return fmt . Sprintf ( "file %s" , s .file )
738
+ return "file " + s .file
739
739
}
740
740
741
741
func (s * FileSecret ) Immutable () bool {
@@ -753,7 +753,7 @@ func (s *refSecret) Fetch(ctx context.Context) (string, error) {
753
753
}
754
754
755
755
func (s * refSecret ) Description () string {
756
- return fmt . Sprintf ( "ref %s" , s .ref )
756
+ return "ref " + s .ref
757
757
}
758
758
759
759
func (s * refSecret ) Immutable () bool {
@@ -1045,7 +1045,7 @@ func NewTLSConfigWithContext(ctx context.Context, cfg *TLSConfig, optFuncs ...TL
1045
1045
1046
1046
if cfg .MaxVersion != 0 && cfg .MinVersion != 0 {
1047
1047
if cfg .MaxVersion < cfg .MinVersion {
1048
- return nil , fmt . Errorf ("tls_config.max_version must be greater than or equal to tls_config.min_version if both are specified" )
1048
+ return nil , errors . New ("tls_config.max_version must be greater than or equal to tls_config.min_version if both are specified" )
1049
1049
}
1050
1050
}
1051
1051
@@ -1144,19 +1144,19 @@ func (c *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
1144
1144
// used.
1145
1145
func (c * TLSConfig ) Validate () error {
1146
1146
if nonZeroCount (len (c .CA ) > 0 , len (c .CAFile ) > 0 , len (c .CARef ) > 0 ) > 1 {
1147
- return fmt . Errorf ("at most one of ca, ca_file & ca_ref must be configured" )
1147
+ return errors . New ("at most one of ca, ca_file & ca_ref must be configured" )
1148
1148
}
1149
1149
if nonZeroCount (len (c .Cert ) > 0 , len (c .CertFile ) > 0 , len (c .CertRef ) > 0 ) > 1 {
1150
- return fmt . Errorf ("at most one of cert, cert_file & cert_ref must be configured" )
1150
+ return errors . New ("at most one of cert, cert_file & cert_ref must be configured" )
1151
1151
}
1152
1152
if nonZeroCount (len (c .Key ) > 0 , len (c .KeyFile ) > 0 , len (c .KeyRef ) > 0 ) > 1 {
1153
- return fmt . Errorf ("at most one of key and key_file must be configured" )
1153
+ return errors . New ("at most one of key and key_file must be configured" )
1154
1154
}
1155
1155
1156
1156
if c .usingClientCert () && ! c .usingClientKey () {
1157
- return fmt . Errorf ("exactly one of key or key_file must be configured when a client certificate is configured" )
1157
+ return errors . New ("exactly one of key or key_file must be configured when a client certificate is configured" )
1158
1158
} else if c .usingClientKey () && ! c .usingClientCert () {
1159
- return fmt . Errorf ("exactly one of cert or cert_file must be configured when a client key is configured" )
1159
+ return errors . New ("exactly one of cert or cert_file must be configured when a client key is configured" )
1160
1160
}
1161
1161
1162
1162
return nil
@@ -1460,16 +1460,16 @@ type ProxyConfig struct {
1460
1460
// UnmarshalYAML implements the yaml.Unmarshaler interface.
1461
1461
func (c * ProxyConfig ) Validate () error {
1462
1462
if len (c .ProxyConnectHeader ) > 0 && (! c .ProxyFromEnvironment && (c .ProxyURL .URL == nil || c .ProxyURL .String () == "" )) {
1463
- return fmt . Errorf ("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured" )
1463
+ return errors . New ("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured" )
1464
1464
}
1465
1465
if c .ProxyFromEnvironment && c .ProxyURL .URL != nil && c .ProxyURL .String () != "" {
1466
- return fmt . Errorf ("if proxy_from_environment is configured, proxy_url must not be configured" )
1466
+ return errors . New ("if proxy_from_environment is configured, proxy_url must not be configured" )
1467
1467
}
1468
1468
if c .ProxyFromEnvironment && c .NoProxy != "" {
1469
- return fmt . Errorf ("if proxy_from_environment is configured, no_proxy must not be configured" )
1469
+ return errors . New ("if proxy_from_environment is configured, no_proxy must not be configured" )
1470
1470
}
1471
1471
if c .ProxyURL .URL == nil && c .NoProxy != "" {
1472
- return fmt . Errorf ("if no_proxy is configured, proxy_url must also be configured" )
1472
+ return errors . New ("if no_proxy is configured, proxy_url must also be configured" )
1473
1473
}
1474
1474
return nil
1475
1475
}
0 commit comments