From d4fcbfafa8be272aa671c10339af01ba16767a48 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 8 Sep 2014 14:20:13 -0700 Subject: [PATCH] Mechanisms to disable checkpoint --- checkpoint.go | 14 +++++++++++++- config.go | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/checkpoint.go b/checkpoint.go index 9ad587f23..dcd567274 100644 --- a/checkpoint.go +++ b/checkpoint.go @@ -9,7 +9,14 @@ import ( "github.com/mitchellh/packer/packer" ) +// runCheckpoint runs a HashiCorp Checkpoint request. You can read about +// Checkpoint here: https://github.com/hashicorp/go-checkpoint. func runCheckpoint(c *config) { + // If the user doesn't want checkpoint at all, then return. + if c.DisableCheckpoint { + return + } + configDir, err := ConfigDir() if err != nil { log.Printf("[ERR] Checkpoint setup error: %s", err) @@ -21,10 +28,15 @@ func runCheckpoint(c *config) { version += fmt.Sprintf(".%s", packer.VersionPrerelease) } + signaturePath := filepath.Join(configDir, "checkpoint_signature") + if c.DisableCheckpointSignature { + signaturePath = "" + } + _, err = checkpoint.Check(&checkpoint.CheckParams{ Product: "packer", Version: version, - SignatureFile: filepath.Join(configDir, "checkpoint_signature"), + SignatureFile: signaturePath, CacheFile: filepath.Join(configDir, "checkpoint_cache"), }) if err != nil { diff --git a/config.go b/config.go index 5df96e453..05295646e 100644 --- a/config.go +++ b/config.go @@ -14,8 +14,10 @@ import ( ) type config struct { - PluginMinPort uint - PluginMaxPort uint + DisableCheckpoint bool `json:"disable_checkpoint"` + DisableCheckpointSignature bool `json:"disable_checkpoint_signature"` + PluginMinPort uint + PluginMaxPort uint Builders map[string]string Commands map[string]string