conf

package
v0.0.0-...-a0bb070 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunDir = "/var/run/auklet"
)

Variables

View Source
var (
	ErrConfNotFound       = errors.New("unable to find any configs")
	ErrUidNotFound        = errors.New("unable to find uid")
	ErrHashSuffixNotFound = errors.New("hash path suffix not found")
	ErrHashConfigNotFound = errors.New("hash path prefix and suffix not found")
)

Functions

func FindServerConfig

func FindServerConfig(name string) string

func GetHashPrefixAndSuffix

func GetHashPrefixAndSuffix() (string, string, error)

func LoadPolicies

func LoadPolicies() map[int]*Policy

func ReadPrefixedOptions

func ReadPrefixedOptions(conf Section, prefixName string,
	defaults map[string][]string) map[string][]string

func ReadResellerOptions

func ReadResellerOptions(conf Section,
	defaults map[string][]string) ([]string, map[string]map[string][]string)

func UidFromConf

func UidFromConf(path string) (uint32, uint32, error)

UidFromConf returns the uid and gid for the user set in the first config found.

Types

type Config

type Config struct{ ini.File }

Config represents an ini file.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads an ini from a path. The path should be a *.conf file or a *.conf.d directory.

func LoadConfigs

func LoadConfigs(path string) ([]Config, error)

LoadConfigs finds and loads any configs that exist for the given path. Multiple configs are supported for things like SAIO setups.

func StringConfig

func StringConfig(data string) (Config, error)

StringConfig returns an Config from a string, for use in tests.

func (Config) Get

func (f Config) Get(section string, key string) (string, bool)

Get fetches a value from the Config, looking in the DEFAULT section if not found in the specific section. Also ignores "set " key prefixes, like paste.

func (Config) GetBool

func (f Config) GetBool(section string, key string, dfl bool) bool

GetBool loads a true/false value from the // config, with support for things like "yes", "true", "1", "t", etc.

func (Config) GetDefault

func (f Config) GetDefault(section string, key string, dfl string) string

GetDefault returns a value from the config, or returns the default setting if the entry doesn't exist.

func (Config) GetFloat

func (f Config) GetFloat(section string, key string, dfl float64) float64

GetFloat loads an entry from the config, parsed as a floating point value.

func (Config) GetInt

func (f Config) GetInt(section string, key string, dfl int64) int64

GetInt loads an entry from the config, parsed as an integer value.

func (Config) GetLimit

func (f Config) GetLimit(
	section string, key string, dfla int64, dflb int64) (int64, int64)

GetLimit loads an entry from the config in the format of %d/%d.

func (Config) GetSection

func (f Config) GetSection(section string) Section

GetSection returns a Section struct.

func (Config) HasSection

func (f Config) HasSection(section string) bool

HasSection determines whether or not the section exists in the ini file.

type Policy

type Policy struct {
	Index      int
	Type       string
	Name       string
	Aliases    []string
	Default    bool
	Deprecated bool
	Config     map[string]string
}

type Section

type Section struct {
	ini.Section
	// contains filtered or unexported fields
}

func (Section) Get

func (s Section) Get(key string) (string, bool)

func (Section) GetBool

func (s Section) GetBool(key string, dfl bool) bool

func (Section) GetDefault

func (s Section) GetDefault(key string, dfl string) string

func (Section) GetFloat

func (s Section) GetFloat(key string, dfl float64) float64

func (Section) GetInt

func (s Section) GetInt(key string, dfl int64) int64

func (Section) GetLimit

func (s Section) GetLimit(key string, dfla int64, dflb int64) (int64, int64)

Jump to

Keyboard shortcuts

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