From ae1bb856a31d0e0846b4dce3db38850831470e90 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Tue, 1 Oct 2019 21:14:15 -0400 Subject: [PATCH] digitalocean-import: Fix panic when 'image_regions' not set (Fixes: #7843). --- post-processor/digitalocean-import/post-processor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/post-processor/digitalocean-import/post-processor.go b/post-processor/digitalocean-import/post-processor.go index e20ea2380..80e1d13a8 100644 --- a/post-processor/digitalocean-import/post-processor.go +++ b/post-processor/digitalocean-import/post-processor.go @@ -119,7 +119,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { "spaces_region": &p.config.SpacesRegion, "space_name": &p.config.SpaceName, "image_name": &p.config.Name, - "image_regions": &p.config.ImageRegions[0], } for key, ptr := range requiredArgs { if *ptr == "" { @@ -128,6 +127,11 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } } + if len(p.config.ImageRegions) == 0 { + errs = packer.MultiErrorAppend( + errs, fmt.Errorf("image_regions must be set")) + } + if len(errs.Errors) > 0 { return errs }