feat: auto detect hostname
This commit is contained in:
parent
2c27823e18
commit
c0baf4fa3b
13 changed files with 300 additions and 125 deletions
|
|
@ -87,7 +87,14 @@ func (c *Config) SaveToPath(path string) error {
|
|||
return os.WriteFile(path, data, 0600)
|
||||
}
|
||||
|
||||
func (c *Config) GetHost(hostname string) (HostConfig, error) {
|
||||
// GetHost resolves the hostname to use for API client creation.
|
||||
// Priority order:
|
||||
// 1. Explicitly provided hostname parameter
|
||||
// 2. CLI flag (--hostname)
|
||||
// 3. Environment variable (FGJ_HOST)
|
||||
// 4. Auto-detected hostname from git remote
|
||||
// 5. Default to codeberg.org
|
||||
func (c *Config) GetHost(hostname string, detectedHost string) (HostConfig, error) {
|
||||
if hostname == "" {
|
||||
hostname = viper.GetString("hostname")
|
||||
}
|
||||
|
|
@ -96,6 +103,10 @@ func (c *Config) GetHost(hostname string) (HostConfig, error) {
|
|||
hostname = os.Getenv("FGJ_HOST")
|
||||
}
|
||||
|
||||
if hostname == "" {
|
||||
hostname = detectedHost
|
||||
}
|
||||
|
||||
if hostname == "" {
|
||||
hostname = "codeberg.org"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue