config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultConfigDir if o ConfigDir supplied
	DefaultConfigDir = "config"
	// DefaultConfigFile if o ConfigFile supplied
	DefaultConfigFile = "config.yaml"
)

Variables

View Source
var (
	// IsProduction will have CurrentMode of the application
	IsProduction bool

	// Version is populated by govvv in compile-time.
	Version = "untouched"
	// BuildDate is populated by govvv.
	BuildDate string
	// GitCommit is populated by govvv.
	GitCommit string
	// GitBranch is populated by govvv.
	GitBranch string
	// GitState is populated by govvv.
	GitState string
	// GitSummary is populated by govvv.
	GitSummary string
)

Functions

func GetBuildInfo

func GetBuildInfo() string

GetBuildInfo get build info

func InitConfig

func InitConfig(configDir, configFile string)

InitConfig loads the configuration from file then from environment variables and then from cli flags

func LoadExtraConfig

func LoadExtraConfig(configDir, configFile string)

LoadExtraConfig loads the extra configuration from file

func PrintBuildInfo

func PrintBuildInfo()

PrintBuildInfo print build info

Types

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Dialect     DatabaseDialect `json:"dialect" default:"postgres"`
	Host        string          `json:"host"`
	Port        int             `json:"port"`
	Username    string          `json:"username"`
	Password    string          `json:"password"`
	Database    string          `json:"database"`
	Charset     string          `json:"charset" default:"utf8"`
	UTC         bool            `default:"true"`
	Logging     bool            `default:"false"`
	Singularize bool            `default:"false"`
	Params      map[string]interface{}
}

DatabaseConfiguration holds db config

func (*DatabaseConfiguration) URL

func (d *DatabaseConfiguration) URL() (url string, err error)

URL returns a connection string for the database.

type DatabaseDialect

type DatabaseDialect string

DatabaseDialect represents a database dialect constant.

const (
	// PostgreSQLDialect is the dialect name for PostgreSQL.
	PostgreSQLDialect DatabaseDialect = "postgres"
	// MySQLDialect is the dialect name for MySQL.
	MySQLDialect DatabaseDialect = "mysql"
	// SQLiteDialect is the dialect name for SQLite.
	SQLiteDialect DatabaseDialect = "sqlite3"
)

type EmailConfiguration

type EmailConfiguration struct {
	Username    string
	Password    string
	EmailServer string
	Port        int
	From        string
}

EmailConfiguration holds email config

type Environment

type Environment string

Environment represents an application environment.

const (
	// Development environment
	Development Environment = "development"
	// Test environment
	Test Environment = "test"
	// Production environment
	Production Environment = "production"
)

type LogConfiguration

type LogConfiguration struct {
	Level  string `json:"level"`
	Format string `json:"format"` // json or text
}

LogConfiguration holds log config

type ServiceConfiguration

type ServiceConfiguration struct {
	ServiceName string      `json:"name"`
	Version     string      `json:"version"`
	Environment Environment `json:"environment"`
	Log         LogConfiguration
	Database    DatabaseConfiguration
	Email       EmailConfiguration
}

TODO: use proto to define config.yaml schema ServiceConfiguration is the top level configuration struct which is loaded from the defined source(s)

Jump to

Keyboard shortcuts

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