From 0bd256326fb5aebf98c98682c13ba0a4d16a1c16 Mon Sep 17 00:00:00 2001 From: Marek Winkler Date: Wed, 2 Oct 2019 22:16:18 +0200 Subject: [PATCH] builder/openstack: Fix interface conversion panic when attempting to find a volume when not using volumes --- builder/openstack/step_create_image.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/builder/openstack/step_create_image.go b/builder/openstack/step_create_image.go index 1b8b02b9e..d70527c31 100644 --- a/builder/openstack/step_create_image.go +++ b/builder/openstack/step_create_image.go @@ -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 + } } }