Skip to content

Commit 6a2252e

Browse files
authored
fix: add tags function (#37)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 88cfbd8 commit 6a2252e

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

pkg/tags/sync.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func SyncTags(
8686
}
8787
}
8888

89-
for k, _ := range existingTags {
89+
for k := range existingTags {
9090
if _, found := desiredTags[k]; !found {
9191
deleteKey := k
9292
toDelete = append(toDelete, deleteKey)
@@ -136,7 +136,7 @@ func addTags(
136136
exit := rlog.Trace("rm.addTag")
137137
defer func() { exit(err) }()
138138

139-
sdkTags := []svcsdktypes.Tag{}
139+
sdkTags := toSdkTags(tags)
140140
input := &svcsdk.TagResourceInput{
141141
ResourceId: &resourceID,
142142
Tags: sdkTags,
@@ -166,3 +166,11 @@ func removeTags(
166166
mr.RecordAPICall("UPDATE", "UntagResource", err)
167167
return err
168168
}
169+
170+
func toSdkTags(tags map[string]*string) []svcsdktypes.Tag {
171+
sdkTags := []svcsdktypes.Tag{}
172+
for key, val := range tags {
173+
sdkTags = append(sdkTags, svcsdktypes.Tag{Key: &key, Value: val})
174+
}
175+
return sdkTags
176+
}

test/e2e/tests/test_file_system.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import json
2121

2222
from acktest.resources import random_suffix_name
23+
from acktest import tags
2324
from acktest.k8s import resource as k8s
2425

2526
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_efs_resource
@@ -179,4 +180,37 @@ def test_update_lifecycle_policies(self, efs_client, simple_file_system):
179180

180181
lfps = validator.get_file_system_lifecycle_policy(file_system_id)
181182
assert lfps is not None
182-
assert lfps[0]['TransitionToIA'] == "AFTER_30_DAYS"
183+
assert lfps[0]['TransitionToIA'] == "AFTER_30_DAYS"
184+
185+
def test_update_tags(self, efs_client, simple_file_system):
186+
(ref, _, file_system_id) = simple_file_system
187+
assert file_system_id is not None
188+
189+
validator = EFSValidator(efs_client)
190+
assert validator.file_system_exists(file_system_id)
191+
192+
desired_tags = [{
193+
"key": "Name",
194+
"value": "foobar"
195+
}]
196+
updates = {
197+
"spec": {
198+
"tags": desired_tags,
199+
},
200+
}
201+
k8s.patch_custom_resource(ref, updates)
202+
time.sleep(UPDATE_WAIT_AFTER_SECONDS)
203+
204+
fs = validator.get_file_system(file_system_id)
205+
assert fs is not None
206+
latest_tags = fs['FileSystems'][0]["Tags"]
207+
208+
tags.assert_ack_system_tags(
209+
tags=latest_tags
210+
)
211+
212+
desired_tags = [{"Key": d["key"], "Value": d["value"]} for d in desired_tags]
213+
tags.assert_equal_without_ack_tags(
214+
expected=desired_tags,
215+
actual=latest_tags
216+
)

0 commit comments

Comments
 (0)