Merge pull request #7526 from aleksey-hariton/master

Add tags to instance in CloudStack builder
This commit is contained in:
Adrien Delorme 2019-06-04 10:13:42 +02:00 committed by GitHub
commit 936ca6545a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -59,6 +59,8 @@ type Config struct {
TemplateScalable bool `mapstructure:"template_scalable"`
TemplateTag string `mapstructure:"template_tag"`
Tags map[string]string `mapstructure:"tags"`
ctx interpolate.Context
}

View File

@ -149,6 +149,20 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
// Store the instance ID so we can remove it later.
state.Put("instance_id", instance.Id)
// Set instance tags
if len(config.Tags) > 0 {
resourceID := []string{instance.Id}
tp := client.Resourcetags.NewCreateTagsParams(resourceID, "UserVm", config.Tags)
_, err = client.Resourcetags.CreateTags(tp)
if err != nil {
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}
return multistep.ActionContinue
}