Add recursive getter functions

When transforming a NodeConf struct to a NodeInfo (get the NodeInfo from
the Nodconf) nested structures were seperately handled. This means there
were seperate handles for e.g *Netdevs and *IpmiConfig. The new getter
traverses through the datastucture and sets the right value for an 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 seperate handling them in the transformer
functions.

Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
Christian Goll
2023-08-11 08:00:00 -06:00
committed by Jonathon Anderson
parent f2bc70ad00
commit fdd233a25f
2 changed files with 63 additions and 166 deletions

View File

@@ -299,13 +299,14 @@ ipmi: {}
t.Errorf("Got wrong yml, wanted:\n'%s'\nGot:\n'%s'", wanted, string(ymlByte))
}
delete(test_node4.Tags, "foo")
nodeConf = NewConf()
nodeConf.GetFrom(test_node4)
nodeConf.Flatten()
ymlByte, _ = yaml.Marshal(nodeConf)
wanted = `{}
`
if string(ymlByte) != wanted {
t.Errorf("Couldn't remove tag'%s'", string(ymlByte))
t.Errorf("Couldn't remove tag, wanted:\n%s\nGot:\n%s", wanted, string(ymlByte))
}
})