Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cthtrifork committed Apr 10, 2024
1 parent c25a321 commit 7743a61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions internal/impl/kafka/sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ func oauthSaslFromConfig(c *service.ParsedConfig) (sasl.Mechanism, error) {
token, err := c.FieldString("token")

if err != nil && token != "" {
if err != nil {
return nil, err
}
var extensions map[string]string
if c.Contains("extensions") {
if extensions, err = c.FieldStringMap("extensions"); err != nil {
Expand Down Expand Up @@ -181,7 +178,7 @@ func acquireToken(ctx context.Context, c *service.ParsedConfig) (string, error)
return "", err
}

clientId, err := c.FieldString("clientId")
clientID, err := c.FieldString("clientId")
if err != nil {
return "", err
}
Expand All @@ -196,7 +193,7 @@ func acquireToken(ctx context.Context, c *service.ParsedConfig) (string, error)
return "", err
}

authHeaderValue := base64.StdEncoding.EncodeToString([]byte(clientId + ":" + clientSecret))
authHeaderValue := base64.StdEncoding.EncodeToString([]byte(clientID + ":" + clientSecret))

queryParams := url.Values{}
queryParams.Set("grant_type", "client_credentials")
Expand Down Expand Up @@ -239,7 +236,7 @@ func acquireToken(ctx context.Context, c *service.ParsedConfig) (string, error)

accessToken, ok := tokenResponse["access_token"].(string)
if !ok {
return "", fmt.Errorf("access_token not found in token response")
return "", errors.New("access_token not found in token response")
}

return accessToken, nil
Expand Down
12 changes: 6 additions & 6 deletions internal/impl/opensearch/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
aFieldAuthTokenCache = "token_cache"
aFieldAuthTokenKey = "token_key"
aFieldAuthTokenEndpoint = "tokenEndpoint"
aFieldAuthTokenClientId = "clientId"
aFieldAuthTokenClientID = "clientId"
aFieldAuthTokenClientSecret = "clientSecret"
aFieldAuthTokenScope = "scope"
)
Expand All @@ -44,7 +44,7 @@ func OAuthAuthField() *service.ConfigField {
service.NewStringField(aFieldAuthTokenEndpoint).
Description("The endpoint to use for OAUTHBEARER token acquisition.").
Default(""),
service.NewStringField(aFieldAuthTokenClientId).
service.NewStringField(aFieldAuthTokenClientID).
Description("The client ID to use for OAUTHBEARER token acquisition.").
Default(""),
service.NewStringField(aFieldAuthTokenClientSecret).
Expand Down Expand Up @@ -84,7 +84,7 @@ func oAuthFromParsed(conf *service.ParsedConfig) (res OAuthConfig, err error) {
if res.TokenEndpoint, err = conf.FieldString(aFieldAuthTokenEndpoint); err != nil {
return
}
if res.ClientId, err = conf.FieldString(aFieldAuthTokenClientId); err != nil {
if res.ClientID, err = conf.FieldString(aFieldAuthTokenClientID); err != nil {
return
}
if res.ClientSecret, err = conf.FieldString(aFieldAuthTokenClientSecret); err != nil {
Expand All @@ -103,7 +103,7 @@ type OAuthConfig struct {
TokenCacheName string
TokenCacheKey string
TokenEndpoint string
ClientId string
ClientID string
ClientSecret string
Scope string
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (c *OAuthConfig) GetCachedToken(mgr *service.Resources) (*oauth2.Token, err

func (c *OAuthConfig) GetToken(ctx context.Context) (*oauth2.Token, error) {

authHeaderValue := base64.StdEncoding.EncodeToString([]byte(c.ClientId + ":" + c.ClientSecret))
authHeaderValue := base64.StdEncoding.EncodeToString([]byte(c.ClientID + ":" + c.ClientSecret))

queryParams := url.Values{}
queryParams.Set("grant_type", "client_credentials")
Expand Down Expand Up @@ -188,7 +188,7 @@ func NewOAuth2Config() OAuthConfig {
TokenCacheName: "",
TokenCacheKey: "",
TokenEndpoint: "",
ClientId: "",
ClientID: "",
ClientSecret: "",
Scope: "",
}
Expand Down

0 comments on commit 7743a61

Please sign in to comment.