config

package
v0.0.0-...-dd2dcfe Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config allows a struct-loading approach to configuration. This is a modified version of the ucpconfig package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetString

func GetString(name string) string

GetString - Get the string value for the named configuration property

func GetValue

func GetValue(name string) (string, error)

GetValue tries to look up an env var of the given name and then tries to look up the secret file of the same

func IsSet

func IsSet(name string) bool

IsSet - is the specified config name set?

func Load

func Load(intf interface{}) error

Load the given pointer to struct with values from the environment and the /etc/secrets/ directory.

In order to make the struct load correctly, use struct tags to define the configuration name, if the configName struct tag is ommitted it will not attempt to look anything up. This is contrary to most serialization libraries like JSON which require a "-" struct tag to bypass deserialization.

type A struct {
  Port   uint    `configName:"PORT"`
  Name   string  `configName:"SERVICE_NAME"`
  Struct *myType
}

The name will be given as defined to Getenv, and if that fails a lookup it's name is then munged to conform to the /etc/secrets filename structure and the file is attempted to be read.

func LoadConfigFile

func LoadConfigFile(path string) error

LoadConfigFile - Load the configuration values in the specified config file if it exists

func SetStructFieldValue

func SetStructFieldValue(value reflect.Value, field reflect.Value, val string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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