Clusters : port 8006 par défaut, liste des cibles jamais null

This commit is contained in:
claude Bot committed 2026-10-23 18:41:59 +02:00
1 parent 8dd2f187ee
commit ee8343c69f
5 files changed
+50 -3

No files matched your search

+12
View File
@@ -216,3 +216,15 @@ func (c *Config) HasKind(k model.Kind) bool {
}
return false
}
// NormalizeURL trims the URL of a cluster and adds the PVE port (8006) when
// none is given: https://pve1 becomes https://pve1:8006.
func NormalizeURL(raw string) string {
s := strings.TrimRight(strings.TrimSpace(raw), "/")
u, err := url.Parse(s)
if err != nil || u.Host == "" || u.Port() != "" {
return s
}
u.Host = net.JoinHostPort(u.Hostname(), "8006")
return u.String()
}
+15
View File
@@ -36,3 +36,18 @@ func TestSSHOptions(t *testing.T) {
t.Fatalf("%+v", o)
}
}
func TestNormalizeURL(t *testing.T) {
for in, want := range map[string]string{
"https://pve1": "https://pve1:8006",
" https://pve1/ ": "https://pve1:8006",
"https://pve1:443": "https://pve1:443",
"https://10.0.0.1": "https://10.0.0.1:8006",
"https://[fd00::1]": "https://[fd00::1]:8006",
"https://pve1:8006/": "https://pve1:8006",
} {
if got := NormalizeURL(in); got != want {
t.Errorf("NormalizeURL(%q) = %q, want %q", in, got, want)
}
}
}