StepDownload uses packer version as user agent

This commit is contained in:
Mark Rushakoff 2014-01-09 13:20:30 -08:00
parent 9e5c0f6c6a
commit 4548495116
2 changed files with 11 additions and 6 deletions

View File

@ -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)

View File

@ -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()
}