Expand nodes when rendering overlay templates

Before #1628, all default constructors for nodes and profiles attempted to
construct objects with pre-populated empty fields (e.g., for pointers to member
structs and for collections that default to nil). Changes to MergeNode in #1629
changed this behavior intentionally to simplify the generation of minimal json;
but this had the unintended side-effect of breaking existing templates that may
now encounter a nil pointer, particularly when accessing member structs.

Introduced here, the Expand() methods on Node and Profile are now responsible
for populating such fields, and Node.Expand() is now called during template
processing.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-19 04:26:01 -07:00
parent 96396ed47e
commit 57d28c5bc9
5 changed files with 119 additions and 13 deletions

View File

@@ -259,6 +259,16 @@ data from other structures.
- Version:
- Args: quiet crashkernel=no vga=791 net.naming-scheme=v238
- Ipmi:
- Ipaddr: <nil>
- Netmask: <nil>
- Port:
- Gateway: <nil>
- UserName:
- Password:
- Interface:
- Write:
- Tags:
- NetDevs[default]:
- Type:
- OnBoot: true