Commit graph

298 commits

Author SHA1 Message Date
Albert Vaca
73fad7c9db Enable storing a set of known valid config keys
This can be used to enforce a config schema
2019-03-29 19:08:07 +01:00
Albert Vaca
991b92b30e
Merge pull request #5 from DataDog/albertvaka/warn-duplicate-keys-no-rebased
Warn when a yaml file has duplicated keys
2019-03-29 18:05:23 +01:00
Albert Vaca
42a499d7ac Warn when a yaml file has duplicated keys
Try using `UnmarshalStrict`, if it fails, print the errors as a warning and try again with plain `Unmarshal`.

Errors look this way:
```
2019/03/26 15:11:33 warning reading config file: yaml: unmarshal errors:
  line 6: key "api_key" already set in map
```
2019-03-29 15:13:52 +01:00
Albert Vaca
10edc96e10
Merge pull request #6 from spf13/master
Merge changes from original repo
2019-03-29 15:12:04 +01:00
Bjørn Erik Pedersen
9e56dacc08 Remove superflous insensitiviseMaps in Unmarshal methods
Fixes #482
2019-03-13 10:29:51 +01:00
Xavier Lucas
59d5cbf4d7
Allow using error getters without disabling type inference (#4) 2019-03-05 13:27:36 +01:00
Xavier Lucas
eadb687b05
Merge pull request #3 from DataDog/xavier.lucas/get-with-errors
Expose type casting errors
2019-03-01 16:47:21 +01:00
Xavier Lucas
07a0f11324
Expose type casting errors 2019-02-26 15:07:04 +01:00
Olivier Vielpeau
23ced3bc6b
Merge pull request #2 from olivielpeau/allow-keydelim-mapkey
Fix AllSettings when some map keys contain the key delimiter
2019-02-14 18:26:07 +01:00
Olivier Vielpeau
e89dd07ee4 Fix AllSettings when some map keys contain the key delimiter 2019-02-14 14:08:51 +01:00
maxime mouial
e9c8d7a439
Merge pull request #1 from DataDog/maxime/merge-override
Adding a method to merge config in the override section
2019-02-13 10:36:55 -07:00
Maxime Mouial
e8d119fbb0 Adding a method to merge config in the override section
This allows users to set configuration that would have precedence on env
variable. This is very useful when some post-processing is done on the
configuration.
2019-02-12 14:20:58 -07: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 #605
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 #317
2018-11-06 22:53:21 +01:00
Andrew Stuart
62edee3196
Revert "Cater for case-sensitive dependencies (#463)"
This reverts commit b56071875a.
2018-09-29 21:41:27 -07:00
Panagiotis Moustafellos
b56071875a Cater for case-sensitive dependencies (#463)
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 (#568) 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 (#340)
* 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 (#489) 2018-08-28 16:05:06 -06:00
Aarti Parikh
05116ad639 Revert "fix dep wrong case (#484)"
This reverts commit b7a62b2c00.
2018-08-28 02:34:36 -06:00
kun
b7a62b2c00 fix dep wrong case (#484) 2018-08-28 01:37:55 -06:00
Robin Brämer
e436d04e6d correct a comment on viper.Set() (#553)
correct regiser with register
2018-08-28 01:29:26 -06:00
Michael
40b1bbb9a8 travis: update go versions (#558) 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 (#470)
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 (#531) 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 (#284)
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 #284

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 (#287)
* 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 (#405)
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
2017-11-09 21:57:16 +01:00