Add recursive setter functions

when transforming a NodeInfo struct to a NodeConf (set the NodeConf from
the NodeInfo) nested structures were seperately handled. This means a
there were seperate handles for e.g *Netdevs and *IpmiConfig. The new
getter traverses through the datastucture and sets the right value for a
Entry struct, but calls itself again if a Pointer is detected.

This adds the posiblity to add new nested structures to NodeConf and
NodeInfo without the need of seperately handling them in the transformer
functions.

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-08-11 09:44:28 -06:00
committed by Jonathon Anderson
parent fdd233a25f
commit c55c5a2ac4
4 changed files with 88 additions and 180 deletions

View File

@@ -166,7 +166,7 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.SetFrom(node)
// only now the netdevs start to exist so that default values can be set
for _, netdev := range n.NetDevs {
netdev.SetDefFrom(defConfNet)
SetDefFrom(defConfNet, netdev)
}
// backward compatibility
n.Ipmi.Ipaddr.Set(node.IpmiIpaddr)