Documentation
¶
Overview ¶
Package config provides the global configuration for Ocular.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Version is the version of the application. Version = "dev" // BuildTime is the date when the application was built. BuildTime = "unknown" // Commit is the commit hash of the application. Commit = "unknown" )
Functions ¶
func InitLogger ¶
InitLogger initializes the logger for the application. It sets the logging level and format based on the configuration. It also replaces the global logger with the new logger.
func IsEnvironmentIn ¶
func IsEnvironmentIn(envs ...Environment) bool
IsEnvironmentIn checks if the current environment is one of the provided environments.
func WriteConfig ¶
Types ¶
type Config ¶
type Config struct {
// Environment is the environment that Ocular is running in.
Environment string `json:"environment" yaml:"environment"`
// Logging is the configuration for the logger.
Logging struct {
// Level is the logging level.
Level string `json:"level"`
Format string `json:"format"` // TODO(bryce): add format support
} `json:"logging" yaml:"logging"`
}
Config is the structure for the global configuration file for Ocular. It is loaded from a config file at startup time, and values can be overridden by environment variables. The config file is expected to be in YAML format. Environment variables are expected to be prefixed with "OCULAR_", all capital and use underscores to separate nested keys. For example, the key "api.tls.enabled" can be overridden by the environment variable "OCULAR_API_TLS_ENABLED".
var State Config
State is the global configuration state for Ocular.
type Environment ¶
type Environment = uint8
Environment represents the different environments the application can run in. It is used to determine the current environment based on the configuration file.
const ( // EnvProduction represents the production environment. EnvProduction Environment = iota // EnvStaging represents the staging environment. This // ideally should be result in a configuration identical to production, // but mainly used for metadata purposes. EnvStaging // EnvDevelopment represents the development environment. EnvDevelopment // EnvTest represents the test environment (both unit and integration). EnvTest )