config

package module
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: GPL-3.0 Imports: 10 Imported by: 1

README

Documentation

Overview

Package config loads configuation objects and provides thin wrappers for interpreting them. It reads a search path from the CONFIG_PATH environment variable. All files found along the search path are read and cached and are accessible by file name.

Currently, the config package does not support recursive searching; directories found on the search path are ignored.

Index

Constants

View Source
const EnvVar = "CONFIG_PATH"

EnvVar is the name of the environment variable used to determine the config path. If it is provided, it will override the DefaultPath value.

Variables

View Source
var DefaultPath string

DefaultPath is the fallback config path if CONFIG_PATH is not defined. It is "/etc/config" if IsKubernetes(). Otherwise, it is "./config".

Functions

func Bytes added in v0.0.6

func Bytes(n string) ([]byte, error)

Bytes calls Load() then returns the data for the configuration value named n.

func InterfaceJson added in v0.0.13

func InterfaceJson(n string, v interface{}) error

InterfaceJson calls json.Unmarshal() on Bytes(n)

func InterfaceYaml added in v0.0.14

func InterfaceYaml(n string, v interface{}) error

InterfaceYaml calls yaml.Unmarshal() on Bytes(n)

func IsKubernetes added in v0.0.15

func IsKubernetes() bool

IsKubernetes determines if we are running in a kubernetes cluster. It checks for the presence of the KUBERNETES_SERVICE_HOST environment variable.

func Load

func Load() error

Load loads the configuration into memory. After it has been called once, calling it again will have no effect.

func Path added in v0.0.6

func Path() string

Path returns the configuration path value pointed to by EnvVar or DefaultPath.

func String added in v0.0.6

func String(n string) (string, error)

String calls Bytes(n) and converts the result to a string.

func Url added in v0.0.6

func Url(n string) (*url.URL, error)

Url calls url.Parse(String(n))

func Userinfo added in v0.0.6

func Userinfo(n string) (*url.Userinfo, error)

Userinfo parses configuration value n into a *url.Userinfo struct. It expects the input to be a json object with a username and an option password field.

{
	"username": "string",
	"password": "string"
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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