Commit ca12303
authored
Add new tag conversion funcitons that preserve order in lists of Tags (#572)
Description of changes:
When converting between ACK tags (map[string]string) and
resource tags(which could be either a list of Tag struct or map[string]*string)
can be tricky. One issue that we found was order preservation, especially when
converting from `map[string]string` to list of `Tag`. The changed order, when
patched to the resource in the cluster, would trigger a reconciliation, for an
unpredictable amount of times (at least until we luckily convert to the list with
a preserved order.)
This change introduces two new functions, similar to the existing ones.
The `toACKTagsWithKeyOrder` has the same function as `ToACKTags`,
but besides returning the ACK tags, it also returns a list of keys in the same
order it is in the resource.
The `fromACKTagsWithKeyOrder`, also similar to `FromACKTags`, accepts
the keyOrder returned by `toACKTagsWithKeyOrder`, and rebuilds the resource
tags, if it's a list, in the same order as it was before. Any extra tags will be added
in random order.
These two new functions will be called before and after `mirrowAWSTags` and
`FilterSystemTags`. The extra tags mentioned earlier are the AWS tags that are
mirrored from the latest resource (more explanation on what they are [here](aws-controllers-k8s/runtime#170)) and will be filtered before getting patched with [this](aws-controllers-k8s/runtime#172)
change.
This will ensure that the tags in desired will maintain their order and avoid triggering
unnecessary reconciliations.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.1 parent 5645e51 commit ca12303
2 files changed
+77
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
| 396 | + | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
65 | 100 | | |
66 | 101 | | |
67 | 102 | | |
| |||
86 | 121 | | |
87 | 122 | | |
88 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
89 | 161 | | |
90 | 162 | | |
91 | 163 | | |
| |||
0 commit comments