Documentation ¶
Index ¶
- func LoadConfig(builderOpts config.BuilderOpts, extraHead config.Source, ...) (*config.RuntimeConfig, []string, error)
- type AutoConfig
- func (ac *AutoConfig) FallbackTLS(ctx context.Context) (*structs.SignedResponse, error)
- func (ac *AutoConfig) InitialConfiguration(ctx context.Context) (*config.RuntimeConfig, error)
- func (ac *AutoConfig) ReadConfig() (*config.RuntimeConfig, error)
- func (ac *AutoConfig) RecordUpdatedCerts(resp *structs.SignedResponse) error
- func (ac *AutoConfig) Start(ctx context.Context) error
- func (ac *AutoConfig) Stop() bool
- type CertMonitor
- type Config
- func (c *Config) WithBuilderOpts(builderOpts config.BuilderOpts) *Config
- func (c *Config) WithCertMonitor(certMonitor CertMonitor) *Config
- func (c *Config) WithDirectRPC(directRPC DirectRPC) *Config
- func (c *Config) WithLogger(logger hclog.Logger) *Config
- func (c *Config) WithOverrides(overrides ...config.Source) *Config
- func (c *Config) WithRetryWaiter(waiter *lib.RetryWaiter) *Config
- type DirectRPC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
func LoadConfig(builderOpts config.BuilderOpts, extraHead config.Source, overrides ...config.Source) (*config.RuntimeConfig, []string, error)
LoadConfig will build the configuration including the extraHead source injected after all other defaults but before any user supplied configuration and the overrides source injected as the final source in the configuration parsing chain.
Types ¶
type AutoConfig ¶
type AutoConfig struct {
// 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.
NOTE: This struct and methods on it are not currently thread/goroutine safe. However it doesn't spawn any of its own go routines yet and is used in a synchronous fashion. In the future if either of those two conditions change then we will need to add some locking here. I am deferring that for now to help ease the review of this already large PR.
func New ¶
func New(config *Config) (*AutoConfig, error)
New creates a new AutoConfig object for providing automatic Consul configuration.
func (*AutoConfig) FallbackTLS ¶
func (ac *AutoConfig) FallbackTLS(ctx context.Context) (*structs.SignedResponse, error)
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) 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) RecordUpdatedCerts ¶
func (ac *AutoConfig) RecordUpdatedCerts(resp *structs.SignedResponse) error
func (*AutoConfig) Stop ¶
func (ac *AutoConfig) Stop() bool
type CertMonitor ¶
type CertMonitor interface { Update(*structs.SignedResponse) error Start(context.Context) (<-chan struct{}, error) Stop() bool }
CertMonitor is the interface that needs to be satisfied for AutoConfig to be able to setup monitoring of the Connect TLS certificate after we first get it.
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 // BuilderOpts are any configuration building options that should be // used when loading the Consul configuration. This is mostly a pass // through from what the CLI will generate. While this option is // not strictly required, not setting it will prevent AutoConfig // from doing anything useful. Enabling AutoConfig requires a // CLI flag or a config file (also specified by the CLI) flag. // So without providing the opts its equivalent to using the // configuration of not specifying anything to the consul agent // cli. BuilderOpts config.BuilderOpts // Waiter is a RetryWaiter to be used during retrieval of the // initial configuration. When a round 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 // to 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 *lib.RetryWaiter // Overrides are a list of configuration sources to append to the tail of // the config builder. This field is optional and mainly useful for testing // to override values that would be otherwise not user-settable. Overrides []config.Source // CertMonitor is the Connect TLS Certificate Monitor to be used for ongoing // certificate renewals and connect CA roots updates. This field is not // strictly required but if not provided the TLS certificates retrieved // through by the AutoConfig.InitialConfiguration RPC will not be used // or renewed. CertMonitor CertMonitor }
Config contains all the tunables for AutoConfig
func (*Config) WithBuilderOpts ¶
func (c *Config) WithBuilderOpts(builderOpts config.BuilderOpts) *Config
WithBuilderOpts will cause the created AutoConfig type to use the provided CLI builderOpts
func (*Config) WithCertMonitor ¶
func (c *Config) WithCertMonitor(certMonitor CertMonitor) *Config
WithCertMonitor is used to provide a certificate monitor to the auto-config. This monitor is responsible for renewing the agents TLS certificate and keeping the connect CA roots up to date.
func (*Config) WithDirectRPC ¶
WithConnectionPool will cause the created AutoConfig type to use the provided connection pool
func (*Config) WithLogger ¶
WithLogger will cause the created AutoConfig type to use the provided logger
func (*Config) WithOverrides ¶
WithOverrides is used to provide a config source to append to the tail sources during config building. It is really only useful for testing to tune non-user configurable tunables to make various tests converge more quickly than they could otherwise.
func (*Config) WithRetryWaiter ¶
func (c *Config) WithRetryWaiter(waiter *lib.RetryWaiter) *Config
WithRetryWaiter will cause the created AutoConfig type to use the provided retry waiter
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.