Commit graph

683 commits

Author SHA1 Message Date
javaducky
3a19b6e0d9 Review updates to utilize afero for file checks and updated checks on unit tests 2019-12-06 08:36:52 +01:00
javaducky
a708479794 Updating SafeWriteConfig and SafeWriteConfigAs to match documented behavior.
Methods should throw an error if the config file already exists or if no configpath is configured when not explicitly requesting a write path.
2019-12-06 08:36:52 +01:00
Benoit Masson
9e353e395e find() looks for flag's default values only when requested.
Default value should be looked for by Get(), but not by IsSet().

This logic should remain inside find(), to make sure that shadowing
of keys is handled properly.

Fixes Issue #276.
2019-11-29 21:16:13 +01:00
Benoit Masson
4e1ebbdaba Added tests to TestIsSet()
Added tests for:
- nested elements
- environment values
- flags (currently fails => IsSet() always returns true,
                            due to the default value of the flag)
2019-11-29 21:16:13 +01:00
Kévin Dunglas
01d7d76eb0 Add Mercure in the list of projects using Viper 2019-11-08 13:18:39 +01:00
Pedro Silva
d1c60d9e69 Support config files with no extensions (#722)
* Support config files with no extensions

* Update README informing config files without extension are supported
2019-11-06 14:54:13 +01:00
Vivek V
72b022eb35 Added capacity to slice creation 2019-11-01 11:15:09 +01:00
Navid Shaikh
40e41dd224 Updates YAML to v2.2.4
Make sure we're not vulnerable to CVE-2019-11253.
See https://github.com/kubernetes/kubernetes/issues/83253
2019-10-16 10:29:20 +02:00
Mark Sagi-Kazar
71509d2887 Revert the effective changes of #673 2019-09-28 12:02:57 +02:00
Mark Sagi-Kazar
398adc5a7d Add breaking test that requires reverting #673 2019-09-28 12:02:57 +02:00
Mark Sagi-Kazar
371f39c3ab Add Go 1.13 to travis 2019-09-27 23:35:02 +02:00
Mark Sagi-Kazar
c171232d3a Add go version to the mod file 2019-09-27 23:35:02 +02:00
Lars Lehtonen
583f79b3ea remote: fix two dropped errors 2019-09-27 21:42:20 +02:00
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