feat: auto detect hostname
This commit is contained in:
parent
2c27823e18
commit
c0baf4fa3b
13 changed files with 300 additions and 125 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue