emissary/internal/spec/uci/spec.go

41 lines
975 B
Go
Raw Normal View History

package uci
2023-02-02 10:55:24 +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
const NameUCI spec.Name = "uci.emissary.cadoles.com"
2023-02-02 10:55:24 +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"`
}
func (s *Spec) SpecName() spec.Name {
2023-02-02 10:55:24 +01:00
return NameUCI
}
func (s *Spec) SpecRevision() int {
return s.Revision
2023-02-02 10:55:24 +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"`
}{Config: s.Config, PostImportCommands: s.PostImportCommands}
2023-02-02 10:55:24 +01:00
}
func NewSpec() *Spec {
return &Spec{
2023-02-02 10:55:24 +01:00
PostImportCommands: make([]*UCIPostImportCommand, 0),
}
}