config

package
v2.1.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2017 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppConfigFilename is the filename for the app config file
	AppConfigFilename = "config.toml"
)

Variables

View Source
var AppFS = afero.NewOsFs()

AppFS is a handle to the filesystem in use

Functions

func GetBasePath

func GetBasePath() (string, error)

GetBasePath returns the full path to the custom sqlboiler template files folder used with the sqlboiler --replace flag.

func NewModeViper

func NewModeViper(appPath string, envAppName, env string) *viper.Viper

NewModeViper creates a viper.Viper with config path and environment prefixes set. It also specifies a Sub of the active environment (the chosen env mode) and reads in the database config file section.

Types

type AppConfig

type AppConfig struct {
	DefaultEnv string `toml:"env"`
}

AppConfig holds the relevant generated app config.toml file variables

type Configuration

type Configuration struct {
	// AppPath is the path to the project, set using the init function
	AppPath string

	// AppName is the name of the application, derived from the path
	AppName string

	// AppEnvName is the name of the app in environment variable prefix format
	// for example "MYAPP" instead of "MyApp".
	AppEnvName string

	// ActiveEnv is the environment mode currently set by "env" in config.toml
	// or APPNAME_ENV environment variable. This mode indicates what section of
	// config variables to to load into the config structs.
	ActiveEnv string

	// ModeViper is a *viper.Viper that has been initialized to:
	// Load the active environment section of the AppPath/config.toml file
	// Load environment variables with a prefix of APPNAME
	// Replace "-" with "_" in environment variable names
	ModeViper *viper.Viper
}

Configuration holds app state variables

func Initialize

func Initialize(env *pflag.Flag) (*Configuration, error)

Initialize the config

func InitializeP

func InitializeP(env *pflag.Flag) *Configuration

InitializeP the config but panic if anything goes wrong

func (*Configuration) CheckEnv

func (c *Configuration) CheckEnv() error

CheckEnv outputs an error if no ActiveEnv is found

type DBConfig

type DBConfig struct {
	DB      string `toml:"db" mapstructure:"db"`
	Host    string `toml:"host" mapstructure:"host"`
	Port    int    `toml:"port" mapstructure:"port"`
	DBName  string `toml:"dbname" mapstructure:"dbname"`
	User    string `toml:"user" mapstructure:"user"`
	Pass    string `toml:"pass" mapstructure:"pass"`
	SSLMode string `toml:"sslmode" mapstructure:"sslmode"`
	// Other SQLBoiler flags
	Blacklist        []string `toml:"blacklist" mapstructure:"blacklist"`
	Whitelist        []string `toml:"whitelist" mapstructure:"whitelist"`
	Tag              []string `toml:"tag" mapstructure:"tag"`
	Replacements     []string `toml:"replacements" mapstructure:"replacements"`
	BaseDir          string   `toml:"base_dir" mapstructure:"base_dir"`
	Output           string   `toml:"output" mapstructure:"output"`
	PkgName          string   `toml:"pkg_name" mapstructure:"pkg_name"`
	Schema           string   `toml:"schema" mapstructure:"schema"`
	TinyintNotBool   bool     `toml:"tinyint_not_bool" mapstructure:"tinyint_not_bool"`
	NoAutoTimestamps bool     `toml:"no_auto_timestamps" mapstructure:"no_auto_timestamps"`
	Debug            bool     `toml:"debug" mapstructure:"debug"`
	NoHooks          bool     `toml:"no_hooks" mapstructure:"no_hooks"`
	NoTests          bool     `toml:"no_tests" mapstructure:"no_tests"`
	Wipe             bool     `toml:"wipe" mapstructure:"wipe"`
}

DBConfig holds the configuration variables contained in the config.toml file for the environment currently loaded (obtained from GetDatabaseEnv())

Jump to

Keyboard shortcuts

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