aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/viper
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/viper')
-rw-r--r--vendor/github.com/spf13/viper/README.md2
-rw-r--r--vendor/github.com/spf13/viper/util.go11
-rw-r--r--vendor/github.com/spf13/viper/viper.go32
3 files changed, 36 insertions, 9 deletions
diff --git a/vendor/github.com/spf13/viper/README.md b/vendor/github.com/spf13/viper/README.md
index cad242d..4ebd8dd 100644
--- a/vendor/github.com/spf13/viper/README.md
+++ b/vendor/github.com/spf13/viper/README.md
@@ -10,7 +10,7 @@ Many Go projects are built using Viper including:
* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
* [Docker Notary](https://github.com/docker/Notary)
* [BloomApi](https://www.bloomapi.com/)
-* [DOIt](https://github.com/bryanl/doit)
+* [doctl(https://github.com/digitalocean/doctl)
[![Build Status](https://travis-ci.org/spf13/viper.svg)](https://travis-ci.org/spf13/viper) [![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
diff --git a/vendor/github.com/spf13/viper/util.go b/vendor/github.com/spf13/viper/util.go
index 0cc4553..fe6cb45 100644
--- a/vendor/github.com/spf13/viper/util.go
+++ b/vendor/github.com/spf13/viper/util.go
@@ -21,9 +21,9 @@ import (
"strings"
"unicode"
- "github.com/BurntSushi/toml"
"github.com/hashicorp/hcl"
"github.com/magiconair/properties"
+ toml "github.com/pelletier/go-toml"
"github.com/spf13/cast"
jww "github.com/spf13/jwalterweatherman"
"gopkg.in/yaml.v2"
@@ -77,7 +77,7 @@ func absPathify(inPath string) string {
// Check if File / Directory Exists
func exists(path string) (bool, error) {
- _, err := os.Stat(path)
+ _, err := v.fs.Stat(path)
if err == nil {
return true, nil
}
@@ -155,9 +155,14 @@ func unmarshallConfigReader(in io.Reader, c map[string]interface{}, configType s
}
case "toml":
- if _, err := toml.Decode(buf.String(), &c); err != nil {
+ tree, err := toml.LoadReader(buf)
+ if err != nil {
return ConfigParseError{err}
}
+ tmap := tree.ToMap()
+ for k, v := range tmap {
+ c[k] = v
+ }
case "properties", "props", "prop":
var p *properties.Properties
diff --git a/vendor/github.com/spf13/viper/viper.go b/vendor/github.com/spf13/viper/viper.go
index a2633b0..f17790e 100644
--- a/vendor/github.com/spf13/viper/viper.go
+++ b/vendor/github.com/spf13/viper/viper.go
@@ -23,7 +23,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"log"
"os"
"path/filepath"
@@ -33,6 +32,7 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/mitchellh/mapstructure"
+ "github.com/spf13/afero"
"github.com/spf13/cast"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/pflag"
@@ -132,6 +132,9 @@ type Viper struct {
// A set of paths to look for the config file in
configPaths []string
+ // The filesystem to read config from.
+ fs afero.Fs
+
// A set of remote providers to search for the configuration
remoteProviders []*defaultRemoteProvider
@@ -161,6 +164,7 @@ func New() *Viper {
v := new(Viper)
v.keyDelim = "."
v.configName = "config"
+ v.fs = afero.NewOsFs()
v.config = make(map[string]interface{})
v.override = make(map[string]interface{})
v.defaults = make(map[string]interface{})
@@ -446,6 +450,11 @@ func (v *Viper) SetTypeByDefaultValue(enable bool) {
v.typeByDefValue = enable
}
+// GetViper gets the global Viper instance.
+func GetViper() *Viper {
+ return v
+}
+
// Viper is essentially repository for configurations
// Get can retrieve any value given the key to use
// Get has the behavior of returning the value associated with the first
@@ -551,6 +560,12 @@ func (v *Viper) GetInt(key string) int {
return cast.ToInt(v.Get(key))
}
+// Returns the value associated with the key as an integer
+func GetInt64(key string) int64 { return v.GetInt64(key) }
+func (v *Viper) GetInt64(key string) int64 {
+ return cast.ToInt64(v.Get(key))
+}
+
// Returns the value associated with the key as a float64
func GetFloat64(key string) float64 { return v.GetFloat64(key) }
func (v *Viper) GetFloat64(key string) float64 {
@@ -660,8 +675,8 @@ func (v *Viper) BindPFlags(flags *pflag.FlagSet) (err error) {
return v.BindFlagValues(pflagValueSet{flags})
}
-// Bind a specific key to a pflag (as used by cobra)
-// Example(where serverCmd is a Cobra instance):
+// Bind a specific key to a pflag (as used by cobra).
+// Example (where serverCmd is a Cobra instance):
//
// serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
// Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
@@ -930,7 +945,7 @@ func (v *Viper) ReadInConfig() error {
return UnsupportedConfigError(v.getConfigType())
}
- file, err := ioutil.ReadFile(v.getConfigFile())
+ file, err := afero.ReadFile(v.fs, v.getConfigFile())
if err != nil {
return err
}
@@ -948,7 +963,7 @@ func (v *Viper) MergeInConfig() error {
return UnsupportedConfigError(v.getConfigType())
}
- file, err := ioutil.ReadFile(v.getConfigFile())
+ file, err := afero.ReadFile(v.fs, v.getConfigFile())
if err != nil {
return err
}
@@ -1202,12 +1217,19 @@ func (v *Viper) AllSettings() map[string]interface{} {
return m
}
+// Se the filesystem to use to read configuration.
+func SetFs(fs afero.Fs) { v.SetFs(fs) }
+func (v *Viper) SetFs(fs afero.Fs) {
+ v.fs = fs
+}
+
// Name for the config file.
// Does not include extension.
func SetConfigName(in string) { v.SetConfigName(in) }
func (v *Viper) SetConfigName(in string) {
if in != "" {
v.configName = in
+ v.configFile = ""
}
}