emissary/internal/spec/proxy/spec.go

46 lines
818 B
Go
Raw Normal View History

2023-03-21 13:28:41 +01:00
package proxy
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
2023-03-21 13:28:41 +01:00
const NameProxy spec.Name = "proxy.emissary.cadoles.com"
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) SpecName() spec.Name {
2023-03-21 13:28:41 +01:00
return NameProxy
}
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{}