Move checkpoint into its own file to make it easy
This commit is contained in:
parent
1c380ea521
commit
806a8e0154
33
checkpoint.go
Normal file
33
checkpoint.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-checkpoint"
|
||||||
|
"github.com/mitchellh/packer/packer"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runCheckpoint(c *config) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = checkpoint.Check(&checkpoint.CheckParams{
|
||||||
|
Product: "packer",
|
||||||
|
Version: version,
|
||||||
|
SignatureFile: filepath.Join(configDir, "checkpoint_signature"),
|
||||||
|
CacheFile: filepath.Join(configDir, "checkpoint_cache"),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERR] Checkpoint error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
18
packer.go
18
packer.go
@ -10,7 +10,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/hashicorp/go-checkpoint"
|
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"github.com/mitchellh/packer/packer/plugin"
|
"github.com/mitchellh/packer/packer/plugin"
|
||||||
"github.com/mitchellh/panicwrap"
|
"github.com/mitchellh/panicwrap"
|
||||||
@ -95,23 +94,8 @@ func wrappedMain() int {
|
|||||||
}
|
}
|
||||||
log.Printf("Packer config: %+v", config)
|
log.Printf("Packer config: %+v", config)
|
||||||
|
|
||||||
configDir, err := ConfigDir()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "Error loading config dir: \n\n%s\n", err)
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire off the checkpoint.
|
// Fire off the checkpoint.
|
||||||
version := packer.Version
|
go runCheckpoint(config)
|
||||||
if packer.VersionPrerelease != "" {
|
|
||||||
version += fmt.Sprintf(".%s", packer.VersionPrerelease)
|
|
||||||
}
|
|
||||||
go checkpoint.Check(&checkpoint.CheckParams{
|
|
||||||
Product: "packer",
|
|
||||||
Version: version,
|
|
||||||
SignatureFile: filepath.Join(configDir, "checkpoint_signature"),
|
|
||||||
CacheFile: filepath.Join(configDir, "checkpoint_cache"),
|
|
||||||
})
|
|
||||||
|
|
||||||
cacheDir := os.Getenv("PACKER_CACHE_DIR")
|
cacheDir := os.Getenv("PACKER_CACHE_DIR")
|
||||||
if cacheDir == "" {
|
if cacheDir == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user