feature: add create tags to volume

This commit is contained in:
Marin Salinas 2019-03-06 14:54:23 -06:00 committed by Megan Marsh
parent db2832d80c
commit 8b8eb70e19
1 changed files with 7 additions and 25 deletions

View File

@ -34,26 +34,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
var err error
//TODO: Add tags
// volTags, err := s.RootVolumeTags.OAPITags(s.Ctx, oapiconn.GetConfig().Region, state)
// if err != nil {
// err := fmt.Errorf("Error tagging volumes: %s", err)
// state.Put("error", err)
// ui.Error(err.Error())
// return multistep.ActionHalt
// }
// // Collect tags for tagging on resource creation
// var tagSpecs []oapi.ResourceTag
// if len(volTags) > 0 {
// runVolTags := &oapi.Resou rceTag{
// ResourceType: "volume",
// Tags: volTags,
// }
// tagSpecs = append(tagSpecs, runVolTags)
// }
volTags, err := s.RootVolumeTags.OAPITags(s.Ctx, oapiconn.GetConfig().Region, state)
var createVolume *oapi.CreateVolumeRequest
if config.FromScratch {
@ -92,11 +73,7 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
return multistep.ActionHalt
}
}
//TODO: ADD TAGS
// if len(tagSpecs) > 0 {
// createVolume.SetTagSpecifications(tagSpecs)
// volTags.Report(ui)
// }
log.Printf("Create args: %+v", createVolume)
createVolumeResp, err := oapiconn.POST_CreateVolume(*createVolume)
@ -111,6 +88,11 @@ func (s *StepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu
s.volumeId = createVolumeResp.OK.Volume.VolumeId
log.Printf("Volume ID: %s", s.volumeId)
//Create tags for volume
if len(volTags) > 0 {
osccommon.CreateTags(oapiconn, s.volumeId, ui, volTags)
}
// Wait for the volume to become ready
err = osccommon.WaitUntilVolumeAvailable(oapiconn, s.volumeId)
if err != nil {