mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-26 14:01:39 +01:00
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>
28 lines
627 B
Go
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
|
|
}
|