feat: add feature to import user-data from a file
Signed-off-by: Pratyush singhal <psinghal20@gmail.com>
This commit is contained in:
parent
2620e18247
commit
3845186c4c
|
@ -62,6 +62,7 @@ type Config struct {
|
|||
Subnetwork string `mapstructure:"subnetwork"`
|
||||
Tags []string `mapstructure:"tags"`
|
||||
UseInternalIP bool `mapstructure:"use_internal_ip"`
|
||||
UserdataFile string `mapstructure:"userdata_file"`
|
||||
Zone string `mapstructure:"zone"`
|
||||
|
||||
Account AccountFile
|
||||
|
|
|
@ -19,7 +19,6 @@ type StepCreateInstance struct {
|
|||
func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string) (map[string]string, error) {
|
||||
instanceMetadata := make(map[string]string)
|
||||
var err error
|
||||
|
||||
// Copy metadata from config.
|
||||
for k, v := range c.Metadata {
|
||||
instanceMetadata[k] = v
|
||||
|
@ -45,6 +44,13 @@ func (c *Config) createInstanceMetadata(sourceImage *Image, sshPublicKey string)
|
|||
} else if wrappedStartupScript, exists := instanceMetadata[StartupScriptKey]; exists {
|
||||
instanceMetadata[StartupWrappedScriptKey] = wrappedStartupScript
|
||||
}
|
||||
|
||||
if c.UserdataFile != "" {
|
||||
var content []byte
|
||||
content, err = ioutil.ReadFile(c.UserdataFile)
|
||||
instanceMetadata["user-data"] = string(content)
|
||||
}
|
||||
|
||||
if sourceImage.IsWindows() {
|
||||
// Windows startup script support is not yet implemented.
|
||||
// Mark the startup script as done.
|
||||
|
|
Loading…
Reference in New Issue