feat: rename gateway spec to proxy

This commit is contained in:
2023-03-21 13:28:41 +01:00
parent fa36d55163
commit fbcd3ca806
21 changed files with 216 additions and 183 deletions

View File

@ -29,6 +29,15 @@
"additionalProperties": false
}
}
},
"auth": {
"type": "object",
"properties": {
"key": {
"type": "object"
}
},
"required": ["key"]
}
},
"required": ["apps"],

View File

@ -7,8 +7,9 @@ import (
const NameApp spec.Name = "app.emissary.cadoles.com"
type Spec struct {
Revision int `json:"revisions"`
Apps map[string]AppEntry
Revision int `json:"revisions"`
Apps map[string]AppEntry `json:"apps"`
Auth *Auth `json:"auth"`
}
type AppEntry struct {
@ -18,6 +19,10 @@ type AppEntry struct {
Format string `json:"format"`
}
type Auth struct {
Key any `json:"key"`
}
func (s *Spec) SpecName() spec.Name {
return NameApp
}
@ -29,6 +34,7 @@ func (s *Spec) SpecRevision() int {
func (s *Spec) SpecData() map[string]any {
return map[string]any{
"apps": s.Apps,
"auth": s.Auth,
}
}

View File

@ -1,4 +1,4 @@
package gateway
package proxy
import (
_ "embed"
@ -11,7 +11,7 @@ import (
var schema []byte
func init() {
if err := spec.Register(NameGateway, schema); err != nil {
if err := spec.Register(NameProxy, schema); err != nil {
panic(errors.WithStack(err))
}
}

View File

@ -1,11 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://gateway.emissary.cadoles.com/spec.json",
"title": "GatewaySpec",
"description": "Emissary 'Gateway' specification",
"$id": "https://proxy.emissary.cadoles.com/spec.json",
"title": "ProxySpec",
"description": "Emissary 'Proxy' specification",
"type": "object",
"properties": {
"gateways": {
"proxies": {
"type": "object",
"patternProperties": {
".*": {
@ -24,6 +24,6 @@
}
}
},
"required": ["gateways"],
"required": ["proxies"],
"additionalProperties": false
}

View File

@ -1,23 +1,23 @@
package gateway
package proxy
import "forge.cadoles.com/Cadoles/emissary/internal/spec"
const NameGateway spec.Name = "gateway.emissary.cadoles.com"
const NameProxy spec.Name = "proxy.emissary.cadoles.com"
type ID string
type Spec struct {
Revision int `json:"revision"`
Gateways map[ID]GatewayEntry `json:"gateways"`
Revision int `json:"revision"`
Proxies map[ID]ProxyEntry `json:"proxies"`
}
type GatewayEntry struct {
type ProxyEntry struct {
Address string `json:"address"`
Target string `json:"target"`
}
func (s *Spec) SpecName() spec.Name {
return NameGateway
return NameProxy
}
func (s *Spec) SpecRevision() int {
@ -26,14 +26,14 @@ func (s *Spec) SpecRevision() int {
func (s *Spec) SpecData() map[string]any {
return map[string]any{
"gateways": s.Gateways,
"proxies": s.Proxies,
}
}
func NewSpec() *Spec {
return &Spec{
Revision: -1,
Gateways: make(map[ID]GatewayEntry),
Proxies: make(map[ID]ProxyEntry),
}
}

View File

@ -1,7 +1,7 @@
{
"name": "gateway.emissary.cadoles.com",
"name": "proxy.emissary.cadoles.com",
"data": {
"gateways": {
"proxies": {
"cadoles.com": {
"address": ":3003",
"target": "https://www.cadoles.com",

View File

@ -1,7 +1,7 @@
{
"name": "gateway.emissary.cadoles.com",
"name": "proxy.emissary.cadoles.com",
"data": {
"gateways": {
"proxies": {
"cadoles.com": {
"address": ":3003"
}

View File

@ -1,7 +1,7 @@
{
"name": "gateway.emissary.cadoles.com",
"name": "proxy.emissary.cadoles.com",
"data": {
"gateways": {
"proxies": {
"cadoles.com": {
"address": ":3003",
"target": "https://www.cadoles.com"

View File

@ -1,4 +1,4 @@
package gateway
package proxy
import (
"context"
@ -38,7 +38,7 @@ func TestValidator(t *testing.T) {
t.Parallel()
validator := spec.NewValidator()
if err := validator.Register(NameGateway, schema); err != nil {
if err := validator.Register(NameProxy, schema); err != nil {
t.Fatalf("+%v", errors.WithStack(err))
}