2023-02-28 15:50:35 +01:00
|
|
|
package uci
|
2023-02-02 10:55:24 +01:00
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
import (
|
|
|
|
"forge.cadoles.com/Cadoles/emissary/internal/openwrt/uci"
|
|
|
|
"forge.cadoles.com/Cadoles/emissary/internal/spec"
|
|
|
|
)
|
2023-02-02 10:55:24 +01:00
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
const NameUCI spec.Name = "uci.emissary.cadoles.com"
|
2023-02-02 10:55:24 +01:00
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
type Spec struct {
|
2023-03-21 15:21:19 +01:00
|
|
|
Revision int `json:"revision"`
|
2023-02-02 10:55:24 +01:00
|
|
|
Config *uci.UCI `json:"config"`
|
|
|
|
PostImportCommands []*UCIPostImportCommand `json:"postImportCommands"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UCIPostImportCommand struct {
|
|
|
|
Command string `json:"command"`
|
|
|
|
Args []string `json:"args"`
|
|
|
|
}
|
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
func (s *Spec) SpecName() spec.Name {
|
2023-02-02 10:55:24 +01:00
|
|
|
return NameUCI
|
|
|
|
}
|
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
func (s *Spec) SpecRevision() int {
|
|
|
|
return s.Revision
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
|
|
|
|
2023-03-03 20:37:09 +01:00
|
|
|
func (s *Spec) SpecData() map[string]any {
|
|
|
|
return map[string]any{
|
|
|
|
"config": s.Config,
|
|
|
|
"postImportCommands": s.PostImportCommands,
|
|
|
|
}
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
|
|
|
|
2023-02-28 15:50:35 +01:00
|
|
|
func NewSpec() *Spec {
|
|
|
|
return &Spec{
|
2023-03-13 10:44:58 +01:00
|
|
|
Revision: -1,
|
2023-02-02 10:55:24 +01:00
|
|
|
PostImportCommands: make([]*UCIPostImportCommand, 0),
|
|
|
|
}
|
|
|
|
}
|
2023-03-03 20:37:09 +01:00
|
|
|
|
|
|
|
var _ spec.Spec = &Spec{}
|