config

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DashboardServiceID = "cadet-dashboard"
)

Variables

View Source
var DefaultACLPolicy = acl.MustParsePolicy("allow " + acl.Wildcard)

Functions

func WatchACLConfig

func WatchACLConfig(kv *api.KV, key string) watch.Watchable[*ACL]

func WatchCaddyConfig

func WatchCaddyConfig(kv *api.KV, key string) watch.Watchable[*caddy.Config]

func WatchConsulCatalog

func WatchConsulCatalog(catalog *api.Catalog, cfg service.ExtractConfig) watch.Watchable[service.Map]

func WatchConsulKey

func WatchConsulKey(kv *api.KV, key string) watch.Watchable[*api.KVPair]

func WatchConsulPrefix

func WatchConsulPrefix(kv *api.KV, prefix string) watch.Watchable[[]*api.KVPair]

func WatchStaticServices

func WatchStaticServices(kv *api.KV, prefix string) watch.Watchable[service.Map]

func WatchZoneConfig

func WatchZoneConfig(kv *api.KV, key string) watch.Watchable[*Zone]

Types

type ACL

type ACL struct {
	Networks      map[string]acl.Network
	Groups        map[string][]string
	DefaultPolicy acl.Policy
	DefaultAction acl.Action
}

func DefaultACLConfig

func DefaultACLConfig() *ACL

func (*ACL) MatchGroups

func (c *ACL) MatchGroups(network string) ([]string, bool)

func (*ACL) MatchNetwork

func (c *ACL) MatchNetwork(ip *net.IP) (string, bool)

func (*ACL) UnmarshalJSON

func (c *ACL) UnmarshalJSON(data []byte) error

type ConsulConfig

type ConsulConfig struct {
	Endpoint           *url.URL
	Token              string
	GlobalConfigPrefix string

	Tags TagConfig
	Keys KeyConfig
}

func DefaultConsulConfig

func DefaultConsulConfig() *ConsulConfig

func (*ConsulConfig) UnmarshalJSON

func (c *ConsulConfig) UnmarshalJSON(data []byte) error

type DashboardConfig added in v0.0.5

type DashboardConfig struct {
	Enabled bool       `json:"enabled"`
	Name    string     `json:"name"`
	Zones   []string   `json:"zones"`
	ACL     acl.Policy `json:"acl"`
}

DashboardConfig controls the web UI. When enabled it is published as a service like any other, with a hostname, TLS and ACLs, but served by the cadet_dashboard handler instead of a reverse proxy.

func DashboardFromCaddy added in v0.0.5

func DashboardFromCaddy(cfg *caddy.Config) (*DashboardConfig, error)

DashboardFromCaddy reads the dashboard config from the cadet app of a caddy config, falling back to the default (disabled) config when it isn't set.

func DefaultDashboardConfig added in v0.0.5

func DefaultDashboardConfig() *DashboardConfig

func (*DashboardConfig) AddTo added in v0.0.5

func (d *DashboardConfig) AddTo(services service.Map) service.Map

AddTo returns services with the dashboard added if it is enabled. A service already registered under the dashboard's ID shadows it. services itself is never modified.

func (*DashboardConfig) Service added in v0.0.5

func (d *DashboardConfig) Service() *service.Config

Service returns the dashboard as a service config. An empty ACL falls back to the global default policy, as it does for real services.

type ErrorHandler

type ErrorHandler func(error) (time.Duration, bool)

type KeyConfig

type KeyConfig struct {
	Name  string `json:"name"`
	Zone  string `json:"zone"`
	ACL   string `json:"acl"`
	Proxy string `json:"proxy"`
}

func DefaultKeyConfig

func DefaultKeyConfig() KeyConfig

type RemoteConfig

type RemoteConfig interface {
	Ready() bool
	Services() service.Map
	ACL() *ACL
	Zone() *Zone
	Caddy() *caddy.Config
}

type TagConfig

type TagConfig struct {
	Service   string `json:"service"`
	NoPublish string `json:"no_publish"`
}

func DefaultTagConfig

func DefaultTagConfig() TagConfig

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(onChange func(RemoteConfig) bool, onError ErrorHandler) *Watcher

func (*Watcher) ACL

func (w *Watcher) ACL() *ACL

func (*Watcher) Caddy

func (w *Watcher) Caddy() *caddy.Config

func (*Watcher) Ready

func (w *Watcher) Ready() bool

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context, catalog *api.Catalog, kv *api.KV, configPrefix string, extractCfg service.ExtractConfig) error

func (*Watcher) Services

func (w *Watcher) Services() service.Map

func (*Watcher) Zone

func (w *Watcher) Zone() *Zone

type Zone

type Zone struct {
	DefaultZone string   `json:"default_zone,omitempty"`
	Zones       []string `json:"zones,omitempty"`
}

func DefaultZoneConfig

func DefaultZoneConfig() *Zone

Jump to

Keyboard shortcuts

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