Accept --registry as a host alone again, completing it with the registry's port (hq ADR 0100)

This commit is contained in:
2026-09-22 18:08:50 +02:00
parent d59d232656
commit 35ecf68393
2 changed files with 27 additions and 0 deletions
+13
View File
@@ -18,6 +18,7 @@ package main
import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
@@ -239,6 +240,18 @@ func registryAgrees(set *flag.FlagSet, opts *bootstrap.Options) error {
said := map[string]bool{}
set.Visit(func(f *flag.Flag) { said[f.Name] = true })
host, portText, err := net.SplitHostPort(opts.Registry)
var missing *net.AddrError
if errors.As(err, &missing) && missing.Err == "missing port in address" {
// A host alone, as --registry took before its port became the node's: the registry's
// port — the one given, or the catalogue's — completes it.
port := opts.Ports.Registry
if port == 0 {
port = bootstrap.DefaultPorts().Registry
}
opts.Ports.Registry = port
opts.Registry = net.JoinHostPort(strings.Trim(opts.Registry, "[]"), strconv.Itoa(port))
return nil
}
if err != nil {
return fmt.Errorf("--registry %q is not host:port: %w", opts.Registry, err)
}