- Add .gitignore: exclude compiled binaries, build artifacts, and Helm values files containing real secrets (authentik, prometheus) - Add all Kubernetes deployment manifests (deployment/) - Add services source code: ha-sync, device-inventory, games-console, paperclip, parts-inventory - Add Ansible orchestration: playbooks, roles, inventory, cloud-init - Add hardware specs, execution plans, scripts, HOMELAB.md - Add skills/homelab/SKILL.md + skills/install.sh to preserve Copilot skill - Remove previously-tracked inventory-cli binary from git index Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
44 lines
781 B
Go
44 lines
781 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
const defaultAPIURL = "http://192.168.2.100:31600"
|
|
|
|
type Config struct {
|
|
APIURL string `yaml:"api_url"`
|
|
}
|
|
|
|
// GetAPIURL returns the API URL from env, then config file, then default.
|
|
func GetAPIURL(apiURLFlag string) string {
|
|
if apiURLFlag != "" {
|
|
return apiURLFlag
|
|
}
|
|
if v := os.Getenv("GCONSOLE_API_URL"); v != "" {
|
|
return v
|
|
}
|
|
cfg := loadConfig()
|
|
if cfg.APIURL != "" {
|
|
return cfg.APIURL
|
|
}
|
|
return defaultAPIURL
|
|
}
|
|
|
|
func loadConfig() Config {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return Config{}
|
|
}
|
|
path := filepath.Join(home, ".gconsole", "config.yaml")
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return Config{}
|
|
}
|
|
var cfg Config
|
|
yaml.Unmarshal(data, &cfg)
|
|
return cfg
|
|
}
|