Skip to content
This repository was archived by the owner on Jul 5, 2021. It is now read-only.

Commit 2c1196f

Browse files
committed
review notes
1 parent e1b42a2 commit 2c1196f

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/onsi/gomega v1.10.2
1818
github.com/prometheus/common v0.13.0
1919
github.com/smartystreets/goconvey v1.6.4
20-
github.com/versent/unicreds v1.5.0
20+
github.com/versent/unicreds v1.5.1-0.20180327234242-7135c859e003
2121
github.com/xanzy/go-gitlab v0.39.0
2222
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
2323
google.golang.org/api v0.32.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
599599
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
600600
github.com/versent/unicreds v1.5.0 h1:ad9QWGahpc/Ra0gjTtxhPD/2zZ6Ly4k48owUxWz2qqs=
601601
github.com/versent/unicreds v1.5.0/go.mod h1:WGxBysez8YlQVyZy3+p7JpgFnNEQVasqcHRVH8ICG/8=
602+
github.com/versent/unicreds v1.5.1-0.20180327234242-7135c859e003 h1:RPAOPj8OLmwZEPeggLPXkp9chvfroheXnzLRjPKEfgI=
603+
github.com/versent/unicreds v1.5.1-0.20180327234242-7135c859e003/go.mod h1:WGxBysez8YlQVyZy3+p7JpgFnNEQVasqcHRVH8ICG/8=
602604
github.com/xanzy/go-gitlab v0.39.0 h1:7aiZ03fJfCdqoHFhsZq/SoVYp2lR91hfYWmiXLOU5Qo=
603605
github.com/xanzy/go-gitlab v0.39.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug=
604606
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=

pkg/credstash/backend.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,41 @@ var (
2626
configEncryptionContext = make(map[string]string)
2727
)
2828

29-
// SecretManagerClient will be our unicreds client
30-
type SecretManagerClient interface {
29+
// SecretManagerClientProvider will be our unicreds client
30+
type SecretManagerClientProvider interface {
3131
SetKMSConfig(config *aws.Config)
3232
SetDynamoDBConfig(config *aws.Config)
3333
GetHighestVersionSecret(tableName *string, name string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error)
3434
GetSecret(tableName *string, name string, version string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error)
3535
}
3636

37-
// SecretManagerClientStruct defining this struct to write methods for it
38-
type SecretManagerClientStruct struct {
37+
// SecretManagerClient defining this struct to write methods for it
38+
type SecretManagerClient struct {
3939
}
4040

4141
// SetKMSConfig sets configuration for KMS access
42-
func (s SecretManagerClientStruct) SetKMSConfig(config *aws.Config) {
42+
func (s SecretManagerClient) SetKMSConfig(config *aws.Config) {
4343
unicreds.SetKMSConfig(config)
4444
}
4545

4646
// SetDynamoDBConfig sets configuration for DynamoDB access
47-
func (s SecretManagerClientStruct) SetDynamoDBConfig(config *aws.Config) {
47+
func (s SecretManagerClient) SetDynamoDBConfig(config *aws.Config) {
4848
unicreds.SetDynamoDBConfig(config)
4949
}
5050

5151
// GetHighestVersionSecret gets a secret with latest version from credstash
52-
func (s SecretManagerClientStruct) GetHighestVersionSecret(tableName *string, name string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error) {
52+
func (s SecretManagerClient) GetHighestVersionSecret(tableName *string, name string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error) {
5353
return unicreds.GetHighestVersionSecret(tableName, name, encContext)
5454
}
5555

5656
// GetSecret gets a secret with specific version from credstash
57-
func (s SecretManagerClientStruct) GetSecret(tableName *string, name string, version string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error) {
57+
func (s SecretManagerClient) GetSecret(tableName *string, name string, version string, encContext *unicreds.EncryptionContextValue) (*unicreds.DecryptedCredential, error) {
5858
return unicreds.GetSecret(tableName, name, version, encContext)
5959
}
6060

6161
// Backend represents a backend for Credstash
6262
type Backend struct {
63-
SecretsManager SecretManagerClient
63+
SecretsManager SecretManagerClientProvider
6464
session *session.Session
6565
}
6666

@@ -76,6 +76,7 @@ func NewBackend() backend.Backend {
7676
// Init initializes the Backend for Credstash
7777
func (s *Backend) Init(parameters map[string]interface{}, credentials []byte) error {
7878
var err error
79+
s.SecretsManager = SecretManagerClient{}
7980

8081
s.session, err = utils.GetAWSSession(parameters, credentials, defaultRegion)
8182
if err != nil {
@@ -93,7 +94,6 @@ func (s *Backend) Init(parameters map[string]interface{}, credentials []byte) er
9394
log.Info("Not using security encryption context. Consider using it")
9495
}
9596

96-
s.SecretsManager = SecretManagerClientStruct{}
9797
s.SecretsManager.SetKMSConfig(s.session.Config)
9898
s.SecretsManager.SetDynamoDBConfig(s.session.Config)
9999
return nil

0 commit comments

Comments
 (0)