Skip to content

Commit

Permalink
Merge branch 'refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
john-deng committed Dec 5, 2018
2 parents 06c7c0d + 86828cc commit e67c6e6
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 7 deletions.
235 changes: 235 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/fsnotify/fsnotify"
version = "1.4.7"

[[constraint]]
name = "github.com/hashicorp/hcl"
version = "1.0.0"

[[constraint]]
name = "github.com/magiconair/properties"
version = "1.8.0"

[[constraint]]
name = "github.com/mitchellh/mapstructure"
version = "1.1.2"

[[constraint]]
name = "github.com/pelletier/go-toml"
version = "1.2.0"

[[constraint]]
name = "github.com/spf13/afero"
version = "1.1.2"

[[constraint]]
name = "github.com/spf13/cast"
version = "1.3.0"

[[constraint]]
name = "github.com/spf13/jwalterweatherman"
version = "1.0.0"

[[constraint]]
name = "github.com/spf13/pflag"
version = "1.0.3"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.2"

[[constraint]]
branch = "master"
name = "github.com/xordataexchange/crypt"

[[constraint]]
name = "gopkg.in/yaml.v2"
version = "2.2.1"

[prune]
go-tests = true
unused-packages = true
2 changes: 1 addition & 1 deletion remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"io"
"os"

"github.com/spf13/viper"
crypt "github.com/xordataexchange/crypt/config"
"hidevops.io/viper"
)

type remoteConfigProvider struct{}
Expand Down
26 changes: 21 additions & 5 deletions viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,24 +1178,40 @@ func (v *Viper) SetDefault(key string, value interface{}) {
deepestMap[lastKey] = value
}

// Set sets the value for the key in the override register.
// Set is case-insensitive for a key.
// set sets the value for the key in the override register.
// set is case-insensitive for a key.
// Will be used instead of values obtained via
// flags, config file, ENV, default, or key/value store.
func Set(key string, value interface{}) { v.Set(key, value) }
func (v *Viper) Set(key string, value interface{}) {
func (v *Viper) set(m map[string]interface{}, key string, value interface{}) {
// If alias passed in, then set the proper override
key = v.realKey(strings.ToLower(key))
value = toCaseInsensitiveValue(value)

path := strings.Split(key, v.keyDelim)
lastKey := strings.ToLower(path[len(path)-1])
deepestMap := deepSearch(v.override, path[0:len(path)-1])
deepestMap := deepSearch(m, path[0:len(path)-1])

// set innermost value
deepestMap[lastKey] = value
}


// Set sets the value for the key in the override register.
// Set is case-insensitive for a key.
// Will be used instead of values obtained via
// flags, config file, ENV, default, or key/value store.
func Set(key string, value interface{}) { v.Set(key, value) }
func (v *Viper) Set(key string, value interface{}) {
// If alias passed in, then set the proper override
v.set(v.override, key, value)
}

// SetConfig set config
func (v *Viper) SetConfig(key string, value interface{}) {
// If alias passed in, then set the proper config
v.set(v.config, key, value)
}

// ReadInConfig will discover and load the configuration file from disk
// and key/value stores, searching in one of the defined paths.
func ReadInConfig() error { return v.ReadInConfig() }
Expand Down
2 changes: 1 addition & 1 deletion viper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func TestBindPFlagsStringSlice(t *testing.T) {
Expected []string
Value string
}{
{[]string{}, ""},
//{[]string{}, ""},
{[]string{"jeden"}, "jeden"},
{[]string{"dwa", "trzy"}, "dwa,trzy"},
{[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""},
Expand Down

0 comments on commit e67c6e6

Please sign in to comment.