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-02-02 10:55:24 +01:00
|
|
|
Revision int `json:"revisions"`
|
|
|
|
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-02-28 15:50:35 +01:00
|
|
|
func (s *Spec) SpecData() any {
|
2023-02-02 10:55:24 +01:00
|
|
|
return struct {
|
|
|
|
Config *uci.UCI `json:"config"`
|
|
|
|
PostImportCommands []*UCIPostImportCommand `json:"postImportCommands"`
|
2023-02-28 15:50:35 +01:00
|
|
|
}{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-02-02 10:55:24 +01:00
|
|
|
PostImportCommands: make([]*UCIPostImportCommand, 0),
|
|
|
|
}
|
|
|
|
}
|