package config

import "github.com/redhatinsights/yggdrasil/internal/config"

Index

Constants

const (
	FlagNameLogLevel                 = "log-level"
	FlagNameCertFile                 = "cert-file"
	FlagNameKeyFile                  = "key-file"
	FlagNameCaRoot                   = "ca-root"
	FlagNameServer                   = "server"
	FlagNameClientID                 = "client-id"
	FlagNamePathPrefix               = "path-prefix"
	FlagNameProtocol                 = "protocol"
	FlagNameDataHost                 = "data-host"
	FlagNameFactsFile                = "facts-file"
	FlagNameHTTPRetries              = "http-retries"
	FlagNameHTTPTimeout              = "http-timeout"
	FlagNameMQTTConnectRetry         = "mqtt-connect-retry"
	FlagNameMQTTConnectRetryInterval = "mqtt-connect-retry-interval"
	FlagNameMQTTAutoReconnect        = "mqtt-auto-reconnect"
	FlagNameMQTTReconnectDelay       = "mqtt-reconnect-delay"
	FlagNameMQTTConnectTimeout       = "mqtt-connect-timeout"
	FlagNameMQTTPublishTimeout       = "mqtt-publish-timeout"
	FlagNameMessageJournal           = "message-journal"
)

Variables

var DefaultConfig = Config{
	PathPrefix: constants.DefaultPathPrefix,
}

Types

type Config

type Config struct {
	// LogLevel is the level value used for logging.
	LogLevel string

	// ClientID is a unique identification value for the client over connection
	// transports.
	ClientID string

	// Server is a URI to which yggd connects in order to send and receive data.
	Server []string

	// CertFile is a path to a public certificate, optionally used along with
	// KeyFile to authenticate connections.
	CertFile string

	// KeyFile is a path to a private certificate, optionally used along with
	// CertFile to authenticate connections.
	KeyFile string

	// CARoot is the list of paths with chain certificate file to optionally
	// include in the TLS configration's CA root list.
	CARoot []string

	// PathPrefix is a value prepended to all path names at the transport layer.
	PathPrefix string

	// Protocol is the protocol used by yggd when connecting to Server. Can be
	// either MQTT or HTTP.
	Protocol string

	// DataHost is a hostname value to interject into all HTTP requests when
	// handling data retrieval for "detachedContent" workers.
	DataHost string

	// FactsFile is a path to a file containing a JSON object consisting of
	// key/value pairs that can be used for system identification.
	FactsFile string

	// HTTPRetries is the number of times the client will attempt to resend
	// failed HTTP requests before giving up.
	HTTPRetries int

	// HTTPTimeout is the duration the client will wait before cancelling an
	// HTTP request.
	HTTPTimeout time.Duration

	// MQTTConnectRetry is the MQTT client option to enable connection retry
	// logic when performing the initial connection.
	MQTTConnectRetry bool

	// MQTTConnectRetryInterval is the MQTT client option that specifies the
	// duration to wait between connection retry attempts.
	MQTTConnectRetryInterval time.Duration

	// MQTTAutoReconnect is the MQTT client option that enables automatic
	// reconnection logic when the client unexpectedly disconnects.
	MQTTAutoReconnect bool

	// MQTTReconnectDelay is the duration the client with wait before attempting
	// to reconnect to the MQTT broker.
	MQTTReconnectDelay time.Duration

	// MQTTConnectTimeout is the duration the client will wait for an MQTT
	// connection to be established before giving up.
	MQTTConnectTimeout time.Duration

	// MQTTPublishTimeout is the duration the client will wait for an MQTT
	// connection to publish a message before giving up.
	MQTTPublishTimeout time.Duration

	// MessageJournal is used to enable the storage of worker events
	// and message data in a SQLite file at the specified file path.
	MessageJournal string
}

Config contains current configuration state for yggdrasil.

func (*Config) CreateTLSConfig

func (conf *Config) CreateTLSConfig() (*tls.Config, error)

CreateTLSConfig creates a tls.Config object from the current configuration.

func (*Config) WatcherUpdate

func (conf *Config) WatcherUpdate() (chan *tls.Config, error)

WatcherUpdate creates an Inotify watcher on all TLS related information (Cert-file, key-file and CA-root) if any of those files are updated, it'll send over the returned channel a new TLS.Config that consumers can use to renew their connections. The main use case if when on short-lived certificates, where a connection need to be reloaded to create a new TLSHandshake It will return an error if cannot set the inotify on any file

Source Files

config.go tls.go

Version
v0.4.5 (latest)
Published
Feb 3, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
3 weeks ago

Tools for package owners.