Utku Ozdemir 9d34158500
fix: fix graph diffs in dashboard when node aliases are used
When `talosctl dashboard` is used with node "aliases" (e.g., node names or machine IDs in Omni) passed via `-n` flag, the graphs in the monitor tab were not rendered correctly: The matching of the old and current data were done incorrectly.

Fix this by pushing node alias->IP resolution down to the (api & log) data sources of the dashboard, by passing a resolver to them.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
2024-08-07 14:54:32 +02:00

28 lines
627 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Package resolver resolves the node names.
package resolver
// Resolver resolves the node names.
type Resolver struct {
db map[string]string
}
// New creates a new Resolver.
func New(db map[string]string) Resolver {
return Resolver{
db: db,
}
}
// Resolve attempts to resolve the node name.
func (n *Resolver) Resolve(node string) string {
if resolved, ok := n.db[node]; ok {
return resolved
}
return node
}