Documentation ¶
Overview ¶
Package config has config-related types
Index ¶
- Constants
- Variables
- func InsertConfigIfNotPresentTx(db *sql.Tx, cfg Config) error
- func InsertConfigTx(db *sql.Tx, cfg Config) error
- func InsertEntryDB(db *sql.DB, e Entry) error
- func Set(db *sql.DB, settings ...entrySetter) error
- func SetPassword(pw []byte) entrySetter
- type Config
- type DefaultPassword
- type Entry
Constants ¶
const ( // ConfigNameSystemPassword is the name for the system password configuration setting ConfigNameSystemPassword = "SystemPassword" // ConfigSystemPasswordBcryptCost is the cost for bcrypting the system password ConfigSystemPasswordBcryptCost = 10 )
const (
// DefaultPasswordBytes is the default password length in bytes
DefaultPasswordBytes = 32
)
Variables ¶
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
var (
ErrEntryNotFound = errors.New("config entry not found")
)
Functions ¶
func InsertConfigIfNotPresentTx ¶
InsertConfigIfNotPresentTx saves a config set if the names are not present
This funtion should be used inside a (SQL-)transaction
func InsertConfigTx ¶
InsertConfigTx saves a config set
This function should be used inside a (SQL-)transaction
func SetPassword ¶
func SetPassword(pw []byte) entrySetter
SetPassword returns a setter for a cleartext system password
Types ¶
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 ¶
Entry represents a configuration entry
func EntryByNameDB ¶
EntryByNameDB selects the current configuration entry for the given name If the name is not present, it returns nil
func EntryByNameTx ¶
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