feat: add network interface handling to metadata generation and tests #88
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.
This pull request adds comprehensive support for exposing all network interfaces of a node in the metadata output for the cloud-init server. It introduces a new
NetworkInterfacesfield in the metadata, updates the metadata generation logic to collect interface data from the SMD client, and provides thorough testing to ensure values with spaces are handled correctly and that multiple interfaces are supported. The SMD client interface and its implementations are extended to support retrieving all network interfaces for a node.Enhancements to metadata output:
NetworkInterfacesfield to theVendorDatastruct, and a newNetworkInterfacestruct to represent MAC, IP, WGIP, and description for each interface. ThegenerateMetaDatafunction now populates this field using the SMD client. (cmd/cloud-init-server/metadata.go[1] [2]MetaDataHandlerto pass the SMD client togenerateMetaData, ensuring network interfaces are included in the response. (cmd/cloud-init-server/metadata_handlers.gocmd/cloud-init-server/metadata_handlers.goL94-R94)SMD client interface and implementation updates:
SMDClientInterfaceto include aGetNodeInterfacesmethod, and implemented this method in both the real and fake SMD clients to return all interfaces for a given node. (internal/smdclient/SMDclient.go[1] [2];internal/smdclient/FakeSMDClient.go[3]Testing improvements:
network_interfaces_test.goto verify that all network interfaces are included in the metadata, and that the structure supports multiple interfaces. (cmd/cloud-init-server/network_interfaces_test.gocmd/cloud-init-server/network_interfaces_test.goR1-R106)comprehensive_metadata_test.goto test the complete metadata output, including network interfaces and proper handling of values with spaces (ensuring they are not split across lines in YAML). (cmd/cloud-init-server/comprehensive_metadata_test.gocmd/cloud-init-server/comprehensive_metadata_test.goR1-R210)These changes ensure that the metadata provided to clients is more complete and robust, especially for environments with multiple network interfaces per node.