Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Configuration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
Configuration
Commits
1b4021d0
Verified
Commit
1b4021d0
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix allow override
parent
60370808
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
merge.go
+1
-1
1 addition, 1 deletion
merge.go
merge_test.go
+25
-0
25 additions, 0 deletions
merge_test.go
with
26 additions
and
1 deletion
merge.go
+
1
−
1
View file @
1b4021d0
...
@@ -14,7 +14,7 @@ func (s *Settings[C]) Merge(change C) *Settings[C] {
...
@@ -14,7 +14,7 @@ func (s *Settings[C]) Merge(change C) *Settings[C] {
s
.
Lock
()
s
.
Lock
()
defer
s
.
Unlock
()
defer
s
.
Unlock
()
if
err
:=
mergo
.
Merge
(
&
s
.
config
,
change
);
err
!=
nil
{
if
err
:=
mergo
.
Merge
(
&
s
.
config
,
change
,
mergo
.
WithOverride
,
mergo
.
WithTypeCheck
);
err
!=
nil
{
s
.
errors
=
append
(
s
.
errors
,
err
)
s
.
errors
=
append
(
s
.
errors
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
merge_test.go
0 → 100644
+
25
−
0
View file @
1b4021d0
// Copyright 2022 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package
configuration
import
(
"github.com/stretchr/testify/assert"
"testing"
)
func
TestMerge
(
t
*
testing
.
T
)
{
var
configS
,
configD
ConfigStruct2
source
:=
New
(
configS
)
source
.
config
.
H
.
HA
=
2
dest
:=
New
(
configD
)
dest
.
config
.
H
.
HA
=
1
assert
.
Equal
(
t
,
dest
.
config
.
H
.
HA
,
1
)
dest
.
Merge
(
source
.
config
)
assert
.
Equal
(
t
,
dest
.
config
.
H
.
HA
,
2
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment