@@ -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
6262type 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
7777func (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