config.go | |
---|---|
|
|
This source file contains definition of data type named ConfigStruct that represents configuration of Insights Results Aggregator Cleaner. This source file also contains function named LoadConfiguration that can be used to load configuration from provided configuration file and/or from environment variables. Additionally several specific functions named GetStorageConfiguration, GetLoggingConfiguration, and GetCleanerConfiguration are to be used to return specific configuration options. |
|
Generated documentation is available at: https://pkg.go.dev/github.com/RedHatInsights/insights-results-aggregator-cleaner |
|
Documentation in literate-programming-style is available at: https://redhatinsights.github.io/insights-results-aggregator-cleaner/packages/config.html |
|
Default name of configuration file is config.toml It can be changed via environment variable INSIGHTSRESULTSCLEANERCONFIGFILE |
|
An example of configuration file that can be used in devel environment: [storage] dbdriver = "postgres" pgusername = "postgres" pgpassword = "postgres" pghost = "localhost" pgport = 5432 pgdbname = "aggregator" pgparams = "sslmode=disable" [logging] debug = true log_level = "" [cleaner] maxage = "90 days" clusterlistfile = "clusterlist.txt" Environment variables that can be used to override configuration file settings: INSIGHTSRESULTSCLEANERSTORAGEDBDRIVER INSIGHTSRESULTS_CLEANERSTORAGEPGUSERNAME INSIGHTSRESULTS_CLEANERSTORAGEPGPASSWORD INSIGHTSRESULTS_CLEANERSTORAGEPGHOST INSIGHTSRESULTS_CLEANERSTORAGEPGPORT INSIGHTSRESULTS_CLEANERSTORAGEPGDBNAME INSIGHTSRESULTSCLEANERSTORAGEPGPARAMS INSIGHTSRESULTS_CLEANERLOGGINGDEBUG INSIGHTSRESULTSCLEANERLOGGINGLOGDEVEL INSIGHTSRESULTS_CLEANERCLEANERMAX_AGE |
|
Common constants used for during logging and error reporting |
|
ConfigStruct is a structure holding the whole service configuration |
|
LoggingConfiguration represents configuration for logging in general |
|
Debug enables pretty colored logging |
|
LogLevel sets logging level to show. Possible values are: "debug" "info" "warn", "warning" "error" "fatal" logging level won't be changed if value is not one of listed above |
|
LoggingToCloudWatchEnabled enables logging to CloudWatch (configuration for CloudWatch is in CloudWatchConfiguration) |
|
CleanerConfiguration represents configuration for the main cleaner |
|
MaxAge is specification of max age for records to be cleaned |
|
ClusterListFile contains file name with list of clusters to delete |
|
StorageConfiguration represents configuration of data storage |
|
LoadConfiguration function loads configuration from defaultConfigFile, file set in configFileEnvVariableName or from environment variables |
|
env. variable holding name of configuration file |
|
we need to separate the directory name and filename without extension |
|
parse the configuration |
|
parse the configuration |
|
try to read the whole configuration |
|
If configuration file is not present (which might be correct in some environment) we need to read configuration from environment variables. The problem is that Viper is not smart enough to understand the structure of config by itself, so we need to read fake config file |
|
check for error during parsing |
|
error is processed on caller side |
|
override config from env if there's variable in env |
|
try to unmarshall configuration and check for (any) error |
|
updated configuration by introducing Clowder-related things |
|
GetStorageConfiguration function returns storage configuration |
|
GetLoggingConfiguration function returns logging configuration |
|
GetCleanerConfiguration returns cleaner configuration |
|
updateConfigFromClowder function updates the current config with the values defined in clowder |
|
can not use Zerolog at this moment! we have to use standard output |
|
get DB configuration from clowder |
|