Use bundled bugsnag APIKey

Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
Jean-Laurent de Morlhon 2015-12-11 11:45:17 +01:00
parent 5dadfe093d
commit a8ba712286
2 changed files with 10 additions and 17 deletions

View File

@ -19,38 +19,30 @@ import (
"github.com/docker/machine/version" "github.com/docker/machine/version"
) )
// We bundle a bugnsag key, but we disable its usage for now const (
// this ease testing just set useDefaultKey to true defaultAPIKey = "a9697f9a010c33ee218a65e5b1f3b0c1"
// and yet we bundle the code without activating it by default. noreportAPIKey = "no-report"
var useDefaultKey = false )
const defaultAPIKey = "a9697f9a010c33ee218a65e5b1f3b0c1"
var apiKey string var apiKey string
// Configure the apikey for bugnag // Configure the apikey for bugnag
func Configure(key string) { func Configure(key string) {
apiKey = defaultAPIKey
if key != "" { if key != "" {
apiKey = key apiKey = key
return
}
if useDefaultKey {
apiKey = defaultAPIKey
} }
} }
// Send through http the crash report to bugsnag need a call to Configure(apiKey) before // Send through http the crash report to bugsnag need a call to Configure(apiKey) before
func Send(err error, context string, driverName string, command string) error { func Send(err error, context string, driverName string, command string) error {
if noReportFileExist() { if noReportFileExist() || apiKey == noreportAPIKey {
err := errors.New("Not sending report since the optout file exist.") log.Debug("Opting out of crash reporting.")
log.Debug(err) return nil
return err
} }
if apiKey == "" { if apiKey == "" {
err := errors.New("Not sending report since no api key has been set.") return errors.New("Not sending report since no api key has been set.")
log.Debug(err)
return err
} }
bugsnag.Configure(bugsnag.Configuration{ bugsnag.Configure(bugsnag.Configuration{

View File

@ -93,6 +93,7 @@ export MACHINE_BIN_NAME=docker-machine
export BATS_LOG="$MACHINE_ROOT/bats.log" export BATS_LOG="$MACHINE_ROOT/bats.log"
export B2D_LOCATION=~/.docker/machine/cache/boot2docker.iso export B2D_LOCATION=~/.docker/machine/cache/boot2docker.iso
export SHARED_NAME="bats-$DRIVER-test-shared-$(date +%s)" export SHARED_NAME="bats-$DRIVER-test-shared-$(date +%s)"
export MACHINE_BUGSNAG_API_TOKEN=no-report
# This function gets used in the integration tests, so export it. # This function gets used in the integration tests, so export it.
export -f machine export -f machine