Commit Graph

244 Commits

Author SHA1 Message Date
Mark Sagi-Kazar 464cdab72a refactor: drop fsonitfy wrapper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-11-30 00:24:02 +07:00
Ville Skyttä f62f86a84b refactor: make use of `strings.Cut` 2023-10-06 14:22:22 +02:00
Oleksandr Redko 3d006fe361 refactor: replace interface{} with any 2023-10-01 17:04:26 +02:00
Mark Sagi-Kazar d16deb4b93 feat: add slog support
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-09-13 16:24:59 +02:00
John Hooks 1e811d1f02 Add NATS support 2023-09-08 15:32:50 +02:00
guangwu cb9b2bffc2
fix: code optimization (#1557)
* fix: code optimization

* fix: golangci-lint
2023-07-27 20:56:32 +02:00
Baruch Odem 731a91be43 feat: add func GetEnvPrefix 2023-06-29 05:37:45 +02:00
Márk Sági-Kazár 53cdb5253a chore: improve log messages 2023-05-29 15:43:38 +02:00
Quentin Burgess 24ece16a9a drop std' logger in favor of jww one 2023-05-29 15:43:38 +02:00
Quentin Burgess 98b1b9fd42 add:viper: allow to disable internal log messages 2023-05-29 15:43:38 +02:00
VOrishirne 2ee16310d0 extend viper's pflag binding to stringToInt pflag 2023-05-29 15:34:52 +02:00
Márk Sági-Kazár 34d6318c0b chore: fix typo 2023-03-31 13:08:16 +02:00
Yoofi Quansah c6ba8f4702 fix: fix typo 2023-03-31 13:08:16 +02:00
TaylorOno 3970ad177e Preserve envPrefix in Sub 2023-02-25 22:17:36 +01:00
TaylorOno 3f4449054d Sub inerits from automaticEnvApplied and envKeyReplacer
parents are tracked so sub(x).sub(y).GetString(z) looks up x.y.z
2023-02-25 22:17:36 +01:00
Dawid Urbański c898f59d33
fix: time.Duration slice type conversion (#1498)
* fix DurationSlice

* Fix typo

---------

Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
2023-02-05 18:30:05 +01:00
glebik000 5182412574
Add DocBlock to WatchConfig (#1467)
* Add DocBlock to WatchConfig

Added a small description of the WatchConfig().
So that you can understand in the ide why you could use it.

* Update viper.go

* update viper.go

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com>
Co-authored-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2023-01-19 16:38:18 +01:00
Mark Sagi-Kazar 4b8d14881e refactor: use new Has fsnotify method for event matching
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-11-04 05:39:26 +01:00
Brad P. Crochet 312417a0c5 Add a DebugTo convenience funtion
One might want to write the debug information somewhere other than
Stdout. This patch adss a DebugTo function and method, that accepts
an io.Writer. It changes the original Debug implementation to call
this new function with a default of os.Stdout, which maintains
backward compatibility.

Signed-off-by: Brad P. Crochet <brad@redhat.com>
2022-09-06 11:14:22 +02:00
Christian Banse 202060b3a2 Adds support for uint16 with `GetUint16`
We have encountered numerous places where it is convenient to have viper return a `uint16` value, especially in combination with the new `netip` package  that represents a port correctly as `uint16` rather than just an `int`. cobra already supports this, but we need a conversion from the existing `GetUint` method in viper.
2022-09-04 03:07:23 +02:00
Mark Sagi-Kazar 97591f0083 build: fix lint violations
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-09-03 19:07:15 +02:00
Kevin Franklin Kim 98c63ede11 feat: check providers and log error 2022-07-10 13:48:18 +02:00
Kevin Franklin Kim 1bc0a5ac7a add etcd3 to supported providers 2022-07-10 13:48:18 +02:00
Wade Carpenter da55858fff chore: fix Error log calls in mergeMaps
The logger interface uses k,v pairs, but it was being called with a
format string, here.

Changed to use k,v pairs.

I didn't find any other instances of this problem.
2022-05-26 16:01:47 +02:00
Michael Wilson f50ce904a9 Add in MustBindEnv.
Adds in a MustBindEnv function which will panic if BindEnv fails.
2022-05-26 15:53:50 +02:00
Mark Sagi-Kazar 55fac1047e chore: fix lint
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2022-04-13 13:22:15 +02:00
Illarion Kovalchuk 97664ba020 Added test case for merging configs, where target is null, and source is not null 2022-01-11 22:36:46 +01:00
illarion Kovalchuk 0353c6ea50 Allow merging configs with different types of leaf values 2022-01-11 22:36:46 +01:00
Mark Sagi-Kazar 04d3a0cb02 feat(encoding): integrate dotenv codec into Viper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-12-15 22:31:11 +01:00
Mark Sagi-Kazar 72453f720e feat(encoding): integrate Java properties codec into Viper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-12-15 22:31:11 +01:00
Mark Sagi-Kazar 430936044e feat(encoding): integrate ini codec into Viper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-12-15 22:31:11 +01:00
Mark Sagi-Kazar dd62da434f refactor(encoding): initialize codecs per Viper
Some codecs might have options that rely on Viper in the future
(eg. key delimiter) which requires initializing codecs
for each Viper instance.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-12-15 22:31:11 +01:00
Mark Sagi-Kazar e54e7a53a5 feat(encoding)!: accept a map in the decoder interface
This interface is specific to decoding data into Viper's internal,
so it's okay to make it Viper specific.

BREAKING CHANGE: the decoder interface now accepts a map instead of an
interface

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-12-15 22:31:11 +01:00
Stephen Wodecki 6c1745665b unnecessary operand 2021-12-15 22:26:56 +01:00
Mark Sagi-Kazar a785a79f22 refactor: replace jww with the new logger interface 2021-12-09 18:58:22 +01:00
Mark Sagi-Kazar 41ec2aaf27 chore: run lint fixer
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-11-21 14:51:34 +01:00
Mark Sagi-Kazar 4e595cec77 feat: use io/fs for searching files on Go 1.16+
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-09-21 18:01:05 +02:00
Jim Razmus II b1fdc47b0d Recognize tfvars files as hcl by default.
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-09-19 23:25:03 +02:00
Séra Zoltán fa3412d7ea fix cannot write hidden file without extension (#1017) 2021-09-19 09:28:14 +02:00
Vasily Ovchinnikov e606f7496e fix: made `InConfig` process paths correctly 2021-09-16 10:32:19 +02:00
Mark Sagi-Kazar a02f9864fa feat(encoding): Integrate the new encoding package into Viper
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-06-25 14:26:08 +02:00
Mikhail f. Shiryaev bd03865899 Add a proper processing for pflag.StringArray 2021-06-25 13:55:36 +02:00
Carlos Henrique Guardão Gandarez acd965b54e Add ini load options argument
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-06-16 01:55:16 +02:00
Carolyn Van Slyck cdb5e5976f Fix merging a key into a nil target
When merging a key where the target value is nil, the type of the target
and source do not match. What currently happens is an error is logged
and the key is skipped.

I have changed it so that it does the same thing as when the target key
is missing: copy the source value to the target.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
2021-05-17 08:55:31 +02:00
Mark Sagi-Kazar 36be6bf91f feat: make sure Viper compiles on WASM
fsnotify is not available on WASM,
so config watching is not going to work.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2021-04-24 10:24:23 +02:00
Chris Waldon 727a41c38a doc: add a note about concurent Get/Set to godoc 2021-04-15 18:20:20 +02:00
r-stepanenko fb4eafdd97
fix INI saving panics (#1075) 2021-03-10 14:46:19 +01:00
Mark Sagi-Kazar 8c89438499
docs: improve AutomaticEnv documentation
Fixes #1000

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2020-10-08 02:46:11 +02:00
dylandreimerink 33bcdc91ea
Added support for accessing slices (#861)
* Added support for accessing slices

* Processed PR feedback
- renamed searchMapWithPathPrefixes to searchIndexableWithPathPrefixes
- moved source type specific search logic to speparate functions
- Inverted if statments to avoid the arrow pattern

* Quickly return from searchSliceWithPathPrefixes and searchMapWithPathPrefixes functions without intermediate variables
2020-10-04 20:07:34 +02:00
Gabriel Aszalos ea890285a5 Update docs 2020-09-30 12:44:21 +02:00