Skip to content

Commit

Permalink
multicluster: Fix metadata prefix matching (linkerd#7825)
Browse files Browse the repository at this point in the history
When formatting event metadata, the method `formatMetadata` checks if a
given string in the metadata map contains a given prefix. However it
does this using `strings.Contains` rather than `strings.HasPrefix`,
which will return true if the given prefix string is located anywhere in
the target string to search.

Signed-off-by: Oliver Gould <[email protected]>
  • Loading branch information
olix0r authored Feb 8, 2022
1 parent 863a51c commit 9089cc6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion multicluster/service-mirror/events_formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func formatMetadata(meta map[string]string) string {
var metadata []string

for k, v := range meta {
if strings.Contains(k, consts.Prefix) || strings.Contains(k, consts.ProxyConfigAnnotationsPrefix) {
if strings.HasPrefix(k, consts.Prefix) || strings.HasPrefix(k, consts.ProxyConfigAnnotationsPrefix) {
metadata = append(metadata, fmt.Sprintf("%s=%s", k, v))
}
}
Expand Down

0 comments on commit 9089cc6

Please sign in to comment.