Skip to content

Commit

Permalink
Use aws helper functions instead of directly dereferencing pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamás Michelberger committed Jul 24, 2017
1 parent 2433b14 commit 272b0db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions credstash/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ func getLatestVersion(svc dynamoDB, name, table string) (keyMaterial, error) {
return keyMaterial{}, err
}

if *out.Count == 0 {
return keyMaterial{}, fmt.Errorf("secret with name %s could not be found.", name)
if aws.Int64Value(out.Count) == 0 {
return keyMaterial{}, fmt.Errorf("secret with name %s could not be found", name)
}

return keyMaterialFromDBItem(out.Items[0])
Expand Down Expand Up @@ -258,7 +258,7 @@ func keyMaterialFromDBItem(item map[string]*dynamodb.AttributeValue) (keyMateria
func getDigest(material map[string]*dynamodb.AttributeValue) string {
digest := "SHA256"
if dVal, ok := material["digest"]; ok {
digest = *dVal.S
digest = aws.StringValue(dVal.S)
}

return digest
Expand All @@ -270,7 +270,7 @@ func getString(item map[string]*dynamodb.AttributeValue, key string) (string, er
return "", fmt.Errorf("missing key: %s", key)
}

return *value.S, nil
return aws.StringValue(value.S), nil
}

func getStringAndDecode(item map[string]*dynamodb.AttributeValue, key string, f func(string) ([]byte, error)) ([]byte, error) {
Expand Down

0 comments on commit 272b0db

Please sign in to comment.