Skip to content

Commit e75570a

Browse files
fix secret fetching (#9)
During the previous improvements in #6 the prefix was accidentally changed to "secret_" instead of "secrets_". Additionally the tag key was used to look up the value of the secret where it should have been the key value, this has been fixed and tests updated.
1 parent 70ccfd5 commit e75570a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ go.work
2323
.DS_Store
2424
.idea
2525
*.env
26+
27+
fetch-secrets

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const (
2323
timeout = 60 * time.Second
24-
secretTagPrefix = "secret_"
24+
secretTagPrefix = "secrets_"
2525
)
2626

2727
var (
@@ -111,7 +111,7 @@ func getTags(ctx context.Context, iamClient iamClient, role string) ([]string, e
111111
for _, t := range resp.Tags {
112112
tag := *t.Key
113113
if strings.HasPrefix(tag, secretTagPrefix) {
114-
tags = append(tags, tag)
114+
tags = append(tags, *t.Value)
115115
}
116116
}
117117

main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ func (s *FetchSecretsTestSuite) TestGetTags_Success() {
147147
Value: stringPtr("tag-value"),
148148
},
149149
{
150-
Key: stringPtr("secret_tag-key"),
151-
Value: stringPtr("secret-tag-value"),
150+
Key: stringPtr("secrets_tag-key"),
151+
Value: stringPtr("secrets-tag-value"),
152152
},
153153
}
154154

@@ -161,7 +161,7 @@ func (s *FetchSecretsTestSuite) TestGetTags_Success() {
161161
assert.NoError(s.T(), err)
162162
assert.NotEmpty(s.T(), result)
163163
assert.Equal(s.T(), len(result), 1)
164-
assert.Contains(s.T(), result, "secret_tag-key")
164+
assert.Contains(s.T(), result, "secrets-tag-value")
165165
}
166166

167167
func (s *FetchSecretsTestSuite) TestFetchSecretsByID_SecretsError() {

0 commit comments

Comments
 (0)