autoconf

package
v1.13.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoConfig

type AutoConfig struct {
	sync.Mutex
	// contains filtered or unexported fields
}

AutoConfig is all the state necessary for being able to parse a configuration as well as perform the necessary RPCs to perform Agent Auto Configuration.

func New

func New(config Config) (*AutoConfig, error)

New creates a new AutoConfig object for providing automatic Consul configuration.

func (*AutoConfig) Done added in v1.8.4

func (ac *AutoConfig) Done() <-chan struct{}

func (*AutoConfig) InitialConfiguration

func (ac *AutoConfig) InitialConfiguration(ctx context.Context) (*config.RuntimeConfig, error)

InitialConfiguration will perform a one-time RPC request to the configured servers to retrieve various cluster wide configurations. See the proto/pbautoconf/auto_config.proto file for a complete reference of what configurations can be applied in this manner. The returned configuration will be the new configuration with any auto-config settings already applied. If AutoConfig is not enabled this method will just parse any local configuration and return the built runtime configuration.

The context passed in can be used to cancel the retrieval of the initial configuration like when receiving a signal during startup.

func (*AutoConfig) IsRunning added in v1.8.4

func (ac *AutoConfig) IsRunning() bool

func (*AutoConfig) ReadConfig

func (ac *AutoConfig) ReadConfig() (*config.RuntimeConfig, error)

ReadConfig will parse the current configuration and inject any auto-config sources if present into the correct place in the parsing chain.

func (*AutoConfig) Start

func (ac *AutoConfig) Start(ctx context.Context) error

func (*AutoConfig) Stop

func (ac *AutoConfig) Stop() bool

type AutoConfigEnterprise added in v1.10.0

type AutoConfigEnterprise struct{}

AutoConfigEnterprise has no fields in OSS

type Cache added in v1.8.4

type Cache interface {
	Notify(ctx context.Context, t string, r cache.Request, correlationID string, ch chan<- cache.UpdateEvent) error
	Prepopulate(t string, result cache.FetchResult, dc string, peerName string, token string, key string) error
}

Cache is an interface to represent the methods of the agent/cache.Cache struct that we care about

type Config

type Config struct {
	// Logger is any logger that should be utilized. If not provided,
	// then no logs will be emitted.
	Logger hclog.Logger

	// DirectRPC is the interface to be used by AutoConfig to make the
	// AutoConfig.InitialConfiguration RPCs for generating the bootstrap
	// configuration. Setting this field is required.
	DirectRPC DirectRPC

	// ServerProvider is the interfaced to be used by AutoConfig to find any
	// known servers during fallback operations.
	ServerProvider ServerProvider

	// Waiter is used during retrieval of the initial configuration.
	// When around of requests fails we will
	// wait and eventually make another round of requests (1 round
	// is trying the RPC once against each configured server addr). The
	// waiting implements some backoff to prevent from retrying these RPCs
	// too often. This field is not required and if left unset a waiter will
	// be used that has a max wait duration of 10 minutes and a randomized
	// jitter of 25% of the wait time. Setting this is mainly useful for
	// testing purposes to allow testing out the retrying functionality without
	// having the test take minutes/hours to complete.
	Waiter *retry.Waiter

	// Loader merges source with the existing FileSources and returns the complete
	// RuntimeConfig.
	Loader func(source config.Source) (config.LoadResult, error)

	// TLSConfigurator is the shared TLS Configurator. AutoConfig will update the
	// auto encrypt/auto config certs as they are renewed.
	TLSConfigurator TLSConfigurator

	// Cache is an object implementing our Cache interface. The Cache
	// used at runtime must be able to handle Roots and Leaf Cert watches
	Cache Cache

	// FallbackLeeway is the amount of time after certificate expiration before
	// invoking the fallback routine. If not set this will default to 10s.
	FallbackLeeway time.Duration

	// FallbackRetry is the duration between Fallback invocations when the configured
	// fallback routine returns an error. If not set this will default to 1m.
	FallbackRetry time.Duration

	// Tokens is the shared token store. It is used to retrieve the current
	// agent token as well as getting notifications when that token is updated.
	// This field is required.
	Tokens TokenStore

	// EnterpriseConfig is the embedded specific enterprise configurations
	EnterpriseConfig
}

Config contains all the tunables for AutoConfig

type DirectRPC

type DirectRPC interface {
	RPC(dc string, node string, addr net.Addr, method string, args interface{}, reply interface{}) error
}

DirectRPC is the interface that needs to be satisifed for AutoConfig to be able to perform direct RPCs against individual servers. This will not be used for any ongoing RPCs as once the agent gets configured, it can go through the normal RPC means of selecting a available server automatically.

type EnterpriseConfig added in v1.10.0

type EnterpriseConfig struct{}

EnterpriseConfig stub - only populated in Consul Enterprise

type ServerProvider added in v1.8.4

type ServerProvider interface {
	FindLANServer() *metadata.Server
}

ServerProvider is an interface that can be used to find one server in the local DC known to the agent via Gossip

type TLSConfigurator added in v1.8.4

type TLSConfigurator interface {
	UpdateAutoTLS(manualCAPEMs, connectCAPEMs []string, pub, priv string, verifyServerHostname bool) error
	UpdateAutoTLSCA([]string) error
	UpdateAutoTLSCert(pub, priv string) error
	AutoEncryptCert() *x509.Certificate
}

TLSConfigurator is an interface of the methods on the tlsutil.Configurator that we will require at runtime.

type TokenStore added in v1.8.4

type TokenStore interface {
	AgentToken() string
	UpdateAgentToken(secret string, source token.TokenSource) bool
	Notify(kind token.TokenKind) token.Notifier
	StopNotify(notifier token.Notifier)
}

TokenStore is an interface of the methods we will need to use from the token.Store.

Jump to

Keyboard shortcuts

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