mirror of
https://github.com/rancher/os.git
synced 2025-09-24 20:09:21 +00:00
Refactor the cloud-init metadata to return a netconf.NetworkConfig
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/os/netconf"
|
||||
|
||||
"github.com/rancher/os/config/cloudinit/datasource"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/metadata"
|
||||
)
|
||||
@@ -72,6 +74,22 @@ func (ms MetadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
SSHPublicKeys: nil,
|
||||
}
|
||||
|
||||
addresses := []string{}
|
||||
if public != nil {
|
||||
addresses = append(addresses, public.String())
|
||||
}
|
||||
if local != nil {
|
||||
addresses = append(addresses, local.String())
|
||||
}
|
||||
if len(addresses) > 0 {
|
||||
network := netconf.InterfaceConfig{
|
||||
Addresses: addresses,
|
||||
}
|
||||
|
||||
md.NetworkConfig.Interfaces = make(map[string]netconf.InterfaceConfig)
|
||||
md.NetworkConfig.Interfaces["eth0"] = network
|
||||
}
|
||||
|
||||
keyStrings := strings.Split(projectSSHKeys+"\n"+instanceSSHKeys, "\n")
|
||||
|
||||
i := 0
|
||||
|
Reference in New Issue
Block a user