config

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: Apache-2.0 Imports: 11 Imported by: 2

README

config (v1.0.0)

GoDoc Build Status Coveralls

Installation:

go get -u github.com/bsdlp/config

Usage:

import "github.com/bsdlp/config"

Documentation

Overview

Package config version v1.0.0

Index

Constants

View Source
const (
	UserBase   string = "~/.config/"
	SystemBase string = "/etc/"
)

UserBase and SystemBase are the prefixes for the user and system config paths, respectively.

Variables

View Source
var (
	// ErrNilUnmarshaller is returned when an undefined unmarshaller is passed to
	// load()
	ErrNilUnmarshaller = errors.New("config: nil unmarshaller")

	// ErrNilFileFormat is returned when the config struct contains a nil FileFormat
	ErrNilFileFormat = errors.New("config: file format undefined")

	// ErrConfigFileNotFound is returned when config files at $HOME/:organization/:system/config.{extension}
	// or /etc/:organization/:systems/config.{extension} are missing
	ErrConfigFileNotFound = errors.New("config: missing config files")

	// ErrNotAPointer is returned when a non-pointer is passed into load
	ErrNotAPointer = errors.New("config: not a pointer")
)

Functions

func ExpandUser

func ExpandUser(path string) (exPath string)

ExpandUser acts kind of like os.path.expanduser in Python, except only supports expanding "~/" or "$HOME"

Types

type Config

type Config struct {
	// optional additional namespace for orgs.
	Organization string

	// Name of the service associated with this config.
	Service string

	// describes the type of config file to unmarshal
	FileFormat *FileFormat
	// contains filtered or unexported fields
}

Config implements Loader

func (Config) EnvVar

func (c Config) EnvVar() (envvar string)

EnvVar returns the name of the environment variable containing the URI of the config. Example: PODHUB_UUIDD_CONFIG_URI

func (Config) Load

func (c Config) Load(dst interface{}) (err error)

Load is a convenience function registered to config.Namespace to implement Config.Load().

func (Config) Path

func (c Config) Path() (path string)

Path returns path to config, chosen by hierarchy and checked for existence:

1. {ORGANIZATION}_{SERVICE}_CONFIG_URI environment variable

2. User config (~/.config/podhub/canary/config.{extension})

3. System config (/etc/podhub/canary/config.{extension})

type FileFormat

type FileFormat struct {
	// file extension, i.e. "yaml" for a file named "config.yaml"
	Extension string

	// Unmarshaller used to unmarshal config data
	Unmarshaller Unmarshaller
}

FileFormat is the type of config file to unmarshal

type Unmarshaller

type Unmarshaller func(data []byte, v interface{}) error

Unmarshaller defines the function signature for unmarshal functions

Directories

Path Synopsis
_vendor
github.com/go-ini/ini
Package ini provides INI file read and write functionality in Go.
Package ini provides INI file read and write functionality in Go.
github.com/hashicorp/hcl
Package hcl decodes HCL into usable Go structures.
Package hcl decodes HCL into usable Go structures.
github.com/hashicorp/hcl/hcl/ast
Package ast declares the types used to represent syntax trees for HCL (HashiCorp Configuration Language)
Package ast declares the types used to represent syntax trees for HCL (HashiCorp Configuration Language)
github.com/hashicorp/hcl/hcl/parser
Package parser implements a parser for HCL (HashiCorp Configuration Language)
Package parser implements a parser for HCL (HashiCorp Configuration Language)
github.com/hashicorp/hcl/hcl/scanner
Package scanner implements a scanner for HCL (HashiCorp Configuration Language) source text.
Package scanner implements a scanner for HCL (HashiCorp Configuration Language) source text.
github.com/hashicorp/hcl/hcl/token
Package token defines constants representing the lexical tokens for HCL (HashiCorp Configuration Language)
Package token defines constants representing the lexical tokens for HCL (HashiCorp Configuration Language)
github.com/onsi/ginkgo
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
github.com/onsi/ginkgo/config
Ginkgo accepts a number of configuration options.
Ginkgo accepts a number of configuration options.
github.com/onsi/ginkgo/internal/remote
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
github.com/onsi/ginkgo/reporters
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
github.com/onsi/gomega
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
github.com/onsi/gomega/format
Gomega's format package pretty-prints objects.
Gomega's format package pretty-prints objects.
github.com/onsi/gomega/matchers
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
ini

Jump to

Keyboard shortcuts

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