resource_missing_tags: rewrite to only consider keys #517
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rewrites the
resource_missing_tags
rule to explicitly deal with slices of keys instead of maps. In doing so, it acknowledges that keys may be unknown, which should fix #516 (in theory). When unknown keys are found we should return early and skip checking that resource. This PR also refactors thiscty.Value
to[]string
logic out as it was previously duplicated in two locations.While a map would be more efficient and
map[string]struct{}
approximates a set in Go, the sizes are small enough that the clearer code of slices makes more sense. There was a bunch of wasted effort (and bugs) in dealing with tag values when ultimately we don't care about the tag values at all, just the keys. In cases where we're merging two lists of tag keys there's no need to de-duplicate as ultimately we are just looking at whether the slice contains our tag of interest.It's not actually possible to test this currently as it's impossible to produce an unknown map value within what's allowed by the test runner, as far as I can tell.
This won't work:
Errors with: