Include arch and os
This commit is contained in:
parent
b17b333e29
commit
b193b96f76
|
@ -14,6 +14,12 @@ var (
|
||||||
// rt is the runtime - variable for tests.
|
// rt is the runtime - variable for tests.
|
||||||
rt = runtime.Version()
|
rt = runtime.Version()
|
||||||
|
|
||||||
|
// goos is the os - variable for tests.
|
||||||
|
goos = runtime.GOOS
|
||||||
|
|
||||||
|
// goarch is the architecture - variable for tests.
|
||||||
|
goarch = runtime.GOARCH
|
||||||
|
|
||||||
// versionFunc is the func that returns the current version. This is a
|
// versionFunc is the func that returns the current version. This is a
|
||||||
// function to take into account the different build processes and distinguish
|
// function to take into account the different build processes and distinguish
|
||||||
// between enterprise and oss builds.
|
// between enterprise and oss builds.
|
||||||
|
@ -24,6 +30,6 @@ var (
|
||||||
|
|
||||||
// String returns the consistent user-agent string for Packer.
|
// String returns the consistent user-agent string for Packer.
|
||||||
func String() string {
|
func String() string {
|
||||||
return fmt.Sprintf("Packer/%s (+%s; %s)",
|
return fmt.Sprintf("Packer/%s (+%s; %s; %s/%s)",
|
||||||
versionFunc(), projectURL, rt)
|
versionFunc(), projectURL, rt, goos, goarch)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,13 @@ import (
|
||||||
func TestUserAgent(t *testing.T) {
|
func TestUserAgent(t *testing.T) {
|
||||||
projectURL = "https://packer-test.com"
|
projectURL = "https://packer-test.com"
|
||||||
rt = "go5.0"
|
rt = "go5.0"
|
||||||
|
goos = "linux"
|
||||||
|
goarch = "amd64"
|
||||||
versionFunc = func() string { return "1.2.3" }
|
versionFunc = func() string { return "1.2.3" }
|
||||||
|
|
||||||
act := String()
|
act := String()
|
||||||
|
|
||||||
exp := "Packer/1.2.3 (+https://packer-test.com; go5.0)"
|
exp := "Packer/1.2.3 (+https://packer-test.com; go5.0; linux/amd64)"
|
||||||
if exp != act {
|
if exp != act {
|
||||||
t.Errorf("expected %q to be %q", act, exp)
|
t.Errorf("expected %q to be %q", act, exp)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue