emissary/internal/config/agent.go

99 lines
3.1 KiB
Go
Raw Permalink 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 {
Persistence PersistenceControllerConfig `yaml:"persistence"`
Spec SpecControllerConfig `yaml:"spec"`
2023-03-21 13:28:41 +01:00
Proxy ProxyControllerConfig `yaml:"proxy"`
2023-02-02 10:55:24 +01:00
UCI UCIControllerConfig `yaml:"uci"`
App AppControllerConfig `yaml:"app"`
SysUpgrade SysUpgradeControllerConfig `yaml:"sysupgrade"`
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-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-02-02 10:55:24 +01:00
},
Collectors: []ShellCollectorConfig{
{
Name: "uname",
Command: "uname",
Args: []string{"-a"},
},
},
2023-02-02 10:55:24 +01:00
}
}