refactor: replace userdata_files with generic metadata_files map
Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
This commit is contained in:
parent
3845186c4c
commit
1e1af35341
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue