Documentation ¶
Overview ¶
Config controls the overall configuration of the application.
It is generated by first attempting to read a configuration file and then overwriting those values with anything found in environment variables. Environment variables always come last and have the highest priority. As per (https://12factor.net/config).
All environment variables are prefixed with "GOFER". Ex: GOFER_DEBUG=true
Most envvar configuration abides by common envvar string=string formatting: Ex. `export GOFER_DEBUG=true`. Complex envvars like "Triggers" for example take a json string as value.
Example: export GOFER_TRIGGERS="{"name":"test"},{"name":"test2"}"
You can print out a current description of current environment variable configuration by using the cli command:
`gofer service printenv`
Note: Even though this package uses the envconfig package it is incorrect to use the 'default' struct tags as that will cause incorrect overwriting of user defined configurations.
Note: Because of the idiosyncrasies of how hcl conversion works certain advanced types like `time.Duration` need to have a sister variable that we read in through hcl via another type and convert to the actual wanted type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintAPIEnvs ¶
func PrintAPIEnvs() error
func PrintCLIEnvs ¶
func PrintCLIEnvs() error
Types ¶
type API ¶
type API struct { // DevMode turns on humanized debug messages, extra debug logging for the web server and other // convenient features for development. Usually turned on along side LogLevel=debug. DevMode bool `hcl:"dev_mode,optional"` // Controls the ability to trigger runs. This setting can be toggled while the server is running. IgnorePipelineRunEvents bool `split_words:"true" hcl:"ignore_pipeline_run_events,optional"` /// The limit automatically imposed if the pipeline does not define a limit. 0 is unlimited. RunParallelismLimit int `split_words:"true" hcl:"run_parallelism_limit,optional"` // Controls how long Gofer will hold onto events before discarding them. This is important factor in disk space // and memory footprint. // // Example: Rough math on a 5,000 pipeline Gofer instance with a full 6 months of retention // puts the memory and storage footprint at about 9GB. EventLogRetention time.Duration `split_words:"true"` // EventLogRetentionHCL is the HCL compatible counter part to EventLogRetention. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. EventLogRetentionHCL string `ignored:"true" hcl:"event_log_retention,optional"` // How often the background process for pruning events should run. EventPruneInterval time.Duration `split_words:"true"` // EventPruneIntervalHCL is the HCL compatible counter part to PruneEventsInterval. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. EventPruneIntervalHCL string `ignored:"true" hcl:"event_prune_interval,optional"` // Log level affects the entire application's logs including launched triggers. LogLevel string `split_words:"true" hcl:"log_level,optional"` // The total amount of runs before logs of the oldest log starts being deleted. TaskRunLogExpiry int `split_words:"true" hcl:"task_run_log_expiry,optional"` // Directory to store task run log files. TaskRunLogsDir string `split_words:"true" hcl:"task_run_logs_dir,optional"` // TaskRunStopTimeout controls the time the scheduler will wait for a normal user container(non-trigger containers) // to stop. When the timeout is reached the container will be forcefully terminated. // You can use a negative duration("-1s") to convey that no timeout should be specified and the scheduler // should wait however long it takes the container to respond to the terminate signal. // This is usually passed to the scheduler when a request to cancel a task run is being made. TaskRunStopTimeout time.Duration `split_words:"true"` // TaskRunStopTimeoutHCL is the HCL compatible counter part to TaskRunStopTimeout. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. TaskRunStopTimeoutHCL string `ignored:"true" hcl:"task_run_stop_timeout,optional"` ExternalEventsAPI *ExternalEventsAPI `split_words:"true" hcl:"external_events_api,block"` ObjectStore *ObjectStore `hcl:"object_store,block"` SecretStore *SecretStore `hcl:"secret_store,block"` Scheduler *Scheduler `hcl:"scheduler,block"` Server *Server `hcl:"server,block"` Triggers *Triggers `hcl:"triggers,block"` }
API defines config settings for the gofer server
func DefaultAPIConfig ¶
func DefaultAPIConfig() *API
func InitAPIConfig ¶
Get the final configuration for the server. This involves correctly finding and ordering different possible paths for the configuration file.
1) The function is intended to be called with paths gleaned from the -config flag 2) Then combine that with possible other config locations that the user might store a config file. 3) Then try to see if the user has set an envvar for the config file, which overrides all previous config file paths. 4) Finally, pass back whatever is deemed the final config path from that process.
We then use that path data to find the config file and read it in via HCL parsers. Once that is finished we then take any configuration from the environment and superimpose that on top of the final config struct.
type CLI ¶
type CLI struct { Namespace string `split_words:"true" hcl:"namespace,optional"` Detail bool `hcl:"detail,optional"` Format string `hcl:"format,optional"` Host string `hcl:"host,optional"` NoColor bool `split_words:"true" hcl:"no_color,optional"` Token string `hcl:"token,optional"` }
func DefaultCLIConfig ¶
func DefaultCLIConfig() *CLI
DefaultCLIConfig returns a pre-populated configuration struct that is used as the base for super imposing user configuration settings.
func InitCLIConfig ¶
Get the final configuration for the CLI. This involves correctly finding and ordering different possible paths for the configuration file.
1) The function is intended to be called with paths gleaned from the -config flag 2) Then combine that with possible other config locations that the user might store a config file. 3) Then try to see if the user has set an envvar for the config file, which overrides all previous config file paths. 4) Finally, pass back whatever is deemed the final config path from that process.
We then use that path data to find the config file and read it in via HCL parsers. Once that is finished we then take any configuration from the environment and superimpose that on top of the final config struct.
type Docker ¶
type Docker struct { // Prune runs a reoccuring `docker system prune` job to avoid filling the local disk with docker images. Prune bool `hcl:"prune,optional"` // The period of time in between runs of `docker system prune` PruneInterval time.Duration `split_words:"true"` // PruneIntervalHCL is the HCL compatible counter part to PruneInterval. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. PruneIntervalHCL string `ignored:"true" hcl:"prune_interval,optional"` }
func DefaultDockerConfig ¶
func DefaultDockerConfig() *Docker
type ExternalEventsAPI ¶
type ExternalEventsAPI struct { Enable bool `hcl:"enable,optional"` // URL for the server to bind to. Ex: localhost:8080 Host string `hcl:"host,optional"` }
ExternalEventsAPI controls how the settings around the HTTP service that handles external trigger events.
func DefaultExternalEventsAPIConfig ¶
func DefaultExternalEventsAPIConfig() *ExternalEventsAPI
type Frontend ¶
type Frontend struct {
Enable bool `hcl:"enable,optional"`
}
Frontend represents configuration for frontend basecoat
type ObjectStore ¶
type ObjectStore struct { // The ObjectStore engine used by the backend. // Possible values are: bolt Engine string `hcl:"engine,optional"` Sqlite *Sqlite `hcl:"sqlite,block"` // Pipeline Objects last forever but are limited in number. This is the total amount of items that can be stored // per pipeline before gofer starts deleting objects. PipelineObjectLimit int `split_words:"true" hcl:"pipeline_object_limit,optional"` // Objects stored at the run level are unlimited in number, but only last for a certain number of runs. // The number below controls how many runs until the run objects for the oldest run will be deleted. // Ex. an object stored on run number #5 with an expiry of 2 will be deleted on run #7 regardless of run // health. RunObjectExpiry int `split_words:"true" hcl:"run_object_expiry,optional"` }
ObjectStore defines config settings for gofer ObjectStore. The ObjectStore stores temporary objects for pipelines and runs.
func DefaultObjectStoreConfig ¶
func DefaultObjectStoreConfig() *ObjectStore
type Scheduler ¶
type Scheduler struct { // The database engine used by the scheduler // possible values are: docker Engine string `hcl:"engine,optional"` Docker *Docker `hcl:"docker,block"` }
Scheduler defines config settings for gofer scheduler. The scheduler is the backend for how containers are run.
func DefaultSchedulerConfig ¶
func DefaultSchedulerConfig() *Scheduler
type SecretStore ¶ added in v0.0.3
type SecretStore struct { // The ObjectStore engine used by the backend. // Possible values are: sqlite Engine string `hcl:"engine,optional"` Sqlite *SqliteSecret `hcl:"sqlite,block"` }
SecretStore defines the configuration for Gofer's secret backend.
func DefaultSecretStoreConfig ¶ added in v0.0.3
func DefaultSecretStoreConfig() *SecretStore
type Server ¶
type Server struct { // URL for the server to bind to. Ex: localhost:8080 Host string `hcl:"host,optional"` // How long the GRPC service should wait on in-progress connections before hard closing everything out. ShutdownTimeout time.Duration `split_words:"true"` // ShutdownTimeoutHCL is the HCL compatible counter part to ShutdownTimeout. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. ShutdownTimeoutHCL string `ignored:"true" hcl:"shutdown_timeout,optional"` // Path to Gofer's sqlite database. StoragePath string `split_words:"true" hcl:"storage_path,optional"` // The total amount of results the database will attempt to pass back when a limit is not explicitly given. StorageResultsLimit int `split_words:"true" hcl:"storage_results_limit,optional"` TLSCertPath string `split_words:"true" hcl:"tls_cert_path,optional"` TLSKeyPath string `split_words:"true" hcl:"tls_key_path,optional"` }
Server represents lower level HTTP/GRPC server settings.
func DefaultServerConfig ¶
func DefaultServerConfig() *Server
DefaultServerConfig returns a pre-populated configuration struct that is used as the base for super imposing user configuration settings.
type Sqlite ¶ added in v0.3.0
type Sqlite struct {
Path string `hcl:"path,optional"` // file path for database file
}
Sqlite
type SqliteSecret ¶ added in v0.3.0
type SqliteSecret struct { Path string `hcl:"path,optional"` // file path for database file // EncryptionKey is a 32-bit random string of characters used to encrypt data at rest. EncryptionKey string `split_words:"true" hcl:"encryption_key,optional"` }
SqliteSecret
type Triggers ¶
type Triggers struct { // InstallBaseTriggers attempts to automatically install the cron and interval triggers on first startup. InstallBaseTriggers bool `split_words:"true" hcl:"install_base_triggers,optional"` // StopTimeout controls the time the scheduler will wait for a trigger container to stop. After this period // Gofer will attempt to force stop the trigger container. StopTimeout time.Duration `split_words:"true"` // StopTimeoutHCL is the HCL compatible counter part to TriggerStopTimeout. It allows the parsing of a string // to a time.Duration since HCL does not support parsing directly into a time.Duration. StopTimeoutHCL string `ignored:"true" hcl:"stop_timeout,optional"` // TLSCertPath is the file path of the trigger TLS certificate. TLSCertPath string `split_words:"true" hcl:"tls_cert_path,optional"` // TLSKeyPath is the file path of the trigger TLS key. TLSKeyPath string `split_words:"true" hcl:"tls_key_path,optional"` }
Triggers represents the configuration for Gofer Triggers. Triggers are used to generate events in which pipelines should run.
func DefaultTriggersConfig ¶
func DefaultTriggersConfig() *Triggers