Documentation
¶
Index ¶
- func FetchCaptainIDs(configs FullConfig) string
- func FetchKeyValues(configs FullConfig, captainID string) (string, error)
- func FetchSection(configs FullConfig, captainID, section string) (string, error)
- func FetchSpecificKey(configs FullConfig, captainID, section, key string) (string, error)
- func SaveConfig(configs FullConfig) error
- func SaveConfigTo(path string, configs FullConfig) error
- type CaptainConfig
- type FullConfig
- type SystemConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchCaptainIDs ¶
func FetchCaptainIDs(configs FullConfig) string
FetchCaptainIDs returns a space-separated string of all captain IDs. Matches the output of `configs.php fetch-captain-ids`.
func FetchKeyValues ¶
func FetchKeyValues(configs FullConfig, captainID string) (string, error)
FetchKeyValues returns KEY=VALUE pairs for the given captain ID. This replicates the output of `configs.php fetch` exactly.
func FetchSection ¶
func FetchSection(configs FullConfig, captainID, section string) (string, error)
FetchSection returns JSON for an entire section (keys, remotes, vars).
func FetchSpecificKey ¶
func FetchSpecificKey(configs FullConfig, captainID, section, key string) (string, error)
FetchSpecificKey returns a specific key's value, e.g. `configs.php fetch vars captaincore_api`.
func SaveConfig ¶
func SaveConfig(configs FullConfig) error
SaveConfig writes configs back to ~/.captaincore/config.json.
func SaveConfigTo ¶
func SaveConfigTo(path string, configs FullConfig) error
SaveConfigTo writes configs to a specific path with 0600 permissions.
Types ¶
type CaptainConfig ¶
type CaptainConfig struct {
CaptainID string `json:"captain_id,omitempty"`
System *SystemConfig `json:"system,omitempty"`
SystemRaw map[string]interface{} `json:"-"` // all system fields for dynamic KEY=VALUE output
Keys map[string]string `json:"keys,omitempty"`
Remotes map[string]string `json:"remotes,omitempty"`
Vars map[string]json.RawMessage `json:"vars,omitempty"`
}
CaptainConfig holds a captain-specific configuration entry from config.json.
func (CaptainConfig) MarshalJSON ¶
func (c CaptainConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling for CaptainConfig. When SystemRaw is populated, it merges typed SystemConfig fields with any extra fields from the original JSON, preventing unknown system fields (like rclone_archive) from being silently dropped during save.
type FullConfig ¶
type FullConfig []CaptainConfig
FullConfig represents the entire config.json array.
func LoadConfig ¶
func LoadConfig() (FullConfig, error)
LoadConfig reads and parses config.json from the user's home directory.
func LoadConfigFrom ¶
func LoadConfigFrom(path string) (FullConfig, error)
LoadConfigFrom reads and parses config.json from a specific path.
func (FullConfig) GetCaptain ¶
func (c FullConfig) GetCaptain(captainID string) *CaptainConfig
GetCaptain returns the captain config matching the given captain ID.
func (FullConfig) GetSystem ¶
func (c FullConfig) GetSystem() *SystemConfig
GetSystem returns the system configuration (first entry with system key).
func (FullConfig) GetSystemRaw ¶
func (c FullConfig) GetSystemRaw() map[string]interface{}
GetSystemRaw returns the raw system map (all fields) for dynamic KEY=VALUE output.
type SystemConfig ¶
type SystemConfig struct {
CaptainCoreFleet string `json:"captaincore_fleet"`
CaptainCoreDev string `json:"captaincore_dev"`
CaptainCoreMaster string `json:"captaincore_master"`
CaptainCoreMasterPort string `json:"captaincore_master_port"`
Logs string `json:"logs"`
Path string `json:"path"`
PathTmp string `json:"path_tmp"`
PathScripts string `json:"path_scripts"`
PathKeys string `json:"path_keys"`
PathRecipes string `json:"path_recipes"`
RcloneBackup string `json:"rclone_backup"`
RcloneCLIBackup string `json:"rclone_cli_backup"`
RcloneSnapshot string `json:"rclone_snapshot"`
RcloneUpload string `json:"rclone_upload"`
RcloneUploadURI string `json:"rclone_upload_uri"`
FathomAPIKey string `json:"fathom_api_key"`
LocalWPDBPW string `json:"local_wp_db_pw"`
CaptainCoreStandby string `json:"captaincore_standby"`
}
SystemConfig holds the system-level configuration (first entry in config.json).