config

package
v0.0.0-...-4c24d26 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 12 Imported by: 2

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 Load

func Load(intf interface{}, envLookup env.Lookup) 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 NewConfigFileLookup

func NewConfigFileLookup(path string) env.Lookup

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

func NewSecretsDirLookup

func NewSecretsDirLookup(secretsDir string) env.Lookup

NewSecretsDirLookup - create a secret dir lookup reads a variable in the form HELLO_THERE from a file in /etc/secrets/hello-there

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