Skip to content

Commit

Permalink
Merge pull request #4 from PaddleHQ/make-parameters-more-testable
Browse files Browse the repository at this point in the history
Make Parameters unaware of aws
  • Loading branch information
geototti21 authored May 22, 2019
2 parents 7edf1ce + 4bd3803 commit be5d8fb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ import (
"io"
"strings"

"github.com/aws/aws-sdk-go/service/ssm"
"github.com/mitchellh/mapstructure"
)

//Parameter holds a Systems Manager parameter from AWS Parameter Store
type Parameter struct {
ssmParameter *ssm.Parameter
Value *string
}

//GetValue return the actual value of the parameter
//GetValue return the actual Value of the parameter
func (p *Parameter) GetValue() string {
if p.ssmParameter.Value == nil {
if p.Value == nil {
return ""
}
return *p.ssmParameter.Value
return *p.Value
}

//NewParameters creates a Parameters
Expand Down
2 changes: 1 addition & 1 deletion parameter_store_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c *ParameterStore) getParameters(input *ssm.GetParametersByPathInput) (*Pa
if v.Name == nil {
continue
}
parameters.parameters[*v.Name] = &Parameter{ssmParameter: v}
parameters.parameters[*v.Name] = &Parameter{Value: v.Value}
}
return parameters, nil
}
Expand Down
4 changes: 2 additions & 2 deletions parameter_store_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestClient_GetParametersByPath(t *testing.T) {
expectedOutput: &Parameters{
basePath: "/my-service/dev/",
parameters: map[string]*Parameter{
"/my-service/dev/DB_PASSWORD": {ssmParameter: param1},
"/my-service/dev/DB_HOST": {ssmParameter: param2},
"/my-service/dev/DB_PASSWORD": {Value: param1.Value},
"/my-service/dev/DB_HOST": {Value: param2.Value},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestParameters_Decode(t *testing.T) {

func getParametersMap() map[string]*Parameter {
return map[string]*Parameter{
"/my-service/dev/DB_PASSWORD": {ssmParameter: param1},
"/my-service/dev/DB_HOST": {ssmParameter: param2},
"/my-service/dev/DB_PASSWORD": {Value: param1.Value},
"/my-service/dev/DB_HOST": {Value: param2.Value},
}
}

0 comments on commit be5d8fb

Please sign in to comment.