emissary/internal/config/agent.go

117 lines
3.6 KiB
Go
Raw Normal View History

2023-02-02 10:55:24 +01:00
package config
import "forge.cadoles.com/Cadoles/emissary/internal/agent/controller/openwrt"
2023-02-02 10:55:24 +01:00
type AgentConfig struct {
ServerURL InterpolatedString `yaml:"serverUrl"`
PrivateKeyPath InterpolatedString `yaml:"privateKeyPath"`
ReconciliationInterval InterpolatedInt `yaml:"reconciliationInterval"`
Controllers ControllersConfig `yaml:"controllers"`
Collectors []ShellCollectorConfig `yaml:"collectors"`
}
type ShellCollectorConfig struct {
Name InterpolatedString `yaml:"name"`
Command InterpolatedString `yaml:"command"`
Args InterpolatedStringSlice `yaml:"args"`
2023-02-02 10:55:24 +01:00
}
type ControllersConfig struct {
2024-02-29 17:17:21 +01:00
Persistence PersistenceControllerConfig `yaml:"persistence"`
Spec SpecControllerConfig `yaml:"spec"`
Proxy ProxyControllerConfig `yaml:"proxy"`
UCI UCIControllerConfig `yaml:"uci"`
App AppControllerConfig `yaml:"app"`
SysUpgrade SysUpgradeControllerConfig `yaml:"sysupgrade"`
MDNS MDNSControllerConfig `yaml:"mdns"`
Registration RegistrationControllerConfig `yaml:"registration"`
2023-02-02 10:55:24 +01:00
}
type PersistenceControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
StateFile InterpolatedString `yaml:"stateFile"`
}
type SpecControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
2023-02-02 10:55:24 +01:00
}
2023-03-21 13:28:41 +01:00
type ProxyControllerConfig struct {
2023-02-02 10:55:24 +01:00
Enabled InterpolatedBool `yaml:"enabled"`
}
type UCIControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
BinPath InterpolatedString `yaml:"binPath"`
ConfigBackupFile InterpolatedString `yaml:"configBackupFile"`
}
type AppControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
DataDir InterpolatedString `yaml:"dataDir"`
DownloadDir InterpolatedString `yaml:"downloadDir"`
}
type SysUpgradeControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
SysUpgradeCommand InterpolatedStringSlice `yaml:"sysupgradeCommand"`
FirmwareVersionCommand InterpolatedStringSlice `yaml:"firmwareVersionCommand"`
}
2023-04-04 20:26:19 +02:00
type MDNSControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
}
2024-02-29 17:17:21 +01:00
type RegistrationControllerConfig struct {
Enabled InterpolatedBool `yaml:"enabled"`
Address InterpolatedString `yaml:"address"`
}
2023-02-02 10:55:24 +01:00
func NewDefaultAgentConfig() AgentConfig {
return AgentConfig{
ServerURL: "http://127.0.0.1:3000",
PrivateKeyPath: "agent-key.json",
2023-02-02 10:55:24 +01:00
ReconciliationInterval: 5,
Controllers: ControllersConfig{
Spec: SpecControllerConfig{
Enabled: true,
2023-02-02 10:55:24 +01:00
},
Persistence: PersistenceControllerConfig{
Enabled: true,
StateFile: "state.json",
},
2023-03-21 13:28:41 +01:00
Proxy: ProxyControllerConfig{
2023-02-02 10:55:24 +01:00
Enabled: true,
},
UCI: UCIControllerConfig{
Enabled: true,
ConfigBackupFile: "uci-backup.conf",
BinPath: "uci",
},
App: AppControllerConfig{
Enabled: true,
DataDir: "apps/data",
DownloadDir: "apps/bundles",
},
SysUpgrade: SysUpgradeControllerConfig{
Enabled: true,
SysUpgradeCommand: InterpolatedStringSlice{"sysupgrade", "--force", "-u", "-v", openwrt.FirmwareFileTemplate},
FirmwareVersionCommand: InterpolatedStringSlice{"sh", "-c", `source /etc/openwrt_release && echo "$DISTRIB_ID-$DISTRIB_RELEASE-$DISTRIB_REVISION"`},
},
2023-04-04 20:26:19 +02:00
MDNS: MDNSControllerConfig{
Enabled: true,
},
2024-02-29 17:17:21 +01:00
Registration: RegistrationControllerConfig{
Enabled: true,
Address: ":42521",
},
2023-02-02 10:55:24 +01:00
},
Collectors: []ShellCollectorConfig{
{
Name: "uname",
Command: "uname",
Args: []string{"-a"},
},
},
2023-02-02 10:55:24 +01:00
}
}