spec

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Add    Action = "add"
	Delete Action = "delete"

	Routes      Resource = "route"
	Services    Resource = "service"
	Namespaces  Resource = "namespace"
	Modules     Resource = "module"
	Domains     Resource = "domain"
	Collections Resource = "collection"
	Documents   Resource = "document"
	Secrets     Resource = "secret"
)

Variables

View Source
var DefaultNamespace = &Namespace{
	Name: "default",
	Tags: []string{"default"},
}

Functions

func ErrCollectionNotFound

func ErrCollectionNotFound(col string) error

func ErrDocumentNotFound

func ErrDocumentNotFound(doc string) error

func ErrDomainNotFound

func ErrDomainNotFound(domain string) error

func ErrModuleNotFound

func ErrModuleNotFound(mod string) error

func ErrNamespaceNotFound

func ErrNamespaceNotFound(ns string) error

func ErrRouteNotFound

func ErrRouteNotFound(route string) error

func ErrSecretNotFound added in v0.8.0

func ErrSecretNotFound(secret string) error

func ErrServiceNotFound

func ErrServiceNotFound(svc string) error

Types

type Action

type Action string

func (Action) String

func (act Action) String() string

type ChangeLog

type ChangeLog struct {
	ID        string  `json:"id"`
	Cmd       Command `json:"cmd"`
	Name      string  `json:"name"`
	Namespace string  `json:"namespace"`
	Item      any     `json:"item"`
	Version   int     `json:"version"`
}

func NewChangeLog

func NewChangeLog(item Named, namespace string, cmd Command) *ChangeLog

func NewNoopChangeLog added in v0.10.0

func NewNoopChangeLog() *ChangeLog

func (*ChangeLog) RenewID added in v0.11.1

func (cl *ChangeLog) RenewID() *ChangeLog

type Collection

type Collection struct {
	Name          string               `json:"name" koanf:"name"`
	NamespaceName string               `json:"namespace" koanf:"namespace"`
	Schema        any                  `json:"schema" koanf:"schema"`
	Visibility    CollectionVisibility `json:"visibility" koanf:"visibility"`
	Type          CollectionType       `json:"type" koanf:"type"`
	// Modules       []string             `json:"modules,omitempty" koanf:"modules"`
	Tags []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateCollection

func TransformDGateCollection(col *DGateCollection) *Collection

func TransformDGateCollections

func TransformDGateCollections(collections ...*DGateCollection) []*Collection

func (*Collection) GetName

func (n *Collection) GetName() string

type CollectionType

type CollectionType string
const (
	CollectionTypeDocument CollectionType = "document"
	CollectionTypeFetcher  CollectionType = "fetcher"
)

type CollectionVisibility

type CollectionVisibility string
const (
	CollectionVisibilityPublic  CollectionVisibility = "public"
	CollectionVisibilityPrivate CollectionVisibility = "private"
)

type Command

type Command string
var (
	AddRouteCommand         Command = newCommand(Add, Routes)
	AddServiceCommand       Command = newCommand(Add, Services)
	AddNamespaceCommand     Command = newCommand(Add, Namespaces)
	AddModuleCommand        Command = newCommand(Add, Modules)
	AddDomainCommand        Command = newCommand(Add, Domains)
	AddCollectionCommand    Command = newCommand(Add, Collections)
	AddDocumentCommand      Command = newCommand(Add, Documents)
	AddSecretCommand        Command = newCommand(Add, Secrets)
	DeleteRouteCommand      Command = newCommand(Delete, Routes)
	DeleteServiceCommand    Command = newCommand(Delete, Services)
	DeleteNamespaceCommand  Command = newCommand(Delete, Namespaces)
	DeleteModuleCommand     Command = newCommand(Delete, Modules)
	DeleteDomainCommand     Command = newCommand(Delete, Domains)
	DeleteCollectionCommand Command = newCommand(Delete, Collections)
	DeleteDocumentCommand   Command = newCommand(Delete, Documents)
	DeleteSecretCommand     Command = newCommand(Delete, Secrets)

	// internal commands
	NoopCommand Command = Command("noop")
)

func (Command) Action

func (clc Command) Action() Action

func (Command) IsNoop

func (clc Command) IsNoop() bool

func (Command) IsRestart added in v0.8.0

func (clc Command) IsRestart() bool

func (Command) IsShutdown added in v0.8.0

func (clc Command) IsShutdown() bool

func (Command) Resource

func (clc Command) Resource() Resource

func (Command) String

func (clc Command) String() string

type DGateCollection

type DGateCollection struct {
	Name          string               `json:"name"`
	Namespace     *DGateNamespace      `json:"namespace"`
	Schema        *jsonschema.Schema   `json:"schema"`
	SchemaPayload string               `json:"schema_payload"`
	Type          CollectionType       `json:"type"`
	Visibility    CollectionVisibility `json:"visibility"`
	// Modules       []*DGateModule       `json:"modules"`
	Tags []string `json:"tags,omitempty"`
}

func TransformCollection

func TransformCollection(ns *DGateNamespace, mods []*DGateModule, col *Collection) *DGateCollection

func TransformCollections

func TransformCollections(ns *DGateNamespace, mods []*DGateModule, collections ...*Collection) []*DGateCollection

func (*DGateCollection) GetName

func (n *DGateCollection) GetName() string

type DGateDocument

type DGateDocument struct {
	ID         string           `json:"id"`
	CreatedAt  time.Time        `json:"created_at"`
	UpdatedAt  time.Time        `json:"updated_at"`
	Namespace  *DGateNamespace  `json:"namespace"`
	Collection *DGateCollection `json:"collection"`
	Data       string           `json:"data"`
}

func TransformDocument

func TransformDocument(ns *DGateNamespace, col *DGateCollection, document *Document) *DGateDocument

func TransformDocuments

func TransformDocuments(ns *DGateNamespace, col *DGateCollection, documents ...*Document) []*DGateDocument

func (*DGateDocument) GetName

func (n *DGateDocument) GetName() string

type DGateDomain

type DGateDomain struct {
	Name      string          `json:"name"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
	Namespace *DGateNamespace `json:"namespace"`
	Patterns  []string        `json:"pattern"`
	Priority  int             `json:"priority"`
	Cert      string          `json:"cert"`
	Key       string          `json:"key"`
	Tags      []string        `json:"tags,omitempty"`
}

func TransformDomain

func TransformDomain(ns *DGateNamespace, dom *Domain) *DGateDomain

func TransformDomains

func TransformDomains(ns *DGateNamespace, domains ...*Domain) []*DGateDomain

type DGateModule

type DGateModule struct {
	Name      string          `json:"name"`
	Namespace *DGateNamespace `json:"namespace"`
	Payload   string          `json:"payload"`
	Type      ModuleType      `json:"module_type"`
	Tags      []string        `json:"tags,omitempty"`
}

func TransformModule

func TransformModule(ns *DGateNamespace, m *Module) (*DGateModule, error)

func TransformModules

func TransformModules(ns *DGateNamespace, modules ...*Module) ([]*DGateModule, error)

func (*DGateModule) GetName

func (m *DGateModule) GetName() string

type DGateNamespace

type DGateNamespace struct {
	Name string   `json:"name"`
	Tags []string `json:"tags,omitempty"`
}

func TransformNamespace

func TransformNamespace(ns *Namespace) *DGateNamespace

func TransformNamespaces

func TransformNamespaces(namespaces ...*Namespace) []*DGateNamespace

func (*DGateNamespace) GetName

func (ns *DGateNamespace) GetName() string

type DGateRoute

type DGateRoute struct {
	Name         string          `json:"name"`
	Paths        []string        `json:"paths"`
	Methods      []string        `json:"methods"`
	StripPath    bool            `json:"stripPath"`
	PreserveHost bool            `json:"preserveHost"`
	Service      *DGateService   `json:"service"`
	Namespace    *DGateNamespace `json:"namespace"`
	Modules      []*DGateModule  `json:"modules"`
	Tags         []string        `json:"tags,omitempty"`
}

func TransformRoute

func TransformRoute(r Route) *DGateRoute

func TransformRoutes

func TransformRoutes(routes ...Route) []*DGateRoute

func (*DGateRoute) GetName

func (r *DGateRoute) GetName() string

type DGateSecret added in v0.8.0

type DGateSecret struct {
	Name      string          `json:"name"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
	Namespace *DGateNamespace `json:"namespace"`
	Data      string          `json:"data"`
	Tags      []string        `json:"tags,omitempty"`
}

func TransformSecret added in v0.8.0

func TransformSecret(ns *DGateNamespace, secret *Secret) (*DGateSecret, error)

func TransformSecrets added in v0.8.0

func TransformSecrets(ns *DGateNamespace, secrets ...*Secret) ([]*DGateSecret, error)

func (*DGateSecret) GetName added in v0.8.0

func (n *DGateSecret) GetName() string

type DGateService

type DGateService struct {
	Name      string          `json:"name"`
	URLs      []*url.URL      `json:"urls"`
	Tags      []string        `json:"tags,omitempty"`
	Namespace *DGateNamespace `json:"namespace"`

	DisableQueryParams bool          `json:"disableQueryParams,omitempty"`
	Retries            int           `json:"retries,omitempty"`
	RetryTimeout       time.Duration `json:"retryTimeout,omitempty"`
	ConnectTimeout     time.Duration `json:"connectTimeout,omitempty"`
	RequestTimeout     time.Duration `json:"requestTimeout,omitempty"`
	TLSSkipVerify      bool          `json:"tlsSkipVerify,omitempty"`
	HTTP2Only          bool          `json:"http2_only,omitempty"`
	HideDGateHeaders   bool          `json:"hideDGateHeaders,omitempty"`
}

func TransformService

func TransformService(ns *DGateNamespace, s *Service) *DGateService

func TransformServices

func TransformServices(ns *DGateNamespace, services ...*Service) []*DGateService

func (*DGateService) GetName

func (s *DGateService) GetName() string

type Document

type Document struct {
	ID             string    `json:"id"`
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
	NamespaceName  string    `json:"namespace"`
	CollectionName string    `json:"collection"`
	Data           any       `json:"data"`
}

func TransformDGateDocument

func TransformDGateDocument(document *DGateDocument) *Document

func TransformDGateDocuments

func TransformDGateDocuments(documents ...*DGateDocument) []*Document

func (*Document) GetName

func (n *Document) GetName() string

type Domain

type Domain struct {
	Name          string   `json:"name" koanf:"name"`
	NamespaceName string   `json:"namespace" koanf:"namespace"`
	Patterns      []string `json:"patterns" koanf:"patterns"`
	Priority      int      `json:"priority" koanf:"priority"`
	Cert          string   `json:"cert" koanf:"cert"`
	Key           string   `json:"key" koanf:"key"`
	Tags          []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateDomain

func TransformDGateDomain(dom *DGateDomain) *Domain

func TransformDGateDomains

func TransformDGateDomains(domains ...*DGateDomain) []*Domain

func (*Domain) GetName

func (n *Domain) GetName() string

type Module

type Module struct {
	Name          string     `json:"name" koanf:"name"`
	NamespaceName string     `json:"namespace" koanf:"namespace"`
	Payload       string     `json:"payload" koanf:"payload"`
	Type          ModuleType `json:"moduleType,omitempty" koanf:"moduleType"`
	Tags          []string   `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateModule

func TransformDGateModule(m *DGateModule) *Module

func TransformDGateModules

func TransformDGateModules(modules ...*DGateModule) []*Module

func (*Module) GetName

func (m *Module) GetName() string

type ModuleType

type ModuleType string
const (
	ModuleTypeJavascript ModuleType = "javascript"
	ModuleTypeTypescript ModuleType = "typescript"
)

func (ModuleType) String

func (m ModuleType) String() string

func (ModuleType) Valid

func (m ModuleType) Valid() bool

type Name

type Name string

type Named

type Named interface {
	GetName() string
}

type Namespace

type Namespace struct {
	Name string   `json:"name" koanf:"name"`
	Tags []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateNamespace

func TransformDGateNamespace(ns *DGateNamespace) *Namespace

func TransformDGateNamespaces

func TransformDGateNamespaces(namespaces ...*DGateNamespace) []*Namespace

func (*Namespace) GetName

func (n *Namespace) GetName() string

type Resource

type Resource string

func (Resource) IsRelatedTo

func (resource1 Resource) IsRelatedTo(resource2 Resource) bool

func (Resource) String

func (rt Resource) String() string

type ResponseWriterTracker

type ResponseWriterTracker interface {
	http.ResponseWriter
	Status() int
	HeadersSent() bool
	BytesWritten() int64
}

func NewResponseWriterTracker

func NewResponseWriterTracker(rw http.ResponseWriter) ResponseWriterTracker

type Route

type Route struct {
	Name          string   `json:"name" koanf:"name"`
	Paths         []string `json:"paths" koanf:"paths"`
	Methods       []string `json:"methods" koanf:"methods"`
	PreserveHost  bool     `json:"preserveHost" koanf:"preserveHost"`
	StripPath     bool     `json:"stripPath" koanf:"stripPath"`
	ServiceName   string   `json:"service,omitempty" koanf:"service"`
	NamespaceName string   `json:"namespace" koanf:"namespace"`
	Modules       []string `json:"modules,omitempty" koanf:"modules"`
	Tags          []string `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateRoute

func TransformDGateRoute(r *DGateRoute) *Route

func TransformDGateRoutes

func TransformDGateRoutes(routes ...*DGateRoute) []*Route

func (*Route) GetName

func (m *Route) GetName() string

type Secret added in v0.8.0

type Secret struct {
	Name          string   `json:"name"`
	NamespaceName string   `json:"namespace"`
	Data          string   `json:"data,omitempty"`
	Tags          []string `json:"tags,omitempty"`
}

func TransformDGateSecret added in v0.8.0

func TransformDGateSecret(sec *DGateSecret) *Secret

func TransformDGateSecrets added in v0.8.0

func TransformDGateSecrets(secrets ...*DGateSecret) []*Secret

func (*Secret) GetName added in v0.8.0

func (n *Secret) GetName() string

type Service

type Service struct {
	Name               string         `json:"name" koanf:"name"`
	URLs               []string       `json:"urls" koanf:"urls"`
	NamespaceName      string         `json:"namespace" koanf:"namespace"`
	Retries            *int           `json:"retries,omitempty" koanf:"retries"`
	RetryTimeout       *time.Duration `json:"retryTimeout,omitempty" koanf:"retryTimeout"`
	ConnectTimeout     *time.Duration `json:"connectTimeout,omitempty"  koanf:"connectTimeout"`
	RequestTimeout     *time.Duration `json:"requestTimeout,omitempty"  koanf:"requestTimeout"`
	TLSSkipVerify      *bool          `json:"tlsSkipVerify,omitempty" koanf:"tlsSkipVerify"`
	HTTP2Only          *bool          `json:"http2Only,omitempty" koanf:"http2Only"`
	HideDGateHeaders   *bool          `json:"hideDGateHeaders,omitempty" koanf:"hideDGateHeaders"`
	DisableQueryParams *bool          `json:"disableQueryParams,omitempty" koanf:"disableQueryParams"`
	Tags               []string       `json:"tags,omitempty" koanf:"tags"`
}

func TransformDGateService

func TransformDGateService(s *DGateService) *Service

func TransformDGateServices

func TransformDGateServices(services ...*DGateService) []*Service

func (*Service) GetName

func (s *Service) GetName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL