diff --git a/common/step_download.go b/common/step_download.go index 4bf44eb5a..34156d52d 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -70,6 +70,7 @@ func (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction { CopyFile: false, Hash: HashForType(s.ChecksumType), Checksum: checksum, + UserAgent: packer.VersionString(), } path, err, retry := s.download(config, state) diff --git a/packer/version.go b/packer/version.go index 73c9f3018..dea8eb822 100644 --- a/packer/version.go +++ b/packer/version.go @@ -31,6 +31,15 @@ func (versionCommand) Run(env Environment, args []string) int { env.Ui().Machine("version-prelease", VersionPrerelease) env.Ui().Machine("version-commit", GitCommit) + env.Ui().Say(VersionString()) + return 0 +} + +func (versionCommand) Synopsis() string { + return "print Packer version" +} + +func VersionString() string { var versionString bytes.Buffer fmt.Fprintf(&versionString, "Packer v%s", Version) if VersionPrerelease != "" { @@ -41,10 +50,5 @@ func (versionCommand) Run(env Environment, args []string) int { } } - env.Ui().Say(versionString.String()) - return 0 -} - -func (versionCommand) Synopsis() string { - return "print Packer version" + return versionString.String() }