packer-cn/checkpoint.go

46 lines
1.0 KiB
Go
Raw Normal View History

package main
import (
"fmt"
"log"
"path/filepath"
"github.com/hashicorp/go-checkpoint"
"github.com/mitchellh/packer/packer"
)
2014-09-08 17:20:13 -04:00
// runCheckpoint runs a HashiCorp Checkpoint request. You can read about
// Checkpoint here: https://github.com/hashicorp/go-checkpoint.
func runCheckpoint(c *config) {
2014-09-08 17:20:13 -04:00
// 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)
return
}
version := packer.Version
if packer.VersionPrerelease != "" {
version += fmt.Sprintf(".%s", packer.VersionPrerelease)
}
2014-09-08 17:20:13 -04:00
signaturePath := filepath.Join(configDir, "checkpoint_signature")
if c.DisableCheckpointSignature {
signaturePath = ""
}
_, err = checkpoint.Check(&checkpoint.CheckParams{
Product: "packer",
Version: version,
2014-09-08 17:20:13 -04:00
SignatureFile: signaturePath,
CacheFile: filepath.Join(configDir, "checkpoint_cache"),
})
if err != nil {
log.Printf("[ERR] Checkpoint error: %s", err)
}
}