mirror of
https://github.com/NotAShelf/catApi.git
synced 2025-12-12 07:03:55 +00:00
bump dependencies
This commit is contained in:
parent
bae551520a
commit
b7319e6bfc
466 changed files with 17912 additions and 12742 deletions
14
vendor/github.com/spf13/viper/.golangci.yaml
generated
vendored
14
vendor/github.com/spf13/viper/.golangci.yaml
generated
vendored
|
|
@ -7,6 +7,16 @@ linters-settings:
|
|||
- standard
|
||||
- default
|
||||
- prefix(github.com/spf13/viper)
|
||||
gocritic:
|
||||
# Enable multiple checks by tags. See "Tags" section in https://github.com/go-critic/go-critic#usage.
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- experimental
|
||||
- opinionated
|
||||
- style
|
||||
disabled-checks:
|
||||
- importShadow
|
||||
- unnamedResult
|
||||
golint:
|
||||
min-confidence: 0
|
||||
goimports:
|
||||
|
|
@ -22,6 +32,8 @@ linters:
|
|||
- exhaustive
|
||||
- exportloopref
|
||||
- gci
|
||||
- gocritic
|
||||
- godot
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
|
|
@ -62,9 +74,7 @@ linters:
|
|||
# - gochecknoinits
|
||||
# - gocognit
|
||||
# - goconst
|
||||
# - gocritic
|
||||
# - gocyclo
|
||||
# - godot
|
||||
# - gosec
|
||||
# - gosimple
|
||||
# - ifshort
|
||||
|
|
|
|||
13
vendor/github.com/spf13/viper/README.md
generated
vendored
13
vendor/github.com/spf13/viper/README.md
generated
vendored
|
|
@ -11,7 +11,7 @@
|
|||
[](https://github.com/spf13/viper/actions?query=workflow%3ACI)
|
||||
[](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://goreportcard.com/report/github.com/spf13/viper)
|
||||

|
||||

|
||||
[](https://pkg.go.dev/mod/github.com/spf13/viper)
|
||||
|
||||
**Go configuration with fangs!**
|
||||
|
|
@ -39,7 +39,7 @@ Many Go projects are built using Viper including:
|
|||
go get github.com/spf13/viper
|
||||
```
|
||||
|
||||
**Note:** Viper uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
|
||||
**Note:** Viper uses [Go Modules](https://go.dev/wiki/Modules) to manage dependencies.
|
||||
|
||||
|
||||
## What is Viper?
|
||||
|
|
@ -418,7 +418,9 @@ in a Key/Value store such as etcd or Consul. These values take precedence over
|
|||
default values, but are overridden by configuration values retrieved from disk,
|
||||
flags, or environment variables.
|
||||
|
||||
Viper uses [crypt](https://github.com/bketelsen/crypt) to retrieve
|
||||
Viper supports multiple hosts. To use, pass a list of endpoints separated by `;`. For example `http://127.0.0.1:4001;http://127.0.0.1:4002`.
|
||||
|
||||
Viper uses [crypt](https://github.com/sagikazarmark/crypt) to retrieve
|
||||
configuration from the K/V store, which means that you can store your
|
||||
configuration values encrypted and have them automatically decrypted if you have
|
||||
the correct gpg keyring. Encryption is optional.
|
||||
|
|
@ -430,7 +432,7 @@ independently of it.
|
|||
K/V store. `crypt` defaults to etcd on http://127.0.0.1:4001.
|
||||
|
||||
```bash
|
||||
$ go get github.com/bketelsen/crypt/bin/crypt
|
||||
$ go get github.com/sagikazarmark/crypt/bin/crypt
|
||||
$ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json
|
||||
```
|
||||
|
||||
|
|
@ -563,6 +565,9 @@ One important thing to recognize is that each Get function will return a zero
|
|||
value if it’s not found. To check if a given key exists, the `IsSet()` method
|
||||
has been provided.
|
||||
|
||||
The zero value will also be returned if the value is set, but fails to parse
|
||||
as the requested type.
|
||||
|
||||
Example:
|
||||
```go
|
||||
viper.GetString("logfile") // case-insensitive Setting & Getting
|
||||
|
|
|
|||
4
vendor/github.com/spf13/viper/TROUBLESHOOTING.md
generated
vendored
4
vendor/github.com/spf13/viper/TROUBLESHOOTING.md
generated
vendored
|
|
@ -15,10 +15,10 @@ cannot find package "github.com/hashicorp/hcl/tree/hcl1" in any of:
|
|||
```
|
||||
|
||||
As the error message suggests, Go tries to look up dependencies in `GOPATH` mode (as it's commonly called) from the `GOPATH`.
|
||||
Viper opted to use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, `GOPATH` mode is no longer able to decide which version to use, so it'll either use one that's already present or pick a version (usually the `master` branch).
|
||||
Viper opted to use [Go Modules](https://go.dev/wiki/Modules) to manage its dependencies. While in many cases the two methods are interchangeable, once a dependency releases new (major) versions, `GOPATH` mode is no longer able to decide which version to use, so it'll either use one that's already present or pick a version (usually the `master` branch).
|
||||
|
||||
The solution is easy: switch to using Go Modules.
|
||||
Please refer to the [wiki](https://github.com/golang/go/wiki/Modules) on how to do that.
|
||||
Please refer to the [wiki](https://go.dev/wiki/Modules) on how to do that.
|
||||
|
||||
**tl;dr* `export GO111MODULE=on`
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func (v *Viper) searchInPath(in string) (filename string) {
|
|||
return ""
|
||||
}
|
||||
|
||||
// Check if file Exists
|
||||
// exists checks if file exists.
|
||||
func exists(fs afero.Fs, path string) (bool, error) {
|
||||
stat, err := fs.Stat(path)
|
||||
if err == nil {
|
||||
2
vendor/github.com/spf13/viper/flags.go
generated
vendored
2
vendor/github.com/spf13/viper/flags.go
generated
vendored
|
|
@ -31,7 +31,7 @@ func (p pflagValueSet) VisitAll(fn func(flag FlagValue)) {
|
|||
}
|
||||
|
||||
// pflagValue is a wrapper around *pflag.flag
|
||||
// that implements FlagValue
|
||||
// that implements FlagValue.
|
||||
type pflagValue struct {
|
||||
flag *pflag.Flag
|
||||
}
|
||||
|
|
|
|||
62
vendor/github.com/spf13/viper/flake.lock
generated
vendored
62
vendor/github.com/spf13/viper/flake.lock
generated
vendored
|
|
@ -8,11 +8,11 @@
|
|||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687972261,
|
||||
"narHash": "sha256-+mxvZfwMVoaZYETmuQWqTi/7T9UKoAE+WpdSQkOVJ2g=",
|
||||
"lastModified": 1707817777,
|
||||
"narHash": "sha256-vHyIs1OULQ3/91wD6xOiuayfI71JXALGA5KLnDKAcy0=",
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "e85df562088573305e55906eaa964341f8cb0d9f",
|
||||
"rev": "5a30b9e5ac7c6167e61b1f4193d5130bb9f8defa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -42,11 +42,11 @@
|
|||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687762428,
|
||||
"narHash": "sha256-DIf7mi45PKo+s8dOYF+UlXHzE0Wl/+k3tXUyAoAnoGE=",
|
||||
"lastModified": 1706830856,
|
||||
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "37dd7bb15791c86d55c5121740a1887ab55ee836",
|
||||
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -56,12 +56,15 @@
|
|||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -151,11 +154,11 @@
|
|||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1685564631,
|
||||
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
|
||||
"lastModified": 1706550542,
|
||||
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
|
||||
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -184,27 +187,27 @@
|
|||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1678872516,
|
||||
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
|
||||
"lastModified": 1685801374,
|
||||
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
|
||||
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.11",
|
||||
"ref": "nixos-23.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1687886075,
|
||||
"narHash": "sha256-PeayJDDDy+uw1Ats4moZnRdL1OFuZm1Tj+KiHlD67+o=",
|
||||
"lastModified": 1707939175,
|
||||
"narHash": "sha256-D1xan0lgxbmXDyzVqXTiSYHLmAMrMRdD+alKzEO/p3w=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a565059a348422af5af9026b5174dc5c0dcefdae",
|
||||
"rev": "f7e8132daca31b1e3859ac0fb49741754375ac3d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -229,11 +232,11 @@
|
|||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686050334,
|
||||
"narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=",
|
||||
"lastModified": 1704725188,
|
||||
"narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc",
|
||||
"rev": "ea96f0c05924341c551a797aaba8126334c505d2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -248,6 +251,21 @@
|
|||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
|
|||
1
vendor/github.com/spf13/viper/flake.nix
generated
vendored
1
vendor/github.com/spf13/viper/flake.nix
generated
vendored
|
|
@ -20,6 +20,7 @@
|
|||
default = {
|
||||
languages = {
|
||||
go.enable = true;
|
||||
go.package = pkgs.go_1_22;
|
||||
};
|
||||
|
||||
pre-commit.hooks = {
|
||||
|
|
|
|||
4
vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
generated
vendored
4
vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
generated
vendored
|
|
@ -8,8 +8,8 @@ import (
|
|||
|
||||
// flattenAndMergeMap recursively flattens the given map into a new map
|
||||
// Code is based on the function with the same name in the main package.
|
||||
// TODO: move it to a common place
|
||||
func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any {
|
||||
// TODO: move it to a common place.
|
||||
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
|
||||
if shadow != nil && prefix != "" && shadow[prefix] != nil {
|
||||
// prefix is shadowed => nothing more to flatten
|
||||
return shadow
|
||||
|
|
|
|||
4
vendor/github.com/spf13/viper/internal/encoding/ini/map_utils.go
generated
vendored
4
vendor/github.com/spf13/viper/internal/encoding/ini/map_utils.go
generated
vendored
|
|
@ -41,8 +41,8 @@ func deepSearch(m map[string]any, path []string) map[string]any {
|
|||
|
||||
// flattenAndMergeMap recursively flattens the given map into a new map
|
||||
// Code is based on the function with the same name in the main package.
|
||||
// TODO: move it to a common place
|
||||
func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any {
|
||||
// TODO: move it to a common place.
|
||||
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
|
||||
if shadow != nil && prefix != "" && shadow[prefix] != nil {
|
||||
// prefix is shadowed => nothing more to flatten
|
||||
return shadow
|
||||
|
|
|
|||
4
vendor/github.com/spf13/viper/internal/encoding/javaproperties/map_utils.go
generated
vendored
4
vendor/github.com/spf13/viper/internal/encoding/javaproperties/map_utils.go
generated
vendored
|
|
@ -41,8 +41,8 @@ func deepSearch(m map[string]any, path []string) map[string]any {
|
|||
|
||||
// flattenAndMergeMap recursively flattens the given map into a new map
|
||||
// Code is based on the function with the same name in the main package.
|
||||
// TODO: move it to a common place
|
||||
func flattenAndMergeMap(shadow map[string]any, m map[string]any, prefix string, delimiter string) map[string]any {
|
||||
// TODO: move it to a common place.
|
||||
func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
|
||||
if shadow != nil && prefix != "" && shadow[prefix] != nil {
|
||||
// prefix is shadowed => nothing more to flatten
|
||||
return shadow
|
||||
|
|
|
|||
5
vendor/github.com/spf13/viper/internal/features/bind_struct.go
generated
vendored
Normal file
5
vendor/github.com/spf13/viper/internal/features/bind_struct.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//go:build viper_bind_struct
|
||||
|
||||
package features
|
||||
|
||||
const BindStruct = true
|
||||
5
vendor/github.com/spf13/viper/internal/features/bind_struct_default.go
generated
vendored
Normal file
5
vendor/github.com/spf13/viper/internal/features/bind_struct_default.go
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//go:build !viper_bind_struct
|
||||
|
||||
package features
|
||||
|
||||
const BindStruct = false
|
||||
2
vendor/github.com/spf13/viper/util.go
generated
vendored
2
vendor/github.com/spf13/viper/util.go
generated
vendored
|
|
@ -156,7 +156,7 @@ func safeMul(a, b uint) uint {
|
|||
return c
|
||||
}
|
||||
|
||||
// parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes
|
||||
// parseSizeInBytes converts strings like 1GB or 12 mb into an unsigned integer number of bytes.
|
||||
func parseSizeInBytes(sizeStr string) uint {
|
||||
sizeStr = strings.TrimSpace(sizeStr)
|
||||
lastChar := len(sizeStr) - 1
|
||||
|
|
|
|||
110
vendor/github.com/spf13/viper/viper.go
generated
vendored
110
vendor/github.com/spf13/viper/viper.go
generated
vendored
|
|
@ -48,6 +48,7 @@ import (
|
|||
"github.com/spf13/viper/internal/encoding/json"
|
||||
"github.com/spf13/viper/internal/encoding/toml"
|
||||
"github.com/spf13/viper/internal/encoding/yaml"
|
||||
"github.com/spf13/viper/internal/features"
|
||||
)
|
||||
|
||||
// ConfigMarshalError happens when failing to marshal the configuration.
|
||||
|
|
@ -77,7 +78,7 @@ type remoteConfigFactory interface {
|
|||
WatchChannel(rp RemoteProvider) (<-chan *RemoteResponse, chan bool)
|
||||
}
|
||||
|
||||
// RemoteConfig is optional, see the remote package
|
||||
// RemoteConfig is optional, see the remote package.
|
||||
var RemoteConfig remoteConfigFactory
|
||||
|
||||
// UnsupportedConfigError denotes encountering an unsupported
|
||||
|
|
@ -102,7 +103,7 @@ func (str UnsupportedRemoteProviderError) Error() string {
|
|||
// pull the configuration from the remote provider.
|
||||
type RemoteConfigError string
|
||||
|
||||
// Error returns the formatted remote provider error
|
||||
// Error returns the formatted remote provider error.
|
||||
func (rce RemoteConfigError) Error() string {
|
||||
return fmt.Sprintf("Remote Configurations Error: %s", string(rce))
|
||||
}
|
||||
|
|
@ -126,7 +127,7 @@ func (faee ConfigFileAlreadyExistsError) Error() string {
|
|||
}
|
||||
|
||||
// A DecoderConfigOption can be passed to viper.Unmarshal to configure
|
||||
// mapstructure.DecoderConfig options
|
||||
// mapstructure.DecoderConfig options.
|
||||
type DecoderConfigOption func(*mapstructure.DecoderConfig)
|
||||
|
||||
// DecodeHook returns a DecoderConfigOption which overrides the default
|
||||
|
|
@ -305,7 +306,7 @@ func Reset() {
|
|||
SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore", "nats"}
|
||||
}
|
||||
|
||||
// TODO: make this lazy initialization instead
|
||||
// TODO: make this lazy initialization instead.
|
||||
func (v *Viper) resetEncoding() {
|
||||
encoderRegistry := encoding.NewEncoderRegistry()
|
||||
decoderRegistry := encoding.NewDecoderRegistry()
|
||||
|
|
@ -439,7 +440,7 @@ func (v *Viper) WatchConfig() {
|
|||
initWG := sync.WaitGroup{}
|
||||
initWG.Add(1)
|
||||
go func() {
|
||||
watcher, err := newWatcher()
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
v.logger.Error(fmt.Sprintf("failed to create watcher: %s", err))
|
||||
os.Exit(1)
|
||||
|
|
@ -590,7 +591,7 @@ func (v *Viper) AddConfigPath(in string) {
|
|||
// path is the path in the k/v store to retrieve configuration
|
||||
// To retrieve a config file called myapp.json from /configs/myapp.json
|
||||
// you should set path to /configs and set config name (SetConfigName()) to
|
||||
// "myapp"
|
||||
// "myapp".
|
||||
func AddRemoteProvider(provider, endpoint, path string) error {
|
||||
return v.AddRemoteProvider(provider, endpoint, path)
|
||||
}
|
||||
|
|
@ -622,8 +623,8 @@ func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error {
|
|||
// path is the path in the k/v store to retrieve configuration
|
||||
// To retrieve a config file called myapp.json from /configs/myapp.json
|
||||
// you should set path to /configs and set config name (SetConfigName()) to
|
||||
// "myapp"
|
||||
// Secure Remote Providers are implemented with github.com/bketelsen/crypt
|
||||
// "myapp".
|
||||
// Secure Remote Providers are implemented with github.com/sagikazarmark/crypt.
|
||||
func AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error {
|
||||
return v.AddSecureRemoteProvider(provider, endpoint, path, secretkeyring)
|
||||
}
|
||||
|
|
@ -827,10 +828,12 @@ func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]any) string
|
|||
// "foo.bar.baz" in a lower-priority map
|
||||
func (v *Viper) isPathShadowedInFlatMap(path []string, mi any) string {
|
||||
// unify input map
|
||||
var m map[string]any
|
||||
switch mi.(type) {
|
||||
case map[string]string, map[string]FlagValue:
|
||||
m = cast.ToStringMap(mi)
|
||||
var m map[string]interface{}
|
||||
switch miv := mi.(type) {
|
||||
case map[string]string:
|
||||
m = castMapStringToMapInterface(miv)
|
||||
case map[string]FlagValue:
|
||||
m = castMapFlagToMapInterface(miv)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
|
@ -957,7 +960,8 @@ func (v *Viper) Sub(key string) *Viper {
|
|||
}
|
||||
|
||||
if reflect.TypeOf(data).Kind() == reflect.Map {
|
||||
subv.parents = append(v.parents, strings.ToLower(key))
|
||||
subv.parents = append([]string(nil), v.parents...)
|
||||
subv.parents = append(subv.parents, strings.ToLower(key))
|
||||
subv.automaticEnvApplied = v.automaticEnvApplied
|
||||
subv.envPrefix = v.envPrefix
|
||||
subv.envKeyReplacer = v.envKeyReplacer
|
||||
|
|
@ -1111,11 +1115,42 @@ func Unmarshal(rawVal any, opts ...DecoderConfigOption) error {
|
|||
}
|
||||
|
||||
func (v *Viper) Unmarshal(rawVal any, opts ...DecoderConfigOption) error {
|
||||
return decode(v.AllSettings(), defaultDecoderConfig(rawVal, opts...))
|
||||
keys := v.AllKeys()
|
||||
|
||||
if features.BindStruct {
|
||||
// TODO: make this optional?
|
||||
structKeys, err := v.decodeStructKeys(rawVal, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
keys = append(keys, structKeys...)
|
||||
}
|
||||
|
||||
// TODO: struct keys should be enough?
|
||||
return decode(v.getSettings(keys), defaultDecoderConfig(rawVal, opts...))
|
||||
}
|
||||
|
||||
func (v *Viper) decodeStructKeys(input any, opts ...DecoderConfigOption) ([]string, error) {
|
||||
var structKeyMap map[string]any
|
||||
|
||||
err := decode(input, defaultDecoderConfig(&structKeyMap, opts...))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
flattenedStructKeyMap := v.flattenAndMergeMap(map[string]bool{}, structKeyMap, "")
|
||||
|
||||
r := make([]string, 0, len(flattenedStructKeyMap))
|
||||
for v := range flattenedStructKeyMap {
|
||||
r = append(r, v)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// defaultDecoderConfig returns default mapstructure.DecoderConfig with support
|
||||
// of time.Duration values & string slices
|
||||
// of time.Duration values & string slices.
|
||||
func defaultDecoderConfig(output any, opts ...DecoderConfigOption) *mapstructure.DecoderConfig {
|
||||
c := &mapstructure.DecoderConfig{
|
||||
Metadata: nil,
|
||||
|
|
@ -1132,7 +1167,7 @@ func defaultDecoderConfig(output any, opts ...DecoderConfigOption) *mapstructure
|
|||
return c
|
||||
}
|
||||
|
||||
// A wrapper around mapstructure.Decode that mimics the WeakDecode functionality
|
||||
// decode is a wrapper around mapstructure.Decode that mimics the WeakDecode functionality.
|
||||
func decode(input any, config *mapstructure.DecoderConfig) error {
|
||||
decoder, err := mapstructure.NewDecoder(config)
|
||||
if err != nil {
|
||||
|
|
@ -1151,7 +1186,20 @@ func (v *Viper) UnmarshalExact(rawVal any, opts ...DecoderConfigOption) error {
|
|||
config := defaultDecoderConfig(rawVal, opts...)
|
||||
config.ErrorUnused = true
|
||||
|
||||
return decode(v.AllSettings(), config)
|
||||
keys := v.AllKeys()
|
||||
|
||||
if features.BindStruct {
|
||||
// TODO: make this optional?
|
||||
structKeys, err := v.decodeStructKeys(rawVal, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
keys = append(keys, structKeys...)
|
||||
}
|
||||
|
||||
// TODO: struct keys should be enough?
|
||||
return decode(v.getSettings(keys), config)
|
||||
}
|
||||
|
||||
// BindPFlags binds a full flag set to the configuration, using each flag's long
|
||||
|
|
@ -1405,11 +1453,11 @@ func readAsCSV(val string) ([]string, error) {
|
|||
}
|
||||
|
||||
// mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/master/string_to_string.go#L79
|
||||
// alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap
|
||||
// alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap.
|
||||
func stringToStringConv(val string) any {
|
||||
val = strings.Trim(val, "[]")
|
||||
// An empty string would cause an empty map
|
||||
if len(val) == 0 {
|
||||
if val == "" {
|
||||
return map[string]any{}
|
||||
}
|
||||
r := csv.NewReader(strings.NewReader(val))
|
||||
|
|
@ -1429,11 +1477,11 @@ func stringToStringConv(val string) any {
|
|||
}
|
||||
|
||||
// mostly copied from pflag's implementation of this operation here https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/string_to_int.go#L68
|
||||
// alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap
|
||||
// alterations are: errors are swallowed, map[string]any is returned in order to enable cast.ToStringMap.
|
||||
func stringToIntConv(val string) any {
|
||||
val = strings.Trim(val, "[]")
|
||||
// An empty string would cause an empty map
|
||||
if len(val) == 0 {
|
||||
if val == "" {
|
||||
return map[string]any{}
|
||||
}
|
||||
ss := strings.Split(val, ",")
|
||||
|
|
@ -1481,13 +1529,13 @@ func (v *Viper) SetEnvKeyReplacer(r *strings.Replacer) {
|
|||
|
||||
// RegisterAlias creates an alias that provides another accessor for the same key.
|
||||
// This enables one to change a name without breaking the application.
|
||||
func RegisterAlias(alias string, key string) { v.RegisterAlias(alias, key) }
|
||||
func RegisterAlias(alias, key string) { v.RegisterAlias(alias, key) }
|
||||
|
||||
func (v *Viper) RegisterAlias(alias string, key string) {
|
||||
func (v *Viper) RegisterAlias(alias, key string) {
|
||||
v.registerAlias(alias, strings.ToLower(key))
|
||||
}
|
||||
|
||||
func (v *Viper) registerAlias(alias string, key string) {
|
||||
func (v *Viper) registerAlias(alias, key string) {
|
||||
alias = strings.ToLower(alias)
|
||||
if alias != key && alias != v.realKey(key) {
|
||||
_, exists := v.aliases[alias]
|
||||
|
|
@ -1743,12 +1791,6 @@ func (v *Viper) writeConfig(filename string, force bool) error {
|
|||
return f.Sync()
|
||||
}
|
||||
|
||||
// Unmarshal a Reader into a map.
|
||||
// Should probably be an unexported function.
|
||||
func unmarshalReader(in io.Reader, c map[string]any) error {
|
||||
return v.unmarshalReader(in, c)
|
||||
}
|
||||
|
||||
func (v *Viper) unmarshalReader(in io.Reader, c map[string]any) error {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(in)
|
||||
|
|
@ -2012,7 +2054,7 @@ func (v *Viper) watchRemoteConfig(provider RemoteProvider) (map[string]any, erro
|
|||
}
|
||||
|
||||
// AllKeys returns all keys holding a value, regardless of where they are set.
|
||||
// Nested keys are returned with a v.keyDelim separator
|
||||
// Nested keys are returned with a v.keyDelim separator.
|
||||
func AllKeys() []string { return v.AllKeys() }
|
||||
|
||||
func (v *Viper) AllKeys() []string {
|
||||
|
|
@ -2098,9 +2140,13 @@ outer:
|
|||
func AllSettings() map[string]any { return v.AllSettings() }
|
||||
|
||||
func (v *Viper) AllSettings() map[string]any {
|
||||
return v.getSettings(v.AllKeys())
|
||||
}
|
||||
|
||||
func (v *Viper) getSettings(keys []string) map[string]any {
|
||||
m := map[string]any{}
|
||||
// start from the list of keys, and construct the map one value at a time
|
||||
for _, k := range v.AllKeys() {
|
||||
for _, k := range keys {
|
||||
value := v.Get(k)
|
||||
if value == nil {
|
||||
// should not happen, since AllKeys() returns only keys holding a value,
|
||||
|
|
|
|||
11
vendor/github.com/spf13/viper/watch.go
generated
vendored
11
vendor/github.com/spf13/viper/watch.go
generated
vendored
|
|
@ -1,11 +0,0 @@
|
|||
//go:build darwin || dragonfly || freebsd || openbsd || linux || netbsd || solaris || windows
|
||||
|
||||
package viper
|
||||
|
||||
import "github.com/fsnotify/fsnotify"
|
||||
|
||||
type watcher = fsnotify.Watcher
|
||||
|
||||
func newWatcher() (*watcher, error) {
|
||||
return fsnotify.NewWatcher()
|
||||
}
|
||||
31
vendor/github.com/spf13/viper/watch_unsupported.go
generated
vendored
31
vendor/github.com/spf13/viper/watch_unsupported.go
generated
vendored
|
|
@ -1,31 +0,0 @@
|
|||
//go:build appengine || (!darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows)
|
||||
|
||||
package viper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
)
|
||||
|
||||
func newWatcher() (*watcher, error) {
|
||||
return &watcher{}, fmt.Errorf("fsnotify not supported on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
type watcher struct {
|
||||
Events chan fsnotify.Event
|
||||
Errors chan error
|
||||
}
|
||||
|
||||
func (*watcher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*watcher) Add(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*watcher) Remove(name string) error {
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue