mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix: pass context into secrets logs (#95944)
This commit is contained in:
parent
3c1a5ab439
commit
f15f6022de
@ -105,7 +105,7 @@ func (s *Service) Decrypt(ctx context.Context, payload []byte, secret string) ([
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
s.log.Error("Decryption failed", "error", err)
|
||||
s.log.FromContext(ctx).Error("Decryption failed", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -331,7 +331,7 @@ func (s *SecretsService) Decrypt(ctx context.Context, payload []byte) ([]byte, e
|
||||
}).Inc()
|
||||
|
||||
if err != nil {
|
||||
s.log.Error("Failed to decrypt secret", "error", err)
|
||||
s.log.FromContext(ctx).Error("Failed to decrypt secret", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -371,7 +371,7 @@ func (s *SecretsService) Decrypt(ctx context.Context, payload []byte) ([]byte, e
|
||||
|
||||
dataKey, err = s.dataKeyById(ctx, string(keyId))
|
||||
if err != nil {
|
||||
s.log.Error("Failed to lookup data key by id", "id", string(keyId), "error", err)
|
||||
s.log.FromContext(ctx).Error("Failed to lookup data key by id", "id", string(keyId), "error", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -436,19 +436,19 @@ func (s *Service) decryptSecrets(ctx context.Context, settings map[string]any) (
|
||||
if IsSecretField(k) && v != "" {
|
||||
strValue, ok := v.(string)
|
||||
if !ok {
|
||||
s.logger.Error("Failed to parse secret value, it is not a string", "key", k)
|
||||
s.logger.FromContext(ctx).Error("Failed to parse secret value, it is not a string", "key", k)
|
||||
return nil, fmt.Errorf("secret value is not a string")
|
||||
}
|
||||
|
||||
decoded, err := base64.RawStdEncoding.DecodeString(strValue)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to decode secret string", "err", err, "value")
|
||||
s.logger.FromContext(ctx).Error("Failed to decode secret string", "err", err, "value")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
decrypted, err := s.secrets.Decrypt(ctx, decoded)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to decrypt secret", "err", err)
|
||||
s.logger.FromContext(ctx).Error("Failed to decrypt secret", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user