117 lines
3.6 KiB
Go
117 lines
3.6 KiB
Go
package config
|
|
|
|
import "forge.cadoles.com/Cadoles/emissary/internal/agent/controller/openwrt"
|
|
|
|
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"`
|
|
}
|
|
|
|
type ControllersConfig struct {
|
|
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"`
|
|
}
|
|
|
|
type PersistenceControllerConfig struct {
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
StateFile InterpolatedString `yaml:"stateFile"`
|
|
}
|
|
|
|
type SpecControllerConfig struct {
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
}
|
|
type ProxyControllerConfig struct {
|
|
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"`
|
|
}
|
|
|
|
type MDNSControllerConfig struct {
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
}
|
|
|
|
type RegistrationControllerConfig struct {
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
Address InterpolatedString `yaml:"address"`
|
|
}
|
|
|
|
func NewDefaultAgentConfig() AgentConfig {
|
|
return AgentConfig{
|
|
ServerURL: "http://127.0.0.1:3000",
|
|
PrivateKeyPath: "agent-key.json",
|
|
ReconciliationInterval: 5,
|
|
Controllers: ControllersConfig{
|
|
Spec: SpecControllerConfig{
|
|
Enabled: true,
|
|
},
|
|
Persistence: PersistenceControllerConfig{
|
|
Enabled: true,
|
|
StateFile: "state.json",
|
|
},
|
|
Proxy: ProxyControllerConfig{
|
|
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"`},
|
|
},
|
|
MDNS: MDNSControllerConfig{
|
|
Enabled: true,
|
|
},
|
|
Registration: RegistrationControllerConfig{
|
|
Enabled: true,
|
|
Address: ":42521",
|
|
},
|
|
},
|
|
Collectors: []ShellCollectorConfig{
|
|
{
|
|
Name: "uname",
|
|
Command: "uname",
|
|
Args: []string{"-a"},
|
|
},
|
|
},
|
|
}
|
|
}
|