mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
bump imdario/mergo v0.3.7
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
f5b8046335
commit
059e2ca135
4 changed files with 30 additions and 10 deletions
|
@ -23,7 +23,7 @@ gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0
|
||||||
github.com/google/go-cmp v0.2.0
|
github.com/google/go-cmp v0.2.0
|
||||||
|
|
||||||
github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
|
github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
|
||||||
github.com/imdario/mergo v0.3.6
|
github.com/imdario/mergo 7c29201646fa3de8506f701213473dd407f19646 # v0.3.7
|
||||||
golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca
|
golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca
|
||||||
|
|
||||||
# buildkit
|
# buildkit
|
||||||
|
|
18
vendor/github.com/imdario/mergo/README.md
generated
vendored
18
vendor/github.com/imdario/mergo/README.md
generated
vendored
|
@ -13,6 +13,7 @@ It is ready for production use. [It is used in several projects by Docker, Googl
|
||||||
[![Build Status][1]][2]
|
[![Build Status][1]][2]
|
||||||
[![Coverage Status][7]][8]
|
[![Coverage Status][7]][8]
|
||||||
[![Sourcegraph][9]][10]
|
[![Sourcegraph][9]][10]
|
||||||
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fimdario%2Fmergo.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fimdario%2Fmergo?ref=badge_shield)
|
||||||
|
|
||||||
[1]: https://travis-ci.org/imdario/mergo.png
|
[1]: https://travis-ci.org/imdario/mergo.png
|
||||||
[2]: https://travis-ci.org/imdario/mergo
|
[2]: https://travis-ci.org/imdario/mergo
|
||||||
|
@ -27,7 +28,7 @@ It is ready for production use. [It is used in several projects by Docker, Googl
|
||||||
|
|
||||||
### Latest release
|
### Latest release
|
||||||
|
|
||||||
[Release v0.3.6](https://github.com/imdario/mergo/releases/tag/v0.3.6).
|
[Release v0.3.7](https://github.com/imdario/mergo/releases/tag/v0.3.7).
|
||||||
|
|
||||||
### Important note
|
### Important note
|
||||||
|
|
||||||
|
@ -217,6 +218,21 @@ If I can help you, you have an idea or you are using Mergo in your projects, don
|
||||||
|
|
||||||
Written by [Dario Castañé](http://dario.im).
|
Written by [Dario Castañé](http://dario.im).
|
||||||
|
|
||||||
|
## Top Contributors
|
||||||
|
|
||||||
|
[![0](https://sourcerer.io/fame/imdario/imdario/mergo/images/0)](https://sourcerer.io/fame/imdario/imdario/mergo/links/0)
|
||||||
|
[![1](https://sourcerer.io/fame/imdario/imdario/mergo/images/1)](https://sourcerer.io/fame/imdario/imdario/mergo/links/1)
|
||||||
|
[![2](https://sourcerer.io/fame/imdario/imdario/mergo/images/2)](https://sourcerer.io/fame/imdario/imdario/mergo/links/2)
|
||||||
|
[![3](https://sourcerer.io/fame/imdario/imdario/mergo/images/3)](https://sourcerer.io/fame/imdario/imdario/mergo/links/3)
|
||||||
|
[![4](https://sourcerer.io/fame/imdario/imdario/mergo/images/4)](https://sourcerer.io/fame/imdario/imdario/mergo/links/4)
|
||||||
|
[![5](https://sourcerer.io/fame/imdario/imdario/mergo/images/5)](https://sourcerer.io/fame/imdario/imdario/mergo/links/5)
|
||||||
|
[![6](https://sourcerer.io/fame/imdario/imdario/mergo/images/6)](https://sourcerer.io/fame/imdario/imdario/mergo/links/6)
|
||||||
|
[![7](https://sourcerer.io/fame/imdario/imdario/mergo/images/7)](https://sourcerer.io/fame/imdario/imdario/mergo/links/7)
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) license, as [Go language](http://golang.org/LICENSE).
|
[BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) license, as [Go language](http://golang.org/LICENSE).
|
||||||
|
|
||||||
|
|
||||||
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fimdario%2Fmergo.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fimdario%2Fmergo?ref=badge_large)
|
||||||
|
|
1
vendor/github.com/imdario/mergo/map.go
generated
vendored
1
vendor/github.com/imdario/mergo/map.go
generated
vendored
|
@ -72,6 +72,7 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
srcMap := src.Interface().(map[string]interface{})
|
srcMap := src.Interface().(map[string]interface{})
|
||||||
for key := range srcMap {
|
for key := range srcMap {
|
||||||
|
config.overwriteWithEmptyValue = true
|
||||||
srcValue := srcMap[key]
|
srcValue := srcMap[key]
|
||||||
fieldName := changeInitialCase(key, unicode.ToUpper)
|
fieldName := changeInitialCase(key, unicode.ToUpper)
|
||||||
dstElement := dst.FieldByName(fieldName)
|
dstElement := dst.FieldByName(fieldName)
|
||||||
|
|
19
vendor/github.com/imdario/mergo/merge.go
generated
vendored
19
vendor/github.com/imdario/mergo/merge.go
generated
vendored
|
@ -26,9 +26,10 @@ func hasExportedField(dst reflect.Value) (exported bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Overwrite bool
|
Overwrite bool
|
||||||
AppendSlice bool
|
AppendSlice bool
|
||||||
Transformers Transformers
|
Transformers Transformers
|
||||||
|
overwriteWithEmptyValue bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Transformers interface {
|
type Transformers interface {
|
||||||
|
@ -40,6 +41,8 @@ type Transformers interface {
|
||||||
// short circuiting on recursive types.
|
// short circuiting on recursive types.
|
||||||
func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
|
func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
|
||||||
overwrite := config.Overwrite
|
overwrite := config.Overwrite
|
||||||
|
overwriteWithEmptySrc := config.overwriteWithEmptyValue
|
||||||
|
config.overwriteWithEmptyValue = false
|
||||||
|
|
||||||
if !src.IsValid() {
|
if !src.IsValid() {
|
||||||
return
|
return
|
||||||
|
@ -74,7 +77,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if dst.CanSet() && !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) {
|
if dst.CanSet() && (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) {
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +128,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
dstSlice = reflect.ValueOf(dstElement.Interface())
|
dstSlice = reflect.ValueOf(dstElement.Interface())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
|
if (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
|
||||||
dstSlice = srcSlice
|
dstSlice = srcSlice
|
||||||
} else if config.AppendSlice {
|
} else if config.AppendSlice {
|
||||||
if srcSlice.Type() != dstSlice.Type() {
|
if srcSlice.Type() != dstSlice.Type() {
|
||||||
|
@ -136,7 +139,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
dst.SetMapIndex(key, dstSlice)
|
dst.SetMapIndex(key, dstSlice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if dstElement.IsValid() && reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Map {
|
if dstElement.IsValid() && !isEmptyValue(dstElement) && (reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Map || reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Slice) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
if !dst.CanSet() {
|
if !dst.CanSet() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
|
if (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
} else if config.AppendSlice {
|
} else if config.AppendSlice {
|
||||||
if src.Type() != dst.Type() {
|
if src.Type() != dst.Type() {
|
||||||
|
@ -191,7 +194,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if dst.CanSet() && !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) {
|
if dst.CanSet() && (!isEmptyValue(src) || overwriteWithEmptySrc) && (overwrite || isEmptyValue(dst)) {
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue