-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
38 lines (30 loc) · 899 Bytes
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package rediselasticache
import (
"os"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/database/dbplugin/v5"
)
func New() (interface{}, error) {
logger := hclog.New(&hclog.LoggerOptions{
Level: hclog.Trace,
Output: os.Stderr,
JSONFormat: true,
})
db := &redisElastiCacheDB{
logger: logger,
}
return wrapWithSanitizerMiddleware(db), nil
}
func wrapWithSanitizerMiddleware(db *redisElastiCacheDB) dbplugin.Database {
return dbplugin.NewDatabaseErrorSanitizerMiddleware(db, db.secretValuesToMask)
}
func (r *redisElastiCacheDB) secretValuesToMask() map[string]string {
return map[string]string{
r.config.Password: "[password]",
r.config.Username: "[username]",
r.config.AccessKeyID: "[access_key_id]",
r.config.SecretAccessKey: "[secret_access_key]",
}
}