config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 10 Imported by: 8

Documentation

Overview

manage and create configs for Altid services

Index

Constants

View Source
const (
	ErrNoConfigure  = "unable to find or create config for this service"
	ErrNoSuchKey    = "no such key"
	ErrNoEntries    = "unable to find config entries for this service"
	ErrMultiEntries = "config contains duplicate entries for this service"
)

Variables

This section is empty.

Functions

func GetLogDir

func GetLogDir(service string) string

GetLogDir returns a canonical directory for a user log, searching first altid/config If no entry is found or the file is missing, it will return "none"

Types

type Config added in v0.1.0

type Config struct {
	Name   string
	Values []*Entry
}

Config defines a services' configuration in a given config file

func New added in v0.1.0

func New(c Configurator, service string) (*Config, error)

New returns a valid config for a given service. If one is not found, the Configurators Configure method will be called to interactively create one

func (*Config) Log added in v0.1.0

func (c *Config) Log() string

Log returns the configured Log, or "none"

func (*Config) MustSearch added in v0.1.0

func (c *Config) MustSearch(key string) string

MustSearch returns a value or an empty string, if not found

func (*Config) Password added in v0.1.0

func (c *Config) Password() (string, error)

Password queries the database for a password, and uses the factotum

func (*Config) SSLCert added in v0.1.0

func (c *Config) SSLCert() (tls.Certificate, error)

SSLCert returns a tls.Certificate based on successfully finding a cert and key file listen in the configuration

func (*Config) Search added in v0.1.0

func (c *Config) Search(key string) (string, error)

Search queries for an entry in the config matching key Returning the value if it exists, or a "no such key" error

func (*Config) String added in v0.1.0

func (c *Config) String() string

String returns our entry tuples in the form of key=value

type Configurator added in v0.1.0

type Configurator func() (*Config, error)

Configurator is called when no entry is found for a given service It should query the user for each required value, returning a complete and usable Config

type Entry added in v0.1.0

type Entry struct {
	Key   string
	Value string
}

Entry is a single tuple in a services configuration

Jump to

Keyboard shortcuts

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