Commit Graph

293 Commits

Author SHA1 Message Date
mexisme 3620d3d9e1 Support `.env` format files ()
* Support `.env` format files

* Missing "dotenv" from SupportedExtns
2019-06-11 16:47:43 -04:00
Jean de Klerk b5bf975e58 Clean up dependencies
This commit was created by manually removing github.com/ugorji/go/codec from
the go.mod (which now does not exist - see https://github.com/ugorji/go/issues/299)
and running `go mod tidy`.

Closes 
2019-05-24 21:57:43 +02:00
Anthony Fok 2bd2732789
Use GetInt64 for largenum in viper_test.go
to prevent overflow error on 32-bit platforms.

Fixes 
2019-05-24 11:53:49 -06:00
Anthony Fok 93066f92c6
Fix typo in viper_test.go: lagrenum → largenum 2019-05-24 07:40:12 -06:00
Mitch Connors 7a605a50e6 Uint Support ()
* add GetUint/GetUint32/GetUint64

* Add Get(string) support for uint.
2019-04-08 10:06:45 -04:00
Kris fccfc2c271 Add API for setting file permissions 2019-04-04 14:02:01 +02:00
Bjørn Erik Pedersen 9e56dacc08 Remove superflous insensitiviseMaps in Unmarshal methods
Fixes 
2019-03-13 10:29:51 +01:00
Mark Sagi-Kazar d104d259b3 Update go.sum with go1.11.4
In Go 1.11.4 a bug was fixed related to checksum calculation.
As a result, some packages might end up with a different checksum
from this version. The solution is upgrading, cleaning the mod cache
and recalculating the go.sum file.

See https://github.com/golang/go/issues/27093
2019-01-27 10:44:59 +01:00
Bjørn Erik Pedersen 6d33b5a963
Make the map in MergeConfigMap case insensitive 2018-12-07 11:03:36 +01:00
Bjørn Erik Pedersen 41cd1c3aa3 Restrict Travis to >= Go 1.11, use Go Modules, and get the test to pass 2018-12-05 17:13:47 +01:00
Bjørn Erik Pedersen 3535c75fa8 Add MergeConfigMap
Fixes 
2018-12-05 17:13:47 +01:00
Bjørn Erik Pedersen 06c7c0d9b3
Use assert.EqualValues for slice checking 2018-11-19 10:38:40 +01:00
Benoit Masson ae103d7e59 Moved shared resources out of the loops in TestBindPFlagsStringSlice()
Common code and resources put out of the loops, to improve
efficiency and readability.
2018-11-07 12:08:59 +01:00
Benoit Masson 69647fb422 Fixed TestBindPFlagsStringSlice()
Replaced Visit() by VisitAll(), so that the Changed attribute of
the updated flag is correctly set.
2018-11-07 12:08:59 +01:00
Benoit Masson cc7e906d88 Updated TestBindPFlagsStringSlice() to highlight a failure
When pflag marked as changed, the value is not detected
(and lower priority value used)
2018-11-07 12:08:59 +01:00
Márk Sági-Kazár b7a3b95476 Lookup environment variables instead of checking if the value is empty
This commit adds an `AllowEmptyEnv` option that, default off, that when set will allow set, but empty, environment variables

Fixes 
2018-11-06 22:53:21 +01:00
Andrew Stuart 62edee3196
Revert "Cater for case-sensitive dependencies ()"
This reverts commit b56071875a.
2018-09-29 21:41:27 -07:00
Panagiotis Moustafellos b56071875a Cater for case-sensitive dependencies ()
Switching jww from jwalterweatherman to jWalterWeatherman for cases when vgo is broken
2018-09-29 20:32:38 -07:00
Andrew Stuart 8e194e8ad2
Merge branch 'master' into mergefix/Issue284_Kubernetes_config 2018-09-28 01:05:04 -07:00
Andrew Stuart 0d783e7344
Use test log 2018-09-28 01:04:19 -07:00
Andrew Stuart 2c12c60302
Fix nil pointer on watch function () 2018-09-28 00:53:21 -07:00
Bjørn Erik Pedersen 3171ef9a22
Revert "Add go.sum to .gitignore"
This reverts commit 841bd4ebcd.
2018-09-07 15:06:02 +02:00
Bjørn Erik Pedersen 841bd4ebcd
Add go.sum to .gitignore
Seems that it's better practice to keep that in Git for "main modules".
2018-09-07 11:52:15 +02:00
Bjørn Erik Pedersen 8fb6420065
Add go.mod 2018-09-07 11:30:55 +02:00
Dr. Tobias Quathamer 0ac2068de9 Fix overflow error on 32 bit architectures ()
* Handle int64 separately for 32 bit architectures

* Remove tests which result in an overflow error on 32 bit architectures
2018-09-01 14:59:01 -06:00
Adhatama 8addaed22d Add README.md for Consul remote provider () 2018-08-28 16:05:06 -06:00
Aarti Parikh 05116ad639 Revert "fix dep wrong case ()"
This reverts commit b7a62b2c00.
2018-08-28 02:34:36 -06:00
kun b7a62b2c00 fix dep wrong case () 2018-08-28 01:37:55 -06:00
Robin Brämer e436d04e6d correct a comment on viper.Set() ()
correct regiser with register
2018-08-28 01:29:26 -06:00
Michael 40b1bbb9a8 travis: update go versions () 2018-08-28 01:08:14 -06:00
Xavier Coulon 41f829b2c9 refactor test to avoid negative counter on WG
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
2018-08-06 09:29:13 +02:00
Xavier Coulon e12d3d32d1 Merge branch 'master' into Issue284_Kubernetes_config 2018-08-06 08:18:53 +02:00
Chris Reeves 907c19d40d Support customising mapstructure.DecoderConfig for Unmarshal
* Added a new `DecoderConfigOption` type allowing the user to write custom
  functions that can override the default mapstructure.DecoderConfig
  settings

* Added a new `DecodeHook` function which returns
  a `DecoderConfigOption`. This allows the user to easily set their own
  Decode hooks when Unmarshaling

* Updated Unmarshal, UnmarshalKey and defaultDecoderConfig to support variadic
  trailing `DecoderConfigOption` functions to allow for customisation of
  the default  mapstructure.DecoderConfig

* Added a test case with example usage
2018-08-03 14:57:45 +02:00
Xavier Coulon c1250e5dd7 apply review comments
use masks for checking the events.

Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
2018-07-13 10:30:23 +02:00
Adriano d493c32b69 Update README.md ()
Fix typo in the environment variable usage documentation.
2018-07-10 13:30:20 +01:00
Brice Fernandes fb7a06477f
Add example of marshalling to string () 2018-07-10 12:30:24 +01:00
Xavier Coulon 242f4890f5 Refactor with WaitGroup and check channel is open
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
2018-05-24 10:09:29 +02:00
Travis Jeffery 15738813a0 Add GetInt32 2018-05-07 09:10:07 +02:00
Michael Käufl 8dc2790b02 travis: update go versions 2018-04-04 20:33:25 +02:00
Bjørn Erik Pedersen b5e8006cbe
Undexport GetConfigFile
It was exported in previous commit, but we have GetConfigFileUsed -- so use that.
2018-03-19 19:50:19 +01:00
Bjørn Erik Pedersen 00ed41cdba
Export and fix GetConfigFile 2018-03-19 19:12:24 +01:00
Xavier Coulon e0f7631cf3 WatchConfig and Kubernetes ()
Support override of symlink to config file
Include tests for WatchConfig of regular files, as well
as config file which links to a folder which is itself a
link to another folder in the same "watch dir" (the way
Kubernetes exposes config files from ConfigMaps mounted
on a volume in a Pod)

Also:
- Add synchronization with WaitGroup to ensure that the WatchConfig
is properly started before returning
- Remove the watcher when the Config file is removed.

Fixes 

Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
2018-01-03 10:37:18 +01:00
Davor Kapsa aafc9e6bc7 travis: update go versions 2017-12-27 20:41:43 +01:00
Adam Sherwood 1a0c4a370c Feature/write config ()
* Added method to write into TOML file.

* Added functionality to export configuration based on config type. The feature supports JSON and TOML.

* Added method to write into YAML file.

* Fixed the issue of incorrect defer and error checking order. The error checking must be first otherwise it will cause panic.

* Add WriteConfig methods

* Add support for toml

* Add shared write function and safe methods

* Fix incorrectly modified imports

* Remove extra comments

* Fix spelling

* Make marshal spelling consistent throughout

* Add support for remaining configuration types

This commit moves a significant portion of the code back to viper.go to
facilitate having access to the object when reading the files. The purpose is to
add properties to the viper object at read time, so that we can add the comments
back to the file when writing.

* Add tests for each written file type

* Modify test for updated HCL specification

* Modify to only support HCL write in Go 1.7

* Revert "Modify to only support HCL write in Go 1.7"

This reverts commit 12b34bc4eb92cbf8ebfd56b79519f448607e3e51.

* Need to truncate the file before writing

* Write all settings including overrides

* Use filename variable

* Lint remote.go

* Fix toml return count error
2017-12-06 23:26:31 -05:00
Jeff Lindsay 4dddf7c62e Allow exists util function to take afero.Fs so it can be used with non-deafult instances of Viper ()
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-11-09 21:57:16 +01:00
Kamil Wargula 8ef37cbca7 Fix incorrect name of function in README.md
Change `SetEnvReplacer` to `SetEnvKeyReplacer`
2017-10-20 12:40:09 +02:00
Bjørn Erik Pedersen d9cca5ef33 Go fmt viper.go 2017-09-29 23:06:42 +02:00
Alexander Krasnukhin 266e588e9e Add string slice support to defaultDecoderConfig
This way it correctly decodes string slices as well.
2017-09-29 21:44:38 +02:00
JG² 25b30aa063 Add Clairctl as a Go project that uses Viper
See 
2017-07-22 23:52:07 -06:00
Nick Miyake 8ac2e2e20f Run gofmt on all existing code
Also:

* Add check to .travis.yml that verifies that all code is gofmt-compliant
* Touch up some newlines

See 
2017-07-22 23:47:47 -06:00