Separate commands into other directories
This commit is contained in:
parent
f49c0cb313
commit
fefd2ae208
|
@ -0,0 +1,15 @@
|
|||
package build
|
||||
|
||||
import "fmt"
|
||||
import "github.com/mitchellh/packer/packer"
|
||||
|
||||
type Command byte
|
||||
|
||||
func (Command) Run(env *packer.Environment, arg []string) int {
|
||||
fmt.Println("HI!")
|
||||
return 0
|
||||
}
|
||||
|
||||
func (Command) Synopsis() string {
|
||||
return "build image(s) from tempate"
|
||||
}
|
|
@ -3,12 +3,16 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"github.com/mitchellh/packer/command/build"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
env, err := packer.NewEnvironment(packer.DefaultEnvironmentConfig())
|
||||
envConfig := packer.DefaultEnvironmentConfig()
|
||||
envConfig.Command["build"] = new(build.Command)
|
||||
|
||||
env, err := packer.NewEnvironment(envConfig)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Packer initialization error: \n\n%s\n", err)
|
||||
os.Exit(1)
|
||||
|
|
|
@ -34,6 +34,7 @@ type EnvironmentConfig struct {
|
|||
func DefaultEnvironmentConfig() *EnvironmentConfig {
|
||||
config := &EnvironmentConfig{}
|
||||
config.BuilderFactory = new(NilBuilderFactory)
|
||||
config.Command = make(map[string]Command)
|
||||
config.Ui = &ReaderWriterUi{os.Stdin, os.Stdout}
|
||||
return config
|
||||
}
|
||||
|
|
|
@ -40,6 +40,13 @@ func testEnvironment() *Environment {
|
|||
return env
|
||||
}
|
||||
|
||||
func TestEnvironment_DefaultConfig_Command(t *testing.T) {
|
||||
assert := asserts.NewTestingAsserts(t, true)
|
||||
|
||||
config := DefaultEnvironmentConfig()
|
||||
assert.NotNil(config.Command, "default Command should not be nil")
|
||||
}
|
||||
|
||||
func TestEnvironment_DefaultConfig_Ui(t *testing.T) {
|
||||
assert := asserts.NewTestingAsserts(t, true)
|
||||
|
||||
|
|
Loading…
Reference in New Issue