show more precise error download/copy/referencing messages

This commit is contained in:
Adrien Delorme 2018-08-16 18:41:44 +02:00
parent fae3db4e58
commit 2b3ea29970
1 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"log"
"strings"
"time"
"github.com/hashicorp/packer/helper/multistep"
@ -66,7 +67,7 @@ func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multiste
}
}
ui.Say(fmt.Sprintf("Downloading or copying %s", s.Description))
ui.Say(fmt.Sprintf("Downloading, copying or inplace referencing %s", s.Description))
// First try to use any already downloaded file
// If it fails, proceed to regular download logic
@ -99,6 +100,7 @@ func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multiste
Checksum: checksum,
UserAgent: useragent.String(),
}
downloadConfigs[i] = config
if match, _ := NewDownloadClient(config).VerifyChecksum(config.TargetPath); match {
@ -110,7 +112,11 @@ func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multiste
if finalPath == "" {
for i, url := range s.Url {
ui.Message(fmt.Sprintf("Downloading or copying: %s", url))
if strings.HasPrefix(url, "file://") {
ui.Message(fmt.Sprintf("Copying or inplace referencing: %s", url))
} else {
ui.Message(fmt.Sprintf("Downloading: %s", url))
}
config := downloadConfigs[i]