From b7f62517b2068aeb8bb996d64c4547777973370f Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Fri, 22 Nov 2024 18:44:12 -0700 Subject: [PATCH] Reorganize where the gating of static IPAM occurs: This moves the gating to the constructing of the kernel parameters and makes it explicit to whether ipam is included or not. Signed-off-by: Jacob Weinstock --- internal/iso/iso.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/iso/iso.go b/internal/iso/iso.go index 62d91861..98b3a769 100644 --- a/internal/iso/iso.go +++ b/internal/iso/iso.go @@ -258,15 +258,18 @@ func (h *Handler) constructPatch(console, mac string, d *data.DHCP) string { tinkerbellTLS := fmt.Sprintf("tinkerbell_tls=%v", h.TinkServerTLS) workerID := fmt.Sprintf("worker_id=%s", mac) vlanID := func() string { - if d != nil { + if d != nil && d.VLANID != "" { return fmt.Sprintf("vlan_id=%s", d.VLANID) } return "" }() hwAddr := fmt.Sprintf("hw_addr=%s", mac) - ipam := parseIPAM(d) + all := []string{strings.Join(h.ExtraKernelParams, " "), console, vlanID, hwAddr, syslogHost, grpcAuthority, tinkerbellTLS, workerID} + if h.StaticIPAMEnabled { + all = append(all, parseIPAM(d)) + } - return strings.Join([]string{strings.Join(h.ExtraKernelParams, " "), console, vlanID, hwAddr, syslogHost, grpcAuthority, tinkerbellTLS, workerID, ipam}, " ") + return strings.Join(all, " ") } func getMAC(urlPath string) (net.HardwareAddr, error) { @@ -288,9 +291,6 @@ func (h *Handler) getFacility(ctx context.Context, mac net.HardwareAddr, br Back if err != nil { return "", nil, err } - if !h.StaticIPAMEnabled { - d = nil - } return n.Facility, d, nil }