builder/openstack: Fix interface conversion panic when attempting to find a volume when not using volumes

This commit is contained in:
Marek Winkler 2019-10-02 22:16:18 +02:00
parent 7e6f58f699
commit 0bd256326f
1 changed files with 12 additions and 10 deletions

View File

@ -92,16 +92,18 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul
return multistep.ActionHalt return multistep.ActionHalt
} }
volume := state.Get("volume_id").(string) if s.UseBlockStorageVolume {
if len(config.ImageMetadata) > 0 && s.UseBlockStorageVolume { volume := state.Get("volume_id").(string)
err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{ if len(config.ImageMetadata) > 0 {
Metadata: config.ImageMetadata, err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{
}).ExtractErr() Metadata: config.ImageMetadata,
if err != nil { }).ExtractErr()
err := fmt.Errorf("Error setting image metadata: %s", err) if err != nil {
state.Put("error", err) err := fmt.Errorf("Error setting image metadata: %s", err)
ui.Error(err.Error()) state.Put("error", err)
return multistep.ActionHalt ui.Error(err.Error())
return multistep.ActionHalt
}
} }
} }