Bad commit message

This commit is contained in:
Mitchell Hashimoto 2013-03-25 16:29:26 -07:00
parent 791e048268
commit 759261dcf1
3 changed files with 56 additions and 32 deletions

View File

@ -1,40 +1,12 @@
// This is the main package for the `packer` application. // This is the main package for the `packer` application.
package main package main
import "github.com/mitchellh/packer/packer" import (
import "os" "github.com/mitchellh/packer/packer"
"os"
type RawTemplate struct { )
Name string
Builders []map[string]interface{}
Provisioners []map[string]interface{}
Outputs []map[string]interface{}
}
type Builder interface {
ConfigInterface() interface{}
Prepare()
Build()
}
type Build interface {
Hook(name string)
}
func main() { func main() {
env := packer.NewEnvironment() env := packer.NewEnvironment()
os.Exit(env.Cli(os.Args[1:])) os.Exit(env.Cli(os.Args[1:]))
/*
file, _ := ioutil.ReadFile("example.json")
var tpl RawTemplate
json.Unmarshal(file, &tpl)
fmt.Printf("%#v\n", tpl)
builderType, ok := tpl.Builders[0]["type"].(Build)
if !ok {
panic("OH NOES")
}
fmt.Printf("TYPE: %v\n", builderType)
*/
} }

14
packer/build.go Normal file
View File

@ -0,0 +1,14 @@
package packer
// A build struct represents a single build job, the result of which should
// be a single machine image artifact. This artifact may be comprised of
// multiple files, of course, but it should be for only a single provider
// (such as VirtualBox, EC2, etc.).
type Build struct {
name string
builder Builder
}
type Builder interface {
Prepare()
}

38
packer/template.go Normal file
View File

@ -0,0 +1,38 @@
package packer
import "encoding/json"
// The rawTemplate struct represents the structure of a template read
// directly from a file. The builders and other components map just to
// "interface{}" pointers since we actually don't know what their contents
// are until we read the "type" field.
type rawTemplate struct {
Name string
Builders []map[string]interface{}
Provisioners []map[string]interface{}
Outputs []map[string]interface{}
}
type Template struct {
Name string
Builders map[string]rawBuilderConfig
}
// The rawBuilderConfig struct represents a raw, unprocessed builder
// configuration. It contains the name of the builder as well as the
// raw configuration. If requested, this is used to compile into a full
// builder configuration at some point.
type rawBuilderConfig struct {
builderName string
rawConfig interface{}
}
func parseTemplate(data []byte) error {
var rawTpl rawTemplate
err := json.Unmarshal(data, &rawTpl)
if err != nil {
return err
}
return nil
}