From af09ebbe4e1b0ac3838bc69d598d8f106094c468 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Wed, 6 Jan 2016 11:08:14 +0100 Subject: [PATCH] This code is only useful to crash reports Signed-off-by: David Gageot --- libmachine/crashreport/crash_report.go | 3 +-- libmachine/{mcnutils => crashreport}/os_darwin.go | 4 ++-- libmachine/{mcnutils => crashreport}/os_linux.go | 4 ++-- libmachine/{mcnutils => crashreport}/os_windows.go | 4 ++-- libmachine/{mcnutils => crashreport}/os_windows_test.go | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) rename libmachine/{mcnutils => crashreport}/os_darwin.go (79%) rename libmachine/{mcnutils => crashreport}/os_linux.go (80%) rename libmachine/{mcnutils => crashreport}/os_windows.go (92%) rename libmachine/{mcnutils => crashreport}/os_windows_test.go (97%) diff --git a/libmachine/crashreport/crash_report.go b/libmachine/crashreport/crash_report.go index e816ef3b51..de49e40f1a 100644 --- a/libmachine/crashreport/crash_report.go +++ b/libmachine/crashreport/crash_report.go @@ -17,7 +17,6 @@ import ( "github.com/bugsnag/bugsnag-go" "github.com/docker/machine/libmachine/log" - "github.com/docker/machine/libmachine/mcnutils" "github.com/docker/machine/version" ) @@ -146,5 +145,5 @@ func detectUname(metaData *bugsnag.MetaData) { } func detectOSVersion(metaData *bugsnag.MetaData) { - metaData.Add("device", "os version", mcnutils.LocalOSVersion()) + metaData.Add("device", "os version", localOSVersion()) } diff --git a/libmachine/mcnutils/os_darwin.go b/libmachine/crashreport/os_darwin.go similarity index 79% rename from libmachine/mcnutils/os_darwin.go rename to libmachine/crashreport/os_darwin.go index 8de0bdc3d2..2e887e4d10 100644 --- a/libmachine/mcnutils/os_darwin.go +++ b/libmachine/crashreport/os_darwin.go @@ -1,8 +1,8 @@ -package mcnutils +package crashreport import "os/exec" -func LocalOSVersion() string { +func localOSVersion() string { command := exec.Command("bash", "-c", `sw_vers | grep ProductVersion | cut -d$'\t' -f2`) output, err := command.Output() if err != nil { diff --git a/libmachine/mcnutils/os_linux.go b/libmachine/crashreport/os_linux.go similarity index 80% rename from libmachine/mcnutils/os_linux.go rename to libmachine/crashreport/os_linux.go index 0c869f0c5e..31b72a89b0 100644 --- a/libmachine/mcnutils/os_linux.go +++ b/libmachine/crashreport/os_linux.go @@ -1,8 +1,8 @@ -package mcnutils +package crashreport import "os/exec" -func LocalOSVersion() string { +func localOSVersion() string { command := exec.Command("bash", "-c", `cat /etc/os-release | grep 'VERSION=' | cut -d'=' -f2`) output, err := command.Output() if err != nil { diff --git a/libmachine/mcnutils/os_windows.go b/libmachine/crashreport/os_windows.go similarity index 92% rename from libmachine/mcnutils/os_windows.go rename to libmachine/crashreport/os_windows.go index 03cf004ef1..da60e9c969 100644 --- a/libmachine/mcnutils/os_windows.go +++ b/libmachine/crashreport/os_windows.go @@ -1,11 +1,11 @@ -package mcnutils +package crashreport import ( "os/exec" "strings" ) -func LocalOSVersion() string { +func localOSVersion() string { command := exec.Command("ver") output, err := command.Output() if err == nil { diff --git a/libmachine/mcnutils/os_windows_test.go b/libmachine/crashreport/os_windows_test.go similarity index 97% rename from libmachine/mcnutils/os_windows_test.go rename to libmachine/crashreport/os_windows_test.go index a794d5f803..e20b2c7174 100644 --- a/libmachine/mcnutils/os_windows_test.go +++ b/libmachine/crashreport/os_windows_test.go @@ -1,4 +1,4 @@ -package mcnutils +package crashreport import ( "testing"