Commit graph

260 commits

Author SHA1 Message Date
Albert
16990631d4 Fix typo in README (#227)
Fixed typo & superfluous white space in README
2016-08-30 16:32:46 +02:00
Vladimir Vivien
7fb2782df3 Handle TOML Library Licensing
This patch updates the package used for parsing TOML content from
"github.com/BurntSushi/toml" to "github.com/pelletier/go-toml" as the
latter uses a more accepted OSS license (MIT), enabling the inclusion of
Viper or projects that depend on Viper in projects that have licensing
requirements incongruent with the license of the previous TOML package.

Closes #228
Closes #225
Fixes #179
2016-08-20 20:00:39 +01:00
Schley Andrew Kutz
fe9c8b59e1 Add Hugo CI Step to Validate Viper
Since Hugo is such a heavy user of Viper, this patch adds an
after_success section to the Travis-CI build that validates the Viper
commit by attempting to build Hugo and executing `hugo -s docs`.

This patch handles issue #222.
2016-08-20 14:03:44 +01:00
Bjørn Erik Pedersen
654fc7bb54 Bump Travis to Go 1.7 2016-08-16 10:09:34 +02:00
Bjørn Erik Pedersen
346299ea79 Add getter for global Viper 2016-08-06 18:06:49 +02:00
Bjørn Erik Pedersen
abafbf243b Revert "Handle TOML Library Licensing"
It breaks Hugo, will have to test/investigate.

Erro when building Hugo docs:
```
ERROR: 2016/08/05 11:19:23 site.go:1208: unable to process menus in site config
ERROR: 2016/08/05 11:19:23 site.go:1209: Unable to Cast map[string]interface {}{"pre":"<i class='fa fa-space-shuttle'></i>", "weight":-20, "url":"/commands/", "name":"Hugo Cmd Reference", "identifier":"commands"} of type map[string]interface {} to []interface{}
```

This reverts commit 7402856f06.
2016-08-05 11:21:53 +02:00
Bjørn Erik Pedersen
a59dcccc82 Move the Afero fs to the Viper type
And make a exported setter for it.
2016-08-05 09:45:58 +02:00
Albert
d0c2644870 Add dot in BindPFlag comment 2016-08-05 09:25:24 +02:00
Matthieu Grieger
4cf0bd2789 Add support for Afero filesystems 2016-08-05 09:24:49 +02:00
Roland Schilter
5619c0edbe Reset cache on config name change
I stumbled over this when trying to merge multiple configs.

```
viper.SetConfigName("default")
err := viper.MergeInConfig()
```
which caches file path resolvemenet in `v.configFile`

and then
```
viper.SetConfigName("prod")
err := viper.MergeInConfig()
```

which reuses `v.configFile` without updating it accordingly to the new name.

See c1ccc378a0/viper.go (L1240)
2016-08-05 09:18:19 +02:00
Chuanjian Wang
64dc6f6810 Add GetInt64 2016-08-05 09:16:55 +02:00
Bryan Liles
6d2589cd85 Update Readme with doit's new location
doit has been moved and renamed to doctl
2016-08-05 09:15:51 +02:00
Schley Andrew Kutz
7402856f06 Handle TOML Library Licensing
This patch updates the package used for parsing TOML content from
"github.com/BurntSushi/toml" to "github.com/pelletier/go-toml" as the
latter uses a more accepted OSS license (MIT), enabling the inclusion of
Viper or projects that depend on Viper in projects that have licensing
requirements incongruent with the license of the previous TOML package.

This patch replaces the PR https://github.com/spf13/viper/pull/208 after
discussing the matter with @spf13 and deciding to update the TOML parser
instead of making TOML build-optional.
2016-08-05 09:15:24 +02:00
Bjørn Erik Pedersen
b53595fb56 Bump Travis to Go 1.6.3 2016-07-18 23:48:14 +02:00
Bjørn Erik Pedersen
c1ccc378a0 Test on both Linux and OSX 2016-06-06 00:03:07 +02:00
Bjørn Erik Pedersen
d8a428b8a3 Bump Travis to 1.6.2 2016-05-08 20:07:13 +02:00
Bjørn Erik Pedersen
960e69f7c4 Allow tip to fail on Travis 2016-05-08 14:34:24 +02:00
Bjørn Erik Pedersen
a0cdbddebd Remove kr/pretty dependency
See https://github.com/spf13/hugo/issues/2124
See https://github.com/kr/text/issues/6
2016-05-08 13:12:02 +02:00
Anthony Fok
f904a17905 Update Travis config to Go 1.4.3, 1.5.4 and 1.6.1 2016-04-21 06:40:14 +08:00
Anthony Fok
8e57fea7a8 Update import path of fsnotify
Rename "gopkg.in/fsnotify.v1" to "github.com/fsnotify/fsnotify"
per upstream recommendation.

See https://github.com/fsnotify/fsnotify/issues/108 for rationale.
2016-04-20 21:51:22 +08:00
Tony Narlock
45b73b72ad Fix typo 2016-04-20 21:43:24 +08:00
dsp
c975dc1b4e implementing a weak decode wrapper called UnmarshalExact that errors on non existant fields in the destination struct 2016-02-09 16:07:50 -07:00
Steve Francia
dd66c894de Populate readme with viper based apps 2016-02-08 17:01:43 -05:00
Marcin Stanisławski
e072d51737 use aliases in all keys list to enable proper Unmarshaling 2016-02-08 15:52:20 -05:00
ryanwalls
30ce444d04 Update README with info about supporting Java properties files 2016-01-30 11:44:53 -07:00
Bjørn Erik Pedersen
a212099cbe Watch the entire config dir for changes
Then checking the file name in the event handler. This seems to be the only robust way
of handling changes from a single file on multiple platforms and editors.

See #142
2016-01-11 16:07:23 +01:00
Bjørn Erik Pedersen
cc70319ebc Fix config watch
* Only add *the* config file, not all possible folders
* Trigger reload on both write and create events;
  the latter is what we get from atomic save editors (like TextMate) once https://github.com/go-fsnotify/fsnotify/pull/111 is merged

See #142
2016-01-11 13:34:45 +01:00
Lei Feng
0c82789feb Handle the case Get() returns either map[interface{}]interface{} or map[string]interface{} 2015-12-26 09:08:49 +08:00
akutz
110492b300 Bugfix for Nested Key Casing
This patch fixes a bug with how Viper handle's key casing when keys are
nested. While Viper is generally case-insensitive, this was not the case
with regards to nested keys. This patch makes nested keys insensitive as
well.
2015-12-24 10:25:30 -05:00
akutz
991d18afb2 Adds MergeConfig functionality
This patch adds the `MergeConfig` and `MergeInConfig` functions to
enable reading new configuration files via a merge strategy rather
than replace. For example, take the following as the base YAML for a
configuration:

    hello:
        pop: 37890
        world:
        - us
        - uk
        - fr
        - de

Now imagine we want to read the following, new configuration data:

    hello:
        pop: 45000
        universe:
        - mw
        - ad
    fu: bar

Using the standard `ReadConfig` function the value returned by the
nested key `hello.world` would no longer be present after the second
configuration is read. This is because the `ReadConfig` function and
its relatives replace nested structures entirely.

The new `MergeConfig` function would produce the following config
after the second YAML snippet was merged with the first:

    hello:
        pop: 45000
        world:
        - us
        - uk
        - fr
        - de
        universe:
        - mw
        - ad
    fu: bar

Examples showing how this works can be found in the two unit tests
named `TestMergeConfig` and `TestMergeConfigNoMerge`.
2015-12-24 10:24:07 -05:00
David Calavera
c8c6312ace Add information about flag interfaces to the readme file.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-24 10:16:42 -05:00
David Calavera
66249a6550 Add FlagValue interface to support other flag systems.
Using an interface allows people to use their favourite flag system
with viper without being restricted to the semantics of pflag or the
standard library.

This change introduce two new functions `BindFlagValues` and
`BindFlagValue` that behave like `BindFlags` and `BindFlag` but using
the new interface as values.

This change also introduces two internal structures to transform
`*pflag.FlagSet` and `*pflag.Flag` into the new interface. This way,
viper keeps working as expected for people that are currently using the
pflag package without breaking backwards compatibility.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-24 10:16:41 -05:00
Lei Feng
105e3d0d19 Add Sub() for Viper, which returns a branch of a Viper instance. 2015-12-24 22:44:14 +08:00
patdhlk
79971f1ae7 add HCL support to the README file 2015-12-15 14:44:21 -05:00
patdhlk
8e6f2421dc add test structure for hcl 2015-12-15 14:44:21 -05:00
patdhlk
60e1b5f599 changed the test hcl config 2015-12-15 14:44:21 -05:00
patdhlk
606a4f3933 add support for hcl 2015-12-15 14:44:21 -05:00
Sanjay Bhandari
5c53af5e4f README: describe interworking with flag package 2015-12-15 12:58:30 -05:00
Abhinandan
823bc1371b Document the use of struct tags to map the dissimilar fields. 2015-12-15 12:57:56 -05:00
HuKeping
87d443c19b Fix tab issue.
As the title said.
2015-12-15 12:54:05 -05:00
Steve Francia
90b31f671f Merge pull request #138 from derekparker/fix-typo
readme: Fix typo
2015-12-11 21:21:22 -05:00
akutz
e3bc06f20c Refactored IsSet to examine keys
This patch refactors the IsSet function to examine the keys in order
to see if a key is set instead of simply checking if a value is nil.
This change is necessary due to the fact that default values via
flag bindings will result in the old logic always being true for
the IsSet function due to a type's default value such as 0 for an
integer or an empty string for a string. While a type's default
value may be preferable when getting the value for a key, it
results in a false positive when determining if a key is actually
set. This change enables users to detect whether a key is set by
only returning a flag's value if it has changed.
2015-12-11 16:17:57 -05:00
Jonathan Boulle
ce08532bfd Correct "etcd" naming
The project should always be referred to in lowercase.
2015-12-11 16:14:08 -05:00
Derek Parker
cc3dd557e0 readme: Fix typo 2015-12-03 11:47:09 -08:00
akutz
c25387f10d AllKeys() now includes bound flag and env var keys
This patch fixes a bug where the function `AllKeys()` did not include
the keys for bound flags and environment variables.
2015-11-12 14:28:38 -06:00
spf13
e37b56e207 Add dynamic reading of config file support 2015-11-09 23:22:04 -05:00
akutz
c374c6d0a9 Flag Binding Refactor
This patch alters the way flags are handled to coincide with the
documentation on the Viper README. The documentation indicated that flag
bindings were late, when in fact they were very, very early. This patch
changes flag bindings to behave as late bindings.
2015-11-09 19:24:13 -05:00
Vlad Didenko
a7ef020a9a Clarify CWD search. Fixes #32 2015-11-06 14:50:12 -05:00
James Sweet
87b94ba486 Fixed #115: Added code in the find method to search for nested configuration parameters 2015-11-04 19:35:10 -05:00
spf13
6a665317fd use docker based travis-ci 2015-11-04 18:15:48 -05:00