Commit Graph

612 Commits

Author SHA1 Message Date
Mark Sagi-Kazar 16fb4b9d29
Add editorconfig 2020-01-16 19:37:42 +01:00
Mark Sagi-Kazar 4525543ce4
Improve CI 2020-01-16 19:27:10 +01:00
Pedro Silva 9cd571279d Extensionless files only allowed when config type is set (#827)
* Only consider files without extension if the config type is explicitly specified

* Hides unused variable in test

* First check for config type then for file without extension
2020-01-16 19:23:50 +01:00
Mark Sagi-Kazar 06ab5a4b62 Add documentation about unmarshaling into embedded structs 2020-01-08 10:58:26 +01:00
Mark Sagi-Kazar eabbc68a3e Fix file path lookup 2019-12-06 17:29:42 +01:00
Mark Sagi-Kazar 5ad4bc05cf Add decoder opts to unmarshal exact 2019-12-06 14:27:22 +01:00
Gregory Haynes bcb420b705 Add global UnmarshalExact method
There is no helper method for UnmarshalExact which calls the
corresponding method on the global viper instance.
2019-12-06 14:15:02 +01:00
Mark Sagi-Kazar 4ad4c8df70 Add string replacer interface and env key replacer option 2019-12-06 14:13:46 +01:00
Mark Sagi-Kazar 6fcf985c5a Fix readme 2019-12-06 14:01:42 +01:00
Mark Sagi-Kazar bdf2db0ff8 Fix goimports 2019-12-06 14:01:42 +01:00
Mark Sagi-Kazar a842b8f618 Replace SetKeyDelimiter with functional options 2019-12-06 14:01:42 +01:00
Mark Sagi-Kazar 9a405be5c0 Add SetKeyDelimiter to the README 2019-12-06 14:01:42 +01:00
Mark Sagi-Kazar a73303ee89 Add key delimiter setter 2019-12-06 14:01:42 +01:00
Mark Sagi-Kazar b6ced70067 Generic improvements 2019-12-06 14:01:30 +01:00
Mark Sagi-Kazar 52836e66ad Improve badges 2019-12-06 14:01:30 +01:00
Mark Sagi-Kazar 6895c083d6 INI is supported 2019-12-06 14:01:30 +01:00
Mark Sagi-Kazar c4fedd192b Fix check target 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar 2fd264d3d1 Fix misspell 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar 8b7fbcaa4b Fix golint 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar 29bb3ee94f Fix deadcode 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar 7b5adba788 Fix whitespace 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar cea8b9dfcd Fix goimports 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar e316012b4d Fix gofmt 2019-12-06 13:00:52 +01:00
Mark Sagi-Kazar 78a0e37a24 Add github actions workflow 2019-12-06 12:35:47 +01:00
Mark Sagi-Kazar fae3a81867 Add ide integration 2019-12-06 12:10:03 +01:00
Mark Sagi-Kazar d52c544291 Add Makefile 2019-12-06 12:10:03 +01:00
Mark Sagi-Kazar abdeaff171 Add golangci config 2019-12-06 12:10:03 +01:00
Mark Sagi-Kazar 8feab54f0e Tidy dependencies 2019-12-06 11:22:37 +01:00
Matti R 351bfe9719 loop through ini sections
pass tests

write out ini file & tests

go fmt

Update viper_test.go
fix test

gofmt
2019-12-06 09:02:54 +01:00
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