fix(dockerCompose): add Volume.MergeFirstWin()

This commit is contained in:
Markus Pesch 2023-08-27 18:53:24 +02:00
parent 7b0109caf4
commit 14c645dd96
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982

View File

@ -1129,6 +1129,25 @@ func (v *Volume) Equal(equalable Equalable) bool {
}
}
func (v *Volume) MergeFirstWin(volume *Volume) {
switch {
case v == nil && volume == nil:
fallthrough
case v != nil && volume == nil:
return
// WARN: It's not possible to change the memory pointer v *Volume to a new
// initialized Volume without returning the volume it self.
//
// case v == nil && volume != nil:
// v = NewVolume()
// fallthrough
default:
v.mergeFirstWinExternal(volume.External)
}
}
func (v *Volume) MergeLastWin(volume *Volume) {
switch {
case v == nil && volume == nil:
@ -1148,6 +1167,13 @@ func (v *Volume) MergeLastWin(volume *Volume) {
}
}
func (v *Volume) mergeFirstWinExternal(external bool) {
if v.External {
return
}
v.External = true
}
func (v *Volume) mergeLastWinExternal(external bool) {
if v.External != external {
v.External = external