Commit 759261dc authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Bad commit message

parent 791e0482
// This is the main package for the `packer` application.
package main
import "github.com/mitchellh/packer/packer"
import "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)
}
import (
"github.com/mitchellh/packer/packer"
"os"
)
func main() {
env := packer.NewEnvironment()
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)
*/
}
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()
}
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
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment