diff options
| author | bndw <ben@bdw.to> | 2026-01-23 21:10:04 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-01-23 21:10:04 -0800 |
| commit | b5d97f633c960a826577fd80cb1d29e392dce34b (patch) | |
| tree | 312b934506f835bcc77c4dcbb9e38a27efbf1528 /internal/state/state.go | |
| parent | 98b9af372025595e8a4255538e2836e019311474 (diff) | |
Move default host from config file to state.json
Instead of a separate ~/.config/deploy/config file, the default host
is now stored as default_host in state.json. This simplifies the
config and keeps all state in one place.
The init command now automatically sets the default host if none
is configured.
Diffstat (limited to 'internal/state/state.go')
| -rw-r--r-- | internal/state/state.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/state/state.go b/internal/state/state.go index eb1dee8..def0bcf 100644 --- a/internal/state/state.go +++ b/internal/state/state.go | |||
| @@ -9,7 +9,8 @@ import ( | |||
| 9 | 9 | ||
| 10 | // State represents the entire local deployment state | 10 | // State represents the entire local deployment state |
| 11 | type State struct { | 11 | type State struct { |
| 12 | Hosts map[string]*Host `json:"hosts"` | 12 | DefaultHost string `json:"default_host,omitempty"` |
| 13 | Hosts map[string]*Host `json:"hosts"` | ||
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | // Host represents deployment state for a single VPS | 16 | // Host represents deployment state for a single VPS |
| @@ -137,6 +138,16 @@ func (s *State) ListApps(host string) map[string]*App { | |||
| 137 | return h.Apps | 138 | return h.Apps |
| 138 | } | 139 | } |
| 139 | 140 | ||
| 141 | // GetDefaultHost returns the default host, or empty string if not set | ||
| 142 | func (s *State) GetDefaultHost() string { | ||
| 143 | return s.DefaultHost | ||
| 144 | } | ||
| 145 | |||
| 146 | // SetDefaultHost sets the default host | ||
| 147 | func (s *State) SetDefaultHost(host string) { | ||
| 148 | s.DefaultHost = host | ||
| 149 | } | ||
| 150 | |||
| 140 | // statePath returns the path to the state file | 151 | // statePath returns the path to the state file |
| 141 | func statePath() string { | 152 | func statePath() string { |
| 142 | home, err := os.UserHomeDir() | 153 | home, err := os.UserHomeDir() |
