Commit 82735652 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

better comments for TODO

parent fc0c1a72
...@@ -44,7 +44,15 @@ func (b *Builder) Prepare(raw interface{}) (err error) { ...@@ -44,7 +44,15 @@ func (b *Builder) Prepare(raw interface{}) (err error) {
log.Printf("Config: %+v", b.config) log.Printf("Config: %+v", b.config)
// TODO: Validate the configuration // TODO: config validation and asking for fields:
// * access key
// * secret key
// * region
// * source ami
// * instance type
// * SSH username
// * SSH port? (or default to 22?)
return return
} }
......
...@@ -35,7 +35,10 @@ type rawBuilderConfig struct { ...@@ -35,7 +35,10 @@ type rawBuilderConfig struct {
} }
// ParseTemplate takes a byte slice and parses a Template from it, returning // ParseTemplate takes a byte slice and parses a Template from it, returning
// the template and possibly errors while loading the template. // the template and possibly errors while loading the template. The error
// could potentially be a MultiError, representing multiple errors. Knowing
// and checking for this can be useful, if you wish to format it in a certain
// way.
func ParseTemplate(data []byte) (t *Template, err error) { func ParseTemplate(data []byte) (t *Template, err error) {
var rawTpl rawTemplate var rawTpl rawTemplate
err = json.Unmarshal(data, &rawTpl) err = json.Unmarshal(data, &rawTpl)
...@@ -49,6 +52,8 @@ func ParseTemplate(data []byte) (t *Template, err error) { ...@@ -49,6 +52,8 @@ func ParseTemplate(data []byte) (t *Template, err error) {
t.Hooks = rawTpl.Hooks t.Hooks = rawTpl.Hooks
errors := make([]error, 0) errors := make([]error, 0)
// Gather all the builders
for i, v := range rawTpl.Builders { for i, v := range rawTpl.Builders {
rawType, ok := v["type"] rawType, ok := v["type"]
if !ok { if !ok {
...@@ -86,6 +91,7 @@ func ParseTemplate(data []byte) (t *Template, err error) { ...@@ -86,6 +91,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
t.Builders[name] = rawBuilderConfig{typeName, v} t.Builders[name] = rawBuilderConfig{typeName, v}
} }
// If there were errors, we put it into a MultiError and return
if len(errors) > 0 { if len(errors) > 0 {
err = &MultiError{errors} err = &MultiError{errors}
return return
......
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