config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: BSD-3-Clause Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DBConfigFilename is the filename for the database config file
	DBConfigFilename = "database.toml"
	// 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 added in v1.0.0

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 config file.

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/database.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() (*Configuration, error)

Initialize the config

func InitializeP

func InitializeP() *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
	Host    string
	Port    int
	DBName  string
	User    string
	Pass    string
	SSLMode string
	// Other SQLBoiler flags
	Blacklist        []string
	Whitelist        []string
	Tag              []string
	Replacements     []string
	BaseDir          string
	Output           string
	PkgName          string
	Schema           string
	TinyintNotBool   bool
	NoAutoTimestamps bool
	Debug            bool
	NoHooks          bool
	NoTests          bool
	Wipe             bool
}

DBConfig holds the configuration variables contained in the database.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