Documentation
¶
Index ¶
- Variables
- func InitConfig(cfgFile string) error
- type Key
- func (k *Key) Bool() bool
- func (k *Key) Duration() time.Duration
- func (k *Key) Float64() float64
- func (k *Key) Images() []*structs.Image
- func (k *Key) Int() int
- func (k *Key) Int64() int64
- func (k *Key) Repositories() []*structs.Repository
- func (k *Key) String() string
- func (k *Key) StringSlice() []string
- func (k *Key) UInt64() uint64
- func (k *Key) Update() *ReloadedKey
- type KeyOption
- func WithAllowedInts(values []int) KeyOption
- func WithAllowedStrings(values []string) KeyOption
- func WithDefaultValue(defaultValue interface{}) KeyOption
- func WithValidBool() KeyOption
- func WithValidDuration() KeyOption
- func WithValidExistingPathOrEmpty() KeyOption
- func WithValidFloat64() KeyOption
- func WithValidImages() KeyOption
- func WithValidInt() KeyOption
- func WithValidMap() KeyOption
- func WithValidNetHostPort() KeyOption
- func WithValidPositiveInt() KeyOption
- func WithValidRepositories() KeyOption
- func WithValidString() KeyOption
- func WithValidStringSlice() KeyOption
- func WithValidURI() KeyOption
- func WithValidURL() KeyOption
- func WithValidationFunc(f func(interface{}) error) KeyOption
- type ReloadedKey
Constants ¶
This section is empty.
Variables ¶
var ( // LoggingFormat defines the logging format used for log messages. Allowed values are "json" and "text". LoggingFormat = NewKey("logging.format", WithDefaultValue("text"), WithAllowedStrings([]string{"json", "text"})) // LoggingColors specifies whether log messages are displayed with color-coded // output. This only applies when LoggingFormat is set to "text". LoggingColors = NewKey("logging.colors", WithDefaultValue(true), WithValidBool()) // LoggingTimeFormat specifies the time format used for log messages. The default is 15:04:05. LoggingTimeFormat = NewKey("logging.timeFormat", WithDefaultValue("15:04:05")) // LoggingOutput specifies the destination where log messages created by the // application are sent. It defaults to stdout. LoggingOutput = NewKey("logging.output", WithDefaultValue("stdout")) // LoggingLevel specifies the minimum severity a log message must meet to be // recorded. LoggingLevel = NewKey("logging.level", WithDefaultValue("INFO"), WithAllowedStrings([]string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC", "DISABLED"})) // TelemetryEnabled indicates whether telemetry is enabled. TelemetryEnabled = NewKey("telemetry.enabled", WithDefaultValue(false), WithValidBool()) // TelemetryMetricsExporter specifies the metrics exporter used for telemetry. TelemetryMetricsExporter = NewKey("telemetry.metrics.exporter", WithDefaultValue("prometheus"), WithAllowedStrings([]string{"prometheus", "stdout"})) // TelemetryMetricsPrometheusAddress specifies the network address for the Prometheus TelemetryMetricsPrometheusAddress = NewKey("telemetry.metrics.prometheus.address", WithDefaultValue("127.0.0.1:9090"), WithValidNetHostPort()) // TelemetryMetricsPrometheusPath specifies the path for the Prometheus metrics endpoint. TelemetryMetricsPrometheusPath = NewKey("telemetry.metrics.prometheus.path", WithDefaultValue("/metrics"), WithValidURI()) // TelemetryMetricsStdoutInterval specifies the sampling interval for sending metrics to stdout. TelemetryMetricsStdoutInterval = NewKey("telemetry.metrics.stdout.interval", WithDefaultValue("5s"), WithValidDuration()) // SyncMaxErrors specifies the maximum number of errors that can occur before the application exits. SyncMaxErrors = NewKey("sync.maxErrors", WithDefaultValue(5), WithValidInt()) // SyncInterval specifies the interval at which images are synchronized. SyncInterval = NewKey("sync.interval", WithDefaultValue("30m"), WithValidDuration()) // SyncMinInterval specifies the minimum interval at which images are synchronized if they were already synchronized before. SyncMinInterval = NewKey("sync.minInterval", WithDefaultValue("12h"), WithValidDuration()) // SyncRegistries specifies the repositories to use for pulling and pushing images. SyncRegistries = NewKey("sync.registries", WithDefaultValue([]map[string]interface{}{ { "name": "Docker Hub", "url": "docker.io", "auth": map[string]interface{}{ "username": "", "password": "", "token": "", "helper": "", }, }, }), WithValidRepositories()) // SyncImages specifies the images to synchronize. SyncImages = NewKey("sync.images", WithDefaultValue([]map[string]interface{}{ { "source": "docker.io/library/ubuntu", "targets": []string{ "docker.io/library/ubuntu", }, }, }), WithValidImages()) )
var ( ECRRegion = NewKey("ecr.region", WithDefaultValue("us-east-1"), WithValidString()) )
var Version = "dev"
Version specifies the current version of the application. It defaults to "dev" to indicate development mode but can be set to reflect the release version during the build process.
Functions ¶
func InitConfig ¶
InitConfig initializes the application's configuration system. It loads settings from a specified file, environment variables, or search paths, and listens for changes to dynamically update the configuration.
Types ¶
type Key ¶
type Key struct {
Name string
Default interface{}
Value interface{}
ValidationFuncs []func(interface{}) error
// contains filtered or unexported fields
}
func NewKey ¶
NewKey creates a new configuration key with the specified name and additional options.
func (*Key) Repositories ¶
func (k *Key) Repositories() []*structs.Repository
func (*Key) StringSlice ¶
func (*Key) Update ¶
func (k *Key) Update() *ReloadedKey
type KeyOption ¶
type KeyOption func(*Key)
func WithAllowedInts ¶
WithAllowedInts sets the allowed values for the configuration key.
func WithAllowedStrings ¶
WithAllowedStrings sets the allowed values for the configuration key.
func WithDefaultValue ¶
func WithDefaultValue(defaultValue interface{}) KeyOption
WithDefaultValue sets the default value for the configuration key.
func WithValidDuration ¶
func WithValidDuration() KeyOption
WithValidDuration checks if the value is a duration.
func WithValidExistingPathOrEmpty ¶
func WithValidExistingPathOrEmpty() KeyOption
WithValidExistingPathOrEmpty checks if the value is an existing path or if it is empty.
func WithValidFloat64 ¶
func WithValidFloat64() KeyOption
WithValidFloat64 checks if the value is a float64.
func WithValidImages ¶
func WithValidImages() KeyOption
WithValidImages checks if the value is a valid image.
func WithValidNetHostPort ¶
func WithValidNetHostPort() KeyOption
WithValidNetHostPort checks if the value is a valid host:port string.
func WithValidPositiveInt ¶
func WithValidPositiveInt() KeyOption
WithValidPositiveInt checks if the value is a positive integer.
func WithValidRepositories ¶
func WithValidRepositories() KeyOption
WithValidRepositories checks if the value is a valid repository.
func WithValidString ¶
func WithValidString() KeyOption
WithValidString checks if the value is a string.
func WithValidStringSlice ¶
func WithValidStringSlice() KeyOption
WithValidStringSlice checks if the value is a string slice.
func WithValidationFunc ¶
WithValidationFunc adds a validation function for the configuration key.
type ReloadedKey ¶
func Reload ¶
func Reload() []*ReloadedKey