Added all merge functions

This commit is contained in:
Trial97
2021-12-06 17:07:44 +02:00
committed by Dan Christian Bogos
parent 7182d57b24
commit c1e399de6d
10 changed files with 416 additions and 575 deletions

View File

@@ -204,3 +204,25 @@ func (aP *APAction) Set(path []string, val interface{}, newBranch bool) (err err
}
return
}
func (ap *ActionProfile) Merge(v2 interface{}) {
vi := v2.(*ActionProfile)
if len(vi.Tenant) != 0 {
ap.Tenant = vi.Tenant
}
if len(vi.ID) != 0 {
ap.ID = vi.ID
}
ap.FilterIDs = append(ap.FilterIDs, vi.FilterIDs...)
ap.Actions = append(ap.Actions, vi.Actions...)
if vi.Weight != 0 {
ap.Weight = vi.Weight
}
if len(vi.Schedule) != 0 {
ap.Schedule = vi.Schedule
}
for k, v := range vi.Targets {
ap.Targets[k] = v
}
}

View File

@@ -296,3 +296,64 @@ func (dH *DispatcherHost) Set(path []string, val interface{}, newBranch bool, _
}
return
}
func (dP *DispatcherProfile) Merge(v2 interface{}) {
vi := v2.(*DispatcherProfile)
if len(vi.Tenant) != 0 {
dP.Tenant = vi.Tenant
}
if len(vi.ID) != 0 {
dP.ID = vi.ID
}
dP.FilterIDs = append(dP.FilterIDs, vi.FilterIDs...)
dP.Hosts = append(dP.Hosts, vi.Hosts...)
if vi.Weight != 0 {
dP.Weight = vi.Weight
}
for k, v := range vi.StrategyParams {
dP.StrategyParams[k] = v
}
if len(vi.Strategy) != 0 {
dP.Strategy = vi.Strategy
}
}
func (dH *DispatcherHost) Merge(v2 interface{}) {
vi := v2.(*DispatcherHost)
if len(vi.Tenant) != 0 {
dH.Tenant = vi.Tenant
}
if len(vi.ID) != 0 {
dH.ID = vi.ID
}
if len(vi.Address) != 0 {
dH.Address = vi.Address
}
if len(vi.Transport) != 0 {
dH.Transport = vi.Transport
}
if len(vi.ClientKey) != 0 {
dH.ClientKey = vi.ClientKey
}
if len(vi.ClientCertificate) != 0 {
dH.ClientCertificate = vi.ClientCertificate
}
if len(vi.CaCertificate) != 0 {
dH.CaCertificate = vi.CaCertificate
}
if vi.TLS {
dH.TLS = vi.TLS
}
if vi.ConnectTimeout != 0 {
dH.ConnectTimeout = vi.ConnectTimeout
}
if vi.ReplyTimeout != 0 {
dH.ReplyTimeout = vi.ReplyTimeout
}
if vi.ConnectAttempts != 0 {
dH.ConnectAttempts = vi.ConnectAttempts
}
if vi.Reconnects != 0 {
dH.Reconnects = vi.Reconnects
}
}

View File

@@ -78,3 +78,21 @@ func (cp *ChargerProfile) Set(path []string, val interface{}, newBranch bool, _
}
return
}
func (cp *ChargerProfile) Merge(v2 interface{}) {
vi := v2.(*ChargerProfile)
if len(vi.Tenant) != 0 {
cp.Tenant = vi.Tenant
}
if len(vi.ID) != 0 {
cp.ID = vi.ID
}
if len(vi.RunID) != 0 {
cp.RunID = vi.RunID
}
cp.FilterIDs = append(cp.FilterIDs, vi.FilterIDs...)
cp.AttributeIDs = append(cp.AttributeIDs, vi.AttributeIDs...)
if vi.Weight != 0 {
cp.Weight = vi.Weight
}
}