config

package
v0.0.0-...-b3f3fbb Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2015 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package config has config-related types

Index

Constants

View Source
const (
	// ConfigNameSystemPassword is the name for the system password configuration setting
	ConfigNameSystemPassword = "SystemPassword"
	// ConfigSystemPasswordBcryptCost is the cost for bcrypting the system password
	ConfigSystemPasswordBcryptCost = 10
)
View Source
const (
	// DefaultPasswordBytes is the default password length in bytes
	DefaultPasswordBytes = 32
)

Variables

View Source
var DefaultPasswordSetter = entrySetter(func(c Config) error {
	pw := make([]byte, DefaultPasswordBytes)
	_, err := rand.Read(pw)
	if err != nil {
		return err
	}

	c[ConfigNameSystemPassword] = hex.EncodeToString(pw)
	return nil
})

DefaultPasswordSetter sets a default password

View Source
var (
	ErrEntryNotFound = errors.New("config entry not found")
)

Functions

func InsertConfigIfNotPresentTx

func InsertConfigIfNotPresentTx(db *sql.Tx, cfg Config) error

InsertConfigIfNotPresentTx saves a config set if the names are not present

This funtion should be used inside a (SQL-)transaction

func InsertConfigTx

func InsertConfigTx(db *sql.Tx, cfg Config) error

InsertConfigTx saves a config set

This function should be used inside a (SQL-)transaction

func InsertEntryDB

func InsertEntryDB(db *sql.DB, e Entry) error

InsertEntryDB inserts an entry

func Set

func Set(db *sql.DB, settings ...entrySetter) error

Set sets passed configuration settings

func SetPassword

func SetPassword(pw []byte) entrySetter

SetPassword returns a setter for a cleartext system password

Types

type Config

type Config map[string]string

Config represents a config set

func NewConfig

func NewConfig() Config

NewConfig creates a new config set

type DefaultPassword

type DefaultPassword string

DefaultPassword represents a default password generation and setting

func (DefaultPassword) Entry

func (d DefaultPassword) Entry() entrySetter

Entry returns a setter, which can be used with the Set() function for setting the default system password

func (*DefaultPassword) Generate

func (d *DefaultPassword) Generate() error

Generate generates a random password

type Entry

type Entry struct {
	Name string

	Value string
	// contains filtered or unexported fields
}

Entry represents a configuration entry

func EntryByNameDB

func EntryByNameDB(db *sql.DB, name string) (Entry, error)

EntryByNameDB selects the current configuration entry for the given name If the name is not present, it returns nil

func EntryByNameTx

func EntryByNameTx(db *sql.Tx, name string) (Entry, error)

EntryByNameTx selects the current configuration entry for the given name If the name is not present, it returns nil

This function should be used inside a (SQL-)transaction

func (Entry) Empty

func (e Entry) Empty() bool

Empty returns true if the entry is considered empty/not set

Jump to

Keyboard shortcuts

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