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
}
volume := state.Get("volume_id").(string)
if len(config.ImageMetadata) > 0 && s.UseBlockStorageVolume {
err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{
Metadata: config.ImageMetadata,
}).ExtractErr()
if err != nil {
err := fmt.Errorf("Error setting image metadata: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
if s.UseBlockStorageVolume {
volume := state.Get("volume_id").(string)
if len(config.ImageMetadata) > 0 {
err = volumeactions.SetImageMetadata(blockStorageClient, volume, volumeactions.ImageMetadataOpts{
Metadata: config.ImageMetadata,
}).ExtractErr()
if err != nil {
err := fmt.Errorf("Error setting image metadata: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}
}