Skip to content

Commit

Permalink
cilium: Fix variable naming for labels
Browse files Browse the repository at this point in the history
A single IP can only have exactly one identity. Each identity can have a
set of labels associated with it. This code was confusingly using the
variable name 'identities' for individual labels within a single
identity. Rename it for clarity.

(Strictly speaking the labels may not actually be labels but may be the
numeric identity if the user decided not to pretty-print the labels, but
I think this variable naming is still more clear than what preceded it).

Signed-off-by: Joe Stringer <joe@cilium.io>
  • Loading branch information
joestringer committed Oct 11, 2023
1 parent 68327ef commit 5173b4c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cilium-dbg/cmd/ip_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ func printEntry(w *tabwriter.Writer, entry *models.IPListEntry) {

ni := identity.NumericIdentity(*entry.Identity)
identityNumeric := ni.StringID()
var identities []string
var labels []string
if numeric {
identities = append(identities, identityNumeric)
labels = append(labels, identityNumeric)
} else {
identities = append(identities, getLabels(ni)...)
labels = append(labels, getLabels(ni)...)
}
first := true
for _, identity := range identities {
for _, lbl := range labels {
if first {
if verbose {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", *entry.Cidr, identity, src, entry.HostIP, entry.EncryptKey)
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", *entry.Cidr, lbl, src, entry.HostIP, entry.EncryptKey)
} else {
fmt.Fprintf(w, "%s\t%s\t%s\n", *entry.Cidr, identity, src)
fmt.Fprintf(w, "%s\t%s\t%s\n", *entry.Cidr, lbl, src)
}
first = false
} else {
fmt.Fprintf(w, "\t%s\t\n", identity)
fmt.Fprintf(w, "\t%s\t\n", lbl)
}
}
}

0 comments on commit 5173b4c

Please sign in to comment.