feat: make DHCP configurable per additional NIC (#143)#144
Merged
Conversation
Additional NICs were hardcoded to DHCP enabled, while the primary NIC honoured --ionoscloud-nic-dhcp. Add --ionoscloud-additional-nics-dhcp, a mapping of numeric LAN ID to true/false (e.g. 5=false), so DHCP can be controlled per additional NIC. Additional LANs absent from the map keep DHCP enabled, preserving the previous behaviour. The primary NIC is unaffected. Overrides for a LAN id that is not an attached additional NIC are logged and ignored. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new driver flag to control the IONOS CloudAPI NIC Dhcp property per additional NIC (keyed by numeric LAN ID), preserving the prior default behavior (additional NICs default to DHCP enabled) and leaving the primary NIC behavior unchanged.
Changes:
- Introduces
--ionoscloud-additional-nics-dhcpand parseslanId=true|falsemappings into driver config. - Applies the per-LAN DHCP override when creating additional NICs, and warns on overrides that don’t match any attached additional NIC.
- Adds unit tests for flag parsing and server creation behavior, and updates documentation/changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ionoscloud.go | Adds the new flag, driver field, and parsing logic for per-additional-NIC DHCP overrides. |
| ionos_create_machine.go | Applies DHCP overrides when building additional NICs and warns about unused overrides. |
| ionoscloud_test.go | Adds tests for parsing and creation-time behavior of the new DHCP override mapping. |
| docs/usage/options.md | Documents the new CLI flag and its environment variable. |
| docs/changelog.md | Notes the new feature in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tion Add two tests for --ionoscloud-additional-nics-dhcp: - TestCreateAdditionalNicDhcpOverrideIgnoredForUnattachedLan drives the warn-and-ignore branch in CreateIonosServer: an override keyed to a LAN id not among the attached additional NICs creates no NIC and is reported via log.Warnf, while the valid overrides still apply. - TestCreateAdditionalNicDhcpOverrideForLanAttachedByName covers the full flag-parse -> PreCreateCheck name-resolution -> NIC-build chain, proving a LAN attached by name resolves to its numeric id and the override keyed by that id is applied to the resulting NIC. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The flag/field is keyed by LAN id and belongs to the additional-LAN family (--ionoscloud-additional-lans, --ionoscloud-additional-lans-ids), not the unrelated AdditionalNicsIds field. Rename while the flag is still unreleased so there is no backward-compat cost: --ionoscloud-additional-nics-dhcp -> --ionoscloud-additional-lans-dhcp AdditionalNicsDhcp -> AdditionalLansDhcp IONOSCLOUD_ADDITIONAL_NICS_DHCP -> IONOSCLOUD_ADDITIONAL_LANS_DHCP Updates the flag, struct field, parsing, warning, docs, changelog and tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Match the project's existing DISK_TYPE:DISK_SIZE convention (--ionoscloud-additional-disks) instead of '='. Entries are now LAN_ID:DHCP (e.g. 5:false). Updates the parser separator, the three error messages, the flag usage text, docs, changelog and tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional NICs were hardcoded to DHCP enabled, while the primary NIC honoured --ionoscloud-nic-dhcp. Add --ionoscloud-additional-nics-dhcp, a mapping of numeric LAN ID to true/false (e.g. 5=false), so DHCP can be controlled per additional NIC.
Additional LANs absent from the map keep DHCP enabled, preserving the previous behaviour. The primary NIC is unaffected. Overrides for a LAN id that is not an attached additional NIC are logged and ignored.
What does this fix or implement?
implements #143
Checklist
feat:/fix:/doc:/test:/refactor:)