configloader

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package configloader implements a Config type for loading in the configuration to be used by the app.

It supports reading in configuration from the "bolt.toml" file if it can be found in the current directory or any parent directory and it supports reading in environment variables. Furthermore, if both a configuration file is found and environment variables are set, the environment variables will take precedence.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigFileNotFound = errors.New(
		"bolt configuration file not found in current directory or any parent directories",
	)
	ErrInvalidVersionStyle = fmt.Errorf(
		"invalid version style for bolt migrations. supported styles: %v",
		[]VersionStyle{VersionStyleSequential, VersionStyleTimestamp},
	)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Migrations MigrationsConfig `toml:"migrations"`

	// Information related to how to connect to the database
	// that is desired to run migrations against.
	Connection ConnectionConfig `toml:"database"`
}

Config represents the application configuration settings.

This can come from the TOML file or environment variables, with environment variables taking precedence.

func NewConfig

func NewConfig() (*Config, error)

type ConnectionConfig

type ConnectionConfig struct {
	Host     string `toml:"host"     envconfig:"BOLT_DB_HOST"`
	Port     string `toml:"port"     envconfig:"BOLT_DB_PORT"`
	User     string `toml:"user"     envconfig:"BOLT_DB_USER"`
	Password string `toml:"password" envconfig:"BOLT_DB_PASSWORD"`
	DBName   string `toml:"dbname"   envconfig:"BOLT_DB_NAME"`
	Driver   string `toml:"driver"   envconfig:"BOLT_DB_DRIVER"`
}

type MigrationsConfig

type MigrationsConfig struct {
	DirectoryPath string       `toml:"directory_path" envconfig:"BOLT_MIGRATIONS_DIR_PATH"`
	VersionStyle  VersionStyle `toml:"version_style"  envconfig:"BOLT_MIGRATIONS_VERSION_STYLE"`
}

type VersionStyle added in v0.3.0

type VersionStyle string
const (
	VersionStyleSequential VersionStyle = "sequential"
	VersionStyleTimestamp  VersionStyle = "timestamp"
)

Jump to

Keyboard shortcuts

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