Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.11.4
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.15.0
  • v1.16.0
  • v1.17.1
  • v1.17.2
  • v1.17.3
  • v1.17.4
  • v1.17.5
  • v1.17.6
  • v1.17.7
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.18.3
  • v1.19.0
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.20.4
  • v1.20.5
  • v1.21.0
  • v1.22.0
  • v1.22.1
  • v1.22.3
  • v1.22.4
  • v1.22.5
  • v1.22.6
  • v1.22.7
  • v1.22.8
  • v1.22.9
  • v1.3.0
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.4.3
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v1.9.0
55 results

Target

Select target project
  • oss/libraries/go/application/configuration
1 result
Select Git revision
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.11.4
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.15.0
  • v1.16.0
  • v1.17.1
  • v1.17.2
  • v1.17.3
  • v1.17.4
  • v1.17.5
  • v1.17.6
  • v1.17.7
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.18.3
  • v1.19.0
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.20.4
  • v1.20.5
  • v1.21.0
  • v1.22.0
  • v1.22.1
  • v1.22.3
  • v1.22.4
  • v1.22.5
  • v1.22.6
  • v1.22.7
  • v1.22.8
  • v1.22.9
  • v1.3.0
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.4.3
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.7.1
  • v1.8.0
  • v1.9.0
55 results
Show changes
Commits on Source (4)
<a name="v1.12.0"></a>
## [v1.12.0] - 2022-10-23
### Add Features
- feat new merge method
### Changes
- chore add licenses
<a name="v1.11.4"></a>
## [v1.11.4] - 2022-10-23
### Bug Fixes
......@@ -137,6 +146,7 @@
<a name="v1.0.0"></a>
## v1.0.0 - 2022-09-18
[v1.12.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.11.4...v1.12.0
[v1.11.4]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.11.3...v1.11.4
[v1.11.3]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.11.2...v1.11.3
[v1.11.2]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.11.1...v1.11.2
......
......@@ -10,7 +10,12 @@ import (
// // Copy implements the xflags.Copyable interface.
func (s *Settings[C]) Copy(m map[string]any) {
c := s.Config()
if s == nil {
panic("struct is not initialized")
}
s.Lock()
defer s.Unlock()
errorCount := len(s.errors)
defer func() {
......@@ -19,6 +24,12 @@ func (s *Settings[C]) Copy(m map[string]any) {
}
}()
copyOf := func(s C) C {
return s
}
c := copyOf(s.config)
for k, v := range m {
err := pathfinder.SetValue(&c, k, v)
if err != nil {
......@@ -26,5 +37,6 @@ func (s *Settings[C]) Copy(m map[string]any) {
}
}
s.setConfigInternal(c, true)
s.setConfigInternal(c, false)
}
......@@ -3,22 +3,31 @@
package configuration
//type testExecutionStruct struct {
//}
//
//type testConfigStruct struct {
//}
//
//func (s *testConfigStruct) Copy(m map[string]any) {
//}
//
//func TestXFlagsCopyable(t *testing.T) {
// config := New(testConfigStruct{})
// flags := xflags.Execute(testExecutionStruct{}, config)
// flags.Parse([]string{"-a", "command1", "-d"})
//}
//
//func TestXFlagsCopyable2(t *testing.T) {
// flags := xflags.Execute(testExecutionStruct{})
// flags.Parse([]string{"-a", "command1", "-d"})
//}
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCopyable(t *testing.T) {
config := struct {
Host string
Port int
}{
Host: "localhost",
Port: 8080,
}
c := New(config)
assert.Equal(t, c.Config().Host, "localhost")
assert.Equal(t, c.Config().Port, 8080)
m := map[string]any{
"Host": "1.2.3.4",
}
c.Copy(m)
assert.Equal(t, c.Config().Host, "1.2.3.4")
}
......@@ -12,8 +12,8 @@ require (
github.com/stretchr/testify v1.8.0
gitlab.schukai.com/oss/libraries/go/application/xflags v1.9.0
gitlab.schukai.com/oss/libraries/go/network/http-negotiation v1.3.0
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1
golang.org/x/exp v0.0.0-20221023144134-a1e5550cf13e
gopkg.in/yaml.v3 v3.0.1
)
......@@ -22,8 +22,8 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
......@@ -35,16 +35,24 @@ gitlab.schukai.com/oss/libraries/go/network/http-negotiation v1.3.0 h1:SZG0BW5ll
gitlab.schukai.com/oss/libraries/go/network/http-negotiation v1.3.0/go.mod h1:RS2rKf5O+rmSBshHLOgjG7dxg5N2MhNYokZOBcuXdX8=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0 h1:mSxk2q/npskmHMmw1oF4moccjGav5dL6qmff2njUV7A=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1 h1:oyElaqEiyr2XgaE1CYwD8LoeHsuR/vQD/p6k3jYbJFs=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 h1:sBdrWpxhGDdTAYNqbgBLAR+ULAPPhfgncLr1X0lyWtg=
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/exp v0.0.0-20221023144134-a1e5550cf13e h1:SkwG94eNiiYJhbeDE018Grw09HIN/KB9NlRmZsrzfWs=
golang.org/x/exp v0.0.0-20221023144134-a1e5550cf13e/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU=
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 h1:OK7RB6t2WQX54srQQYSXMW8dF5C6/8+oA/s5QBmmto4=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
......
// Copyright 2022 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package configuration
import "github.com/imdario/mergo"
func (s *Settings[C]) Merge(change C) *Settings[C] {
if s == nil {
panic("struct is not initialized")
}
s.Lock()
defer s.Unlock()
if err := mergo.Merge(&s.config, change); err != nil {
s.errors = append(s.errors, err)
}
return s
}
{"version":"1.11.4"}
{"version":"1.12.0"}