Commit Graph

670 Commits

Author SHA1 Message Date
inkychris 99520c81d8 Implemented ability to unmarshal keys containing dots to structs.
Changed formatting of test objects for better git diffing and readibility.
Fixed failing tests on Windows.
2019-09-11 16:03:08 +02:00
Mark Sagi-Kazar bd1db6bb8c Run go mod tidy 2019-08-29 15:42:25 +02:00
TwiN e697d557b7 Fix small typo 2019-08-17 00:18:41 +02:00
Christian Muehlhaeuser 33bf76add3 Simplify code
Removed unnecessary conversions.
2019-07-29 18:37:00 +02:00
Christian Muehlhaeuser 1b33e8258e Add error handling
Added error handling around ineffectual err assignments. Please review
thoroughly.
2019-07-28 14:50:13 +02:00
Christian Muehlhaeuser d65fa7608b Fixed typo
Just a nitpicky typo fix.
2019-07-28 14:47:04 +02:00
Rodrigo Chiossi cdccc8152c Fix SafeWriteConfig
If the config file does not exist and the force flag is not set,
OpenFile would not use O_CREATE flag, causing viper to fail with
error "File not exist" and to not create the config file.
This patch changes the behavior of writeConfig() so that if force is set
to false, OpenFile will use O_EXCL flag, thus failing if the file
already exists or creating a new file otherwise.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-07-28 12:33:29 +02:00
bpizzi e02bc9eca5 Fixed missing f.Close() in writeConfig()
Defering can cause trouble because we're writing to the file outside the function
where the defering is registered, calling f.Sync() ensures that bytes are flushed
to disk even is Close() is called too soon.
2019-07-13 12:28:02 +02:00
Nicolas Martin e325492b82 Add missing call to initWF.Done() 2019-07-13 12:13:30 +02:00
Márk Sági-Kazár e6d1c6bc9a Improve godoc 2019-07-13 12:11:16 +02:00
CodeLingo Bot 275a36d0a0 Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-07-13 12:11:16 +02:00
Márk Sági-Kazár 7fdad0204e Fix typo 2019-07-13 12:04:36 +02:00
AGirard b8221cf4ee Add GetIntSlice helper method 2019-07-13 12:04:36 +02:00
Márk Sági-Kazár 72cbe340cb Improve travis 2019-07-13 11:53:30 +02:00
lucperkins 5ae3a072d1 Add documentation for no config file found
Signed-off-by: lucperkins <lucperkins@gmail.com>
2019-07-13 11:37:02 +02:00
Márk Sági-Kazár d34be8d9ee Improve BindEnv details 2019-07-13 11:35:03 +02:00
Bruce Wang 96441b4b74 BindEnv details specified. Now less confusion. 2019-07-13 11:35:03 +02:00
victor23d 2b4f7d3cde Add dotenv documentation in README.md 2019-07-13 11:28:35 +02:00
Márk Sági-Kazár 3349bd9cc2 Improve Unmarshal docs (#713)
Closes #589
Closes  #588
2019-06-14 11:17:12 -04:00
okazu-dm 3b4aca7571 Fix example code
Unmarshal -> viper.Unmarshal
2019-06-13 10:51:37 +02:00
liubog2008 b235f72abb fix(leak): fix leak in dependency magiconair/properities 2019-06-11 23:33:57 +02:00
Alpha fde59dd3e4 ADD: installation method (#604)
* ADD: installation method

* Update README.md
2019-06-11 16:58:53 -04:00
Pawan Rawal 0c777cfac1 Fix indentation for yamlStringSettings (#651)
The indentation seemed messed up and didn't read well. This change fixes it.
2019-06-11 16:53:59 -04:00
Márk Sági-Kazár ad5ed02fa4 Add support for int slice flags (#637)
* Add support for int slice flags

* Add int slice test to unmarshal
2019-06-11 16:51:57 -04:00
EmilLuta 0da4d41b2d Add WriteConfig documentation (#649) 2019-06-11 16:51:04 -04:00
0xflotus a52795991d fixed marshal (#647) 2019-06-11 16:50:29 -04:00
Leonardo Fedalto 33688bf23c Fix typo on README.md (#710) 2019-06-11 16:48:19 -04:00
mexisme 3620d3d9e1 Support `.env` format files (#528)
* 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 #658
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 #704
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 (#681)
* 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 #482
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 #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