metadata: simplify merging of metadata
Add an internal field for CloudConfig to make it easier to distinguish. Instead of creating two CloudConfigs and merging them, just merge the metadata into the existing CloudConfig.
This commit is contained in:
@@ -170,9 +170,9 @@ func Apply(cfg config.CloudConfig, env *Environment) error {
|
||||
var err error
|
||||
switch env.NetconfType() {
|
||||
case "debian":
|
||||
interfaces, err = network.ProcessDebianNetconf(cfg.NetworkConfig)
|
||||
interfaces, err = network.ProcessDebianNetconf(cfg.Internal.NetworkConfig)
|
||||
case "digitalocean":
|
||||
interfaces, err = network.ProcessDigitalOceanNetconf(cfg.NetworkConfig)
|
||||
interfaces, err = network.ProcessDigitalOceanNetconf(cfg.Internal.NetworkConfig)
|
||||
default:
|
||||
err = fmt.Errorf("Unsupported network config format %q", env.NetconfType())
|
||||
}
|
||||
|
@@ -17,25 +17,9 @@ package initialize
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/coreos/coreos-cloudinit/config"
|
||||
"github.com/coreos/coreos-cloudinit/datasource"
|
||||
)
|
||||
|
||||
// ParseMetaData parses a JSON blob in the OpenStack metadata service format,
|
||||
// and converts it to a partially hydrated CloudConfig.
|
||||
func ParseMetaData(metadata datasource.Metadata) *config.CloudConfig {
|
||||
var cfg config.CloudConfig
|
||||
if len(metadata.SSHPublicKeys) > 0 {
|
||||
cfg.SSHAuthorizedKeys = make([]string, 0, len(metadata.SSHPublicKeys))
|
||||
for _, name := range sortedKeys(metadata.SSHPublicKeys) {
|
||||
cfg.SSHAuthorizedKeys = append(cfg.SSHAuthorizedKeys, metadata.SSHPublicKeys[name])
|
||||
}
|
||||
}
|
||||
cfg.Hostname = metadata.Hostname
|
||||
cfg.NetworkConfigPath = metadata.NetworkConfigPath
|
||||
return &cfg
|
||||
}
|
||||
|
||||
// ExtractIPsFromMetaData parses a JSON blob in the OpenStack metadata service
|
||||
// format and returns a substitution map possibly containing private_ipv4,
|
||||
// public_ipv4, private_ipv6, and public_ipv6 addresses.
|
||||
|
Reference in New Issue
Block a user