Commit d4fcbfaf authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Mechanisms to disable checkpoint

parent 806a8e01
...@@ -9,7 +9,14 @@ import ( ...@@ -9,7 +9,14 @@ import (
"github.com/mitchellh/packer/packer" "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) { func runCheckpoint(c *config) {
// If the user doesn't want checkpoint at all, then return.
if c.DisableCheckpoint {
return
}
configDir, err := ConfigDir() configDir, err := ConfigDir()
if err != nil { if err != nil {
log.Printf("[ERR] Checkpoint setup error: %s", err) log.Printf("[ERR] Checkpoint setup error: %s", err)
...@@ -21,10 +28,15 @@ func runCheckpoint(c *config) { ...@@ -21,10 +28,15 @@ func runCheckpoint(c *config) {
version += fmt.Sprintf(".%s", packer.VersionPrerelease) version += fmt.Sprintf(".%s", packer.VersionPrerelease)
} }
signaturePath := filepath.Join(configDir, "checkpoint_signature")
if c.DisableCheckpointSignature {
signaturePath = ""
}
_, err = checkpoint.Check(&checkpoint.CheckParams{ _, err = checkpoint.Check(&checkpoint.CheckParams{
Product: "packer", Product: "packer",
Version: version, Version: version,
SignatureFile: filepath.Join(configDir, "checkpoint_signature"), SignatureFile: signaturePath,
CacheFile: filepath.Join(configDir, "checkpoint_cache"), CacheFile: filepath.Join(configDir, "checkpoint_cache"),
}) })
if err != nil { if err != nil {
......
...@@ -14,8 +14,10 @@ import ( ...@@ -14,8 +14,10 @@ import (
) )
type config struct { type config struct {
PluginMinPort uint DisableCheckpoint bool `json:"disable_checkpoint"`
PluginMaxPort uint DisableCheckpointSignature bool `json:"disable_checkpoint_signature"`
PluginMinPort uint
PluginMaxPort uint
Builders map[string]string Builders map[string]string
Commands map[string]string Commands map[string]string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment