packer-cn/builder/amazonebs/builder.go

40 lines
776 B
Go
Raw Normal View History

package amazonebs
import (
2013-05-09 16:19:38 -04:00
"encoding/json"
"github.com/mitchellh/packer/packer"
2013-05-09 16:26:40 -04:00
"log"
)
type config struct {
2013-05-09 16:19:38 -04:00
AccessKey string `json:"access_key"`
Region string
2013-05-09 16:19:38 -04:00
SecretKey string `json:"secret_key"`
SourceAmi string `json:"source_ami"`
}
type Builder struct {
config config
}
2013-05-09 16:19:38 -04:00
func (b *Builder) Prepare(raw interface{}) (err error) {
2013-05-09 17:10:57 -04:00
// Marshal and unmarshal the raw configuration as a way to get it
// into our "config" struct.
// TODO: Use the reflection package and provide this as an API for
// better error messages
2013-05-09 16:19:38 -04:00
jsonBytes, err := json.Marshal(raw)
if err != nil {
return
}
err = json.Unmarshal(jsonBytes, &b.config)
if err != nil {
return
}
2013-05-09 16:26:40 -04:00
log.Printf("Config: %+v\n", b.config)
2013-05-09 16:19:38 -04:00
return
}
func (*Builder) Run(packer.Build, packer.Ui) {}