Move ConfigFile() and ConfigDir() from package main to packer
This commit is contained in:
parent
82a7f6ef97
commit
38c81cf3e3
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/go-checkpoint"
|
||||
"github.com/mitchellh/packer/command"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -25,7 +26,7 @@ func runCheckpoint(c *config) {
|
|||
return
|
||||
}
|
||||
|
||||
configDir, err := ConfigDir()
|
||||
configDir, err := packer.ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERR] Checkpoint setup error: %s", err)
|
||||
checkpointResult <- nil
|
||||
|
|
15
config.go
15
config.go
|
@ -25,19 +25,6 @@ type config struct {
|
|||
Provisioners map[string]string
|
||||
}
|
||||
|
||||
// ConfigFile returns the default path to the configuration file. On
|
||||
// Unix-like systems this is the ".packerconfig" file in the home directory.
|
||||
// On Windows, this is the "packer.config" file in the application data
|
||||
// directory.
|
||||
func ConfigFile() (string, error) {
|
||||
return configFile()
|
||||
}
|
||||
|
||||
// ConfigDir returns the configuration directory for Packer.
|
||||
func ConfigDir() (string, error) {
|
||||
return configDir()
|
||||
}
|
||||
|
||||
// Decodes configuration in JSON format from the given io.Reader into
|
||||
// the config object pointed to.
|
||||
func decodeConfig(r io.Reader, c *config) error {
|
||||
|
@ -64,7 +51,7 @@ func (c *config) Discover() error {
|
|||
}
|
||||
|
||||
// Next, look in the plugins directory.
|
||||
dir, err := ConfigDir()
|
||||
dir, err := packer.ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERR] Error loading config directory: %s", err)
|
||||
} else {
|
||||
|
|
2
main.go
2
main.go
|
@ -223,7 +223,7 @@ func loadConfig() (*config, error) {
|
|||
configFilePath := os.Getenv("PACKER_CONFIG")
|
||||
if configFilePath == "" {
|
||||
var err error
|
||||
configFilePath, err = configFile()
|
||||
configFilePath, err = packer.ConfigFile()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error detecting default config file path: %s", err)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package packer
|
||||
|
||||
// ConfigFile returns the default path to the configuration file. On
|
||||
// Unix-like systems this is the ".packerconfig" file in the home directory.
|
||||
// On Windows, this is the "packer.config" file in the application data
|
||||
// directory.
|
||||
func ConfigFile() (string, error) {
|
||||
return configFile()
|
||||
}
|
||||
|
||||
// ConfigDir returns the configuration directory for Packer.
|
||||
func ConfigDir() (string, error) {
|
||||
return configDir()
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// +build darwin freebsd linux netbsd openbsd
|
||||
|
||||
package main
|
||||
package packer
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,6 +1,6 @@
|
|||
// +build windows
|
||||
|
||||
package main
|
||||
package packer
|
||||
|
||||
import (
|
||||
"path/filepath"
|
Loading…
Reference in New Issue