config

package
v2.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package config provides Trickster configuration abilities, including parsing and printing configuration files, command line parameters, and environment variables, as well as default values and state.

Index

Constants

View Source
const (
	// DefaultConfigPath defines the default location of the Trickster config file
	DefaultConfigPath = "/etc/trickster/trickster.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Main is the primary MainConfig section
	Main *MainConfig `yaml:"main,omitempty"`
	// Backends is a map of BackendOptions
	Backends bo.Lookup `yaml:"backends,omitempty"`
	// Caches is a map of CacheConfigs
	Caches cache.Lookup `yaml:"caches,omitempty"`
	// Frontend provides configurations about the Proxy Front End
	Frontend *fropt.Options `yaml:"frontend,omitempty"`
	// Logging provides configurations that affect logging behavior
	Logging *lo.Options `yaml:"logging,omitempty"`
	// Metrics provides configurations for collecting Metrics about the application
	Metrics *mo.Options `yaml:"metrics,omitempty"`
	// TracingConfigs provides the distributed tracing configuration
	TracingConfigs tracing.Lookup `yaml:"tracing,omitempty"`
	// NegativeCacheConfigs is a map of NegativeCacheConfigs
	NegativeCacheConfigs negative.ConfigLookup `yaml:"negative_caches,omitempty"`
	// Rules is a map of the Rules
	Rules rule.Lookup `yaml:"rules,omitempty"`
	// RequestRewriters is a map of the Rewriters
	RequestRewriters rwopts.Lookup `yaml:"request_rewriters,omitempty"`
	// MgmtConfig provides configurations for managing the trickster process
	// including reloading, purging cache entries, and health checks
	MgmtConfig *mgmt.Options `yaml:"mgmt,omitempty"`
	// Authenticators provides configurations for Authenticating users
	Authenticators auth.Lookup `yaml:"authenticators,omitempty"`

	// Flags contains a compiled version of the CLI flags
	Flags *Flags `yaml:"-"`
	// Resources holds runtime resources uses by the Config
	Resources *Resources `yaml:"-"`

	CompiledRewriters      rewriter.InstructionsLookup `yaml:"-"`
	CompiledNegativeCaches negative.Lookups            `yaml:"-"`

	LoaderWarnings []string `yaml:"-"`
	// contains filtered or unexported fields
}

Config is the main configuration object

func Load

func Load(args []string) (*Config, error)

Load returns the Application Configuration, starting with a default config, then overriding with any provided config file, then env vars, and finally flags

func NewConfig

func NewConfig() *Config

NewConfig returns a Config initialized with default values.

func (*Config) CheckFileLastModified

func (c *Config) CheckFileLastModified() time.Time

CheckFileLastModified returns the last modified date of the running config file, if present

func (*Config) Clone

func (c *Config) Clone() *Config

Clone returns an exact copy of the subject *Config

func (*Config) ConfigFilePath

func (c *Config) ConfigFilePath() string

ConfigFilePath returns the file path from which this configuration is based

func (*Config) IsStale

func (c *Config) IsStale() bool

IsStale returns true if the running config is stale versus the config on disk

func (*Config) OverlayYAMLData

func (c *Config) OverlayYAMLData(md yamlx.KeyLookup) error

OverlayYAMLData extracts supported Config values from the yaml map, overlays the extracted values onto c.

func (*Config) Process

func (c *Config) Process() error

Process converts various raw config options into internal data structures as needed

func (*Config) String

func (c *Config) String() string

func (*Config) TLSCertConfig

func (c *Config) TLSCertConfig() (*tls.Config, error)

TLSCertConfig returns the crypto/tls configuration object with a list of name-bound certs derived from the running config

type Flags

type Flags struct {
	PrintVersion   bool
	ValidateConfig bool

	ProxyListenPort   int
	MetricsListenPort int
	InstanceID        int
	ConfigPath        string
	Origin            string
	Provider          string
	LogLevel          string
	// contains filtered or unexported fields
}

Flags holds the values for whitelisted flags

type MainConfig

type MainConfig struct {
	// InstanceID represents a unique ID for the current instance, when multiple instances on the same host
	InstanceID int `yaml:"instance_id,omitempty"`
	// ServerName represents the server name that is conveyed in Via headers to upstream origins
	// defaults to os.Hostname
	ServerName string `yaml:"server_name,omitempty"`
	// contains filtered or unexported fields
}

MainConfig is a collection of general configuration values.

func (*MainConfig) SetStalenessInfo

func (mc *MainConfig) SetStalenessInfo(fp string, lm, rlt time.Time)

type Resources

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

Resources is a collection of values used by configs at runtime that are not part of the config itself

Directories

Path Synopsis
Package reload helps with reloading the running Trickster configuration
Package reload helps with reloading the running Trickster configuration

Jump to

Keyboard shortcuts

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