From 4dc12701d3a045b3d07f5df7c41cb5097984b46b Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 15 Apr 2019 14:22:31 +0200 Subject: [PATCH 1/2] step_download: display clearer error messages, also when the checksum is not set Usually the builder validation should error when the checksum is empty, but for the virtualbox-ovf builder this is not validated. Which is something I didn't see when refactoring for go-getter incorporation/refactor. --- common/step_download.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/step_download.go b/common/step_download.go index 2310d0311..39d82964d 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -82,7 +82,9 @@ func (s *StepDownload) Run(ctx context.Context, state multistep.StateBag) multis errs = append(errs, err) } - state.Put("error", fmt.Errorf("Downloading file: %v", errs)) + err := fmt.Errorf("error downloading %s: %v", s.Description, errs) + state.Put("error", err) + ui.Error(err.Error()) return multistep.ActionHalt } @@ -104,7 +106,7 @@ func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string q.Set("checksum", s.Checksum) u.RawQuery = q.Encode() } else if s.ChecksumType != "none" { - return "", fmt.Errorf("Empty checksum") + return "", fmt.Errorf("empty checksum, a checksum or a 'none' checksum type must be set") } targetPath := s.TargetPath From a78970c029a7109b3ffae1ea867a8c1c58897cb9 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 15 Apr 2019 15:29:41 +0200 Subject: [PATCH 2/2] virtualbox-ovf: also document that the checksum field is now mandatory --- .../source/docs/builders/virtualbox-ovf.html.md.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/website/source/docs/builders/virtualbox-ovf.html.md.erb b/website/source/docs/builders/virtualbox-ovf.html.md.erb index e42198b4d..e64b9a886 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.md.erb +++ b/website/source/docs/builders/virtualbox-ovf.html.md.erb @@ -67,6 +67,13 @@ builder. - `source_path` (string) - The path to an OVF or OVA file that acts as the source of this build. It can also be a URL. +- `checksum` (string) - The checksum for the `source_path` file. The + algorithm to use when computing the checksum can be optionally specified + with `checksum_type`. When `checksum_type` is not set packer will guess the + checksumming type based on `checksum` length. `checksum` can be also be a + file or an URL, in which case `checksum_type` must be set to `file`; the + go-getter will download it and use the first hash found. + ### Optional: - `boot_command` (array of strings) - This is an array of commands to type @@ -82,9 +89,6 @@ builder. five seconds and one minute 30 seconds, respectively. If this isn't specified, the default is `10s` or 10 seconds. -- `checksum` (string) - The checksum for the OVA file. The type of the - checksum is specified with `checksum_type`, documented below. - - `checksum_type` (string) - The type of the checksum specified in `checksum`. Valid values are `none`, `md5`, `sha1`, `sha256`, or `sha512`. Although the checksum will not be verified when `checksum_type` is set to "none", this is