config

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config provides the global configuration for Ocular.

Index

Constants

This section is empty.

Variables

View Source
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 Init

func Init()

func InitEnv

func InitEnv()

InitEnv initializes the environment based on the configuration file.

func InitLogger

func InitLogger(level, format string, globalFields ...zap.Field)

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

func WriteConfig(w io.Writer) error

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL