ips: prepend options instead of append

to ensure default options are at the end. Otherwise, they would
always match first.
This commit is contained in:
ionutboangiu
2025-05-30 18:00:44 +03:00
committed by Dan Christian Bogos
parent 9812e6f605
commit 9ee93ed879

View File

@@ -184,26 +184,29 @@ func (o *IPsOpts) loadFromJSONCfg(jc *IPsOptsJson) error {
if jc == nil {
return nil
}
// NOTE: prepend to the existing slice to ensure that the default opts that
// always match are at the end.
if jc.UsageID != nil {
usageID, err := InterfaceToDynamicStringOpts(jc.UsageID)
if err != nil {
return err
}
o.UsageID = append(o.UsageID, usageID...)
o.UsageID = append(usageID, o.UsageID...)
}
if jc.TTL != nil {
ttl, err := IfaceToDurationDynamicOpts(jc.TTL)
if err != nil {
return err
}
o.TTL = append(o.TTL, ttl...)
o.TTL = append(ttl, o.TTL...)
}
if jc.Units != nil {
units, err := InterfaceToFloat64DynamicOpts(jc.Units)
if err != nil {
return err
}
o.Units = append(o.Units, units...)
o.Units = append(units, o.Units...)
}
return nil
}