emissary/internal/spec/proxy/spec.go

53 lines
913 B
Go
Raw Normal View History

2023-03-21 13:28:41 +01:00
package proxy
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
const (
Name string = "proxy.emissary.cadoles.com"
Version = "0.0.0"
)
type ID string
type Spec struct {
2023-03-21 13:28:41 +01:00
Revision int `json:"revision"`
Proxies map[ID]ProxyEntry `json:"proxies"`
}
2023-03-21 13:28:41 +01:00
type ProxyEntry struct {
2023-03-22 18:15:22 +01:00
Address string `json:"address"`
Mappings []ProxyMapping `json:"mappings"`
}
type ProxyMapping struct {
HostPattern string `json:"hostPattern"`
Target string `json:"target"`
}
func (s *Spec) SpecDefinitionName() string {
return Name
}
func (s *Spec) SpecDefinitionVersion() string {
return Version
}
func (s *Spec) SpecRevision() int {
return s.Revision
}
func (s *Spec) SpecData() map[string]any {
return map[string]any{
2023-03-21 13:28:41 +01:00
"proxies": s.Proxies,
}
}
func NewSpec() *Spec {
return &Spec{
2023-03-13 10:44:58 +01:00
Revision: -1,
2023-03-21 13:28:41 +01:00
Proxies: make(map[ID]ProxyEntry),
}
}
var _ spec.Spec = &Spec{}