settings

package
v1.1.1-0...-acba925 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package settings is a package that implements Dependency Injection through methods that create the options needed for structs to be created. See GetSettings for more information.

This package uses anonymous structs as the injection options, this is to avoid issues with import loops when importing settings into *_test.go files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Settings

type Settings struct {
	DBDriver string
	DBDsn    string
	Home     string

	// No Colour output when running commands.
	NoColour bool
	// Project name, normally supplied by the start sub command.
	ProjectName      string
	PathMetadataDir  string
	PathTemplateConf string
	PathTemplateDir  string
	PathUserConf     string
	SqliteDB         string
	Stdin            io.Reader
	Stderr           io.Writer
	Stdout           io.Writer
	// contains filtered or unexported fields
}

Settings provides settings for resources & services.

func GetSettings

func GetSettings(home string) *Settings

GetSettings get settings using the supplied "home" directory option. Any Dependency Injection (DI) configuration created by settings is then contextualized by the home variable. For instance when home is set the paths...

{{home}}/.prjstart/config.yml
{{home}}/.prjstart/templates.yml
{{home}}/.prjstart/metadata/metadata.db
{{home}}/.prjstart/templates
etc..

are then factored in when creating dependency injections.

If initialization is needed for testing then the initialize package can be used. For example

set := GetSettings("/tmp/tmp_home");
init := initialize.New(iinitialize.Inject(s));
init.Init()

will create the structures under "/tmp/tmp_home"

"home" must be explicitly set or a panic will ensue.

func (*Settings) ConfigFile

func (s *Settings) ConfigFile() *config.File

ConfigFile load settings from configuration file

func (*Settings) GetDB

func (s *Settings) GetDB() *sql.DB

GetDB return DB object.

func (*Settings) GetLogger

func (s *Settings) GetLogger() *log.Logger

GetLogger inject logger object.

func (*Settings) LogLevel

func (s *Settings) LogLevel(lvl log.Level)

LogLevel Sets the log level

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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