erconfig

package
v0.0.0-...-af2531a Latest Latest
Warning

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

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

Documentation

Overview

Application configuration data structures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowInsecureHTTP

func AllowInsecureHTTP(opts *frontendOptions)

func ErrorIfUnset

func ErrorIfUnset(isUnset bool, fieldName string) error

TODO: gokit/builtin

func FirstError

func FirstError(errs ...error) error

TODO: gokit/builtin

func StripPathPrefix

func StripPathPrefix(opts *frontendOptions)

Types

type Application

type Application struct {
	Id        string     `json:"id"` // ACLs can reference this, so keep stable (i.e. service replicas/restarts should not affect this)
	Frontends []Frontend `json:"frontends"`
	Backend   Backend    `json:"backend"`
}

func FindApplication

func FindApplication(id string, apps []Application) *Application

func SimpleApplication

func SimpleApplication(id string, frontend Frontend, backend Backend) Application

func (*Application) Describe

func (a *Application) Describe() string

func (*Application) Validate

func (a *Application) Validate() error

type Backend

type Backend struct {
	Kind                BackendKind                 `json:"kind"`
	S3StaticWebsiteOpts *BackendOptsS3StaticWebsite `json:"s3_static_website_opts,omitempty"`
	ReverseProxyOpts    *BackendOptsReverseProxy    `json:"reverse_proxy_opts,omitempty"`
	AwsLambdaOpts       *BackendOptsAwsLambda       `json:"aws_lambda_opts,omitempty"`
	AuthV0Opts          *BackendOptsAuthV0          `json:"auth_v0_opts,omitempty"`
	AuthSsoOpts         *BackendOptsAuthSso         `json:"auth_sso_opts,omitempty"`
	RedirectOpts        *BackendOptsRedirect        `json:"redirect_opts,omitempty"`
	TurbochargerOpts    *BackendOptsTurbocharger    `json:"turbocharger_opts,omitempty"`
}

func AuthSsoBackend

func AuthSsoBackend(
	idServerUrl string,
	allowedUserIds []string,
	audience string,
	authorizedBackend Backend,
) Backend

func AuthV0Backend

func AuthV0Backend(bearerToken string, authorizedBackend Backend) Backend

func EdgerouterAdminBackend

func EdgerouterAdminBackend() Backend

func LambdaBackend

func LambdaBackend(functionName string, regionId string) Backend

func PromMetricsBackend

func PromMetricsBackend() Backend

func RedirectBackend

func RedirectBackend(to string) Backend

func ReverseProxyBackend

func ReverseProxyBackend(addrs []string, tlsConfig *TlsConfig, passHostHeader bool) Backend

func S3Backend

func S3Backend(bucketName string, regionId string, deployedVersion string) Backend

func TurbochargerBackend

func TurbochargerBackend(manifestID turbocharger.ObjectID) Backend

func (*Backend) Describe

func (b *Backend) Describe() string

type BackendKind

type BackendKind string

when adding new kind, remember to update: - Application.Validate() - Backend.Describe() - factory in backendfactory

const (
	BackendKindS3StaticWebsite BackendKind = "s3_static_website"
	BackendKindReverseProxy    BackendKind = "reverse_proxy"
	BackendKindAwsLambda       BackendKind = "aws_lambda"
	BackendKindEdgerouterAdmin BackendKind = "edgerouter_admin"
	BackendKindAuthV0          BackendKind = "auth_v0"
	BackendKindAuthSso         BackendKind = "auth_sso"
	BackendKindRedirect        BackendKind = "redirect"
	BackendKindPromMetrics     BackendKind = "prom_metrics"
	BackendKindTurbocharger    BackendKind = "turbocharger"
)

type BackendOptsAuthSso

type BackendOptsAuthSso struct {
	IdServerUrl       string   `json:"id_server_url,omitempty"`
	AllowedUserIds    []string `json:"allowed_user_ids"`
	Audience          string   `json:"audience"`
	AuthorizedBackend *Backend `json:"authorized_backend"` // ptr for validation
}

func (*BackendOptsAuthSso) Validate

func (b *BackendOptsAuthSso) Validate() error

type BackendOptsAuthV0

type BackendOptsAuthV0 struct {
	BearerToken       string   `json:"bearer_token"`
	AuthorizedBackend *Backend `json:"authorized_backend"` // ptr for validation
}

func (*BackendOptsAuthV0) Validate

func (b *BackendOptsAuthV0) Validate() error

type BackendOptsAwsLambda

type BackendOptsAwsLambda struct {
	FunctionName string `json:"function_name"`
	RegionId     string `json:"region_id"`
}

func (*BackendOptsAwsLambda) Validate

func (b *BackendOptsAwsLambda) Validate() error

type BackendOptsRedirect

type BackendOptsRedirect struct {
	To string `json:"to"`
}

func (*BackendOptsRedirect) Validate

func (b *BackendOptsRedirect) Validate() error

type BackendOptsReverseProxy

type BackendOptsReverseProxy struct {
	Origins           []string          `json:"origins"`
	TlsConfig         *TlsConfig        `json:"tls_config,omitempty"`
	Caching           bool              `json:"caching,omitempty"`             // turn on response caching?
	PassHostHeader    bool              `json:"pass_host_header,omitempty"`    // use client-sent Host (=true) or origin's hostname? (=false) https://doc.traefik.io/traefik/routing/services/#pass-host-header
	IndexDocument     string            `json:"index_document,omitempty"`      // if request path ends in /foo/ ("directory"), rewrite it into /foo/index.html
	RemoveQueryString bool              `json:"remove_query_string,omitempty"` // reduces cache misses if responses don't vary on qs
	HeadersToOrigin   map[string]string `json:"headers_to_origin,omitempty"`   // force-add headers to be sent to origin
}

func (*BackendOptsReverseProxy) Validate

func (b *BackendOptsReverseProxy) Validate() error

type BackendOptsS3StaticWebsite

type BackendOptsS3StaticWebsite struct {
	BucketName      string `json:"bucket_name"`
	RegionId        string `json:"region_id"`
	DeployedVersion string `json:"deployed_version"`   // can be empty before first deployed version
	NotFoundPage    string `json:"404_page,omitempty"` // (optional) ex: "404.html", relative to root of deployed site
}

func (*BackendOptsS3StaticWebsite) Validate

func (b *BackendOptsS3StaticWebsite) Validate() error

type BackendOptsTurbocharger

type BackendOptsTurbocharger struct {
	Manifest turbocharger.ObjectID `json:"manifest"`
}

func (*BackendOptsTurbocharger) Validate

func (b *BackendOptsTurbocharger) Validate() error

type CurrentConfigAccessor

type CurrentConfigAccessor interface {
	Apps() []Application
	LastUpdated() time.Time
}

can be used to fetch the current state of configuration - the apps Edgerouter knows *right now*, based on all the discovery mechanisms used

type Frontend

type Frontend struct {
	Kind              FrontendKind `json:"kind"`
	Hostname          string       `json:"hostname,omitempty"`
	HostnameRegexp    string       `json:"hostname_regexp,omitempty"`
	PathPrefix        string       `json:"path_prefix"` // applies with both kinds
	StripPathPrefix   bool         `json:"strip_path_prefix,omitempty"`
	AllowInsecureHTTP bool         `json:"allow_insecure_http,omitempty"`
}

https://docs.traefik.io/v1.7/basics/#matchers

func PathPrefixFrontend

func PathPrefixFrontend(pathPrefix string, options ...FrontendOpt) Frontend

catches all requests irregardless of hostname

func RegexpHostnameFrontend

func RegexpHostnameFrontend(hostnameRegexp string, options ...FrontendOpt) Frontend

func SimpleHostnameFrontend

func SimpleHostnameFrontend(hostname string, options ...FrontendOpt) Frontend

func (*Frontend) Describe

func (f *Frontend) Describe() string

func (*Frontend) Validate

func (f *Frontend) Validate() error

type FrontendKind

type FrontendKind string

loosely modeled after https://doc.traefik.io/traefik/v1.7/basics/#matchers

const (
	FrontendKindHostname       FrontendKind = "hostname"
	FrontendKindHostnameRegexp FrontendKind = "hostname_regexp"
	FrontendKindPathPrefix     FrontendKind = "path_prefix"
)

type FrontendOpt

type FrontendOpt func(opts *frontendOptions)

func PathPrefix

func PathPrefix(pathPrefix string) FrontendOpt

type TlsConfig

type TlsConfig struct {
	InsecureSkipVerify bool   `json:"insecure_skip_verify,omitempty"`
	ServerName         string `json:"server_name,omitempty"` // used to verify the hostname on the server cert. also sent via SNI
}

func (*TlsConfig) HasMeaningfulContent

func (t *TlsConfig) HasMeaningfulContent() bool

func (*TlsConfig) SelfOrNilIfNoMeaningfulContent

func (t *TlsConfig) SelfOrNilIfNoMeaningfulContent() *TlsConfig

Jump to

Keyboard shortcuts

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