feat: auto detect hostname

This commit is contained in:
Romain Bertrand 2026-01-05 12:47:28 +01:00
parent 2c27823e18
commit c0baf4fa3b
13 changed files with 300 additions and 125 deletions

View file

@ -33,8 +33,8 @@ func NewClient(hostname, token string) (*Client, error) {
}, nil
}
func NewClientFromConfig(cfg *config.Config, hostname string) (*Client, error) {
host, err := cfg.GetHost(hostname)
func NewClientFromConfig(cfg *config.Config, hostname string, detectedHost string) (*Client, error) {
host, err := cfg.GetHost(hostname, detectedHost)
if err != nil {
return nil, err
}

View file

@ -21,7 +21,7 @@ func TestNewClientFromConfig_MissingHost(t *testing.T) {
Hosts: map[string]config.HostConfig{},
}
_, err := NewClientFromConfig(cfg, "nonexistent.org")
_, err := NewClientFromConfig(cfg, "nonexistent.org", "")
if err == nil {
t.Error("Expected error for nonexistent host")
}