refactor: replace userdata_files with generic metadata_files map

Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
This commit is contained in:
Pratyush singhal 2019-06-06 16:14:57 +05:30
parent 3845186c4c
commit 1e1af35341
2 changed files with 5 additions and 4 deletions

View File

@ -62,7 +62,7 @@ type Config struct {
Subnetwork string `mapstructure:"subnetwork"`
Tags []string `mapstructure:"tags"`
UseInternalIP bool `mapstructure:"use_internal_ip"`
UserdataFile string `mapstructure:"userdata_file"`
MetadataFiles map[string]string `mapstructure:"metadata_files"`
Zone string `mapstructure:"zone"`
Account AccountFile

View File

@ -45,10 +45,11 @@ func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string)
instanceMetadata[StartupWrappedScriptKey] = wrappedStartupScript
}
if c.UserdataFile != "" {
// Read metadata from files specified with metadata_files
for key, value := range c.MetadataFiles {
var content []byte
content, err = ioutil.ReadFile(c.UserdataFile)
instanceMetadata["user-data"] = string(content)
content, err = ioutil.ReadFile(value)
instanceMetadata[key] = string(content)
}
if sourceImage.IsWindows() {