mirror of https://github.com/hashicorp/packer
parent
9600bf5b4b
commit
6d0fa84e2c
@ -1,22 +1,40 @@
|
||||
package amazonebs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
AccessKey string
|
||||
AccessKey string `json:"access_key"`
|
||||
Region string
|
||||
SecretKey string
|
||||
SourceAmi string
|
||||
SecretKey string `json:"secret_key"`
|
||||
SourceAmi string `json:"source_ami"`
|
||||
}
|
||||
|
||||
type Builder struct {
|
||||
config config
|
||||
}
|
||||
|
||||
func (*Builder) Prepare(interface{}) error {
|
||||
return nil
|
||||
func (b *Builder) Prepare(raw interface{}) (err error) {
|
||||
_, ok := raw.(map[string]interface{})
|
||||
if !ok {
|
||||
err = errors.New("configuration isn't a valid map")
|
||||
return
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(raw)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(jsonBytes, &b.config)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (*Builder) Run(packer.Build, packer.Ui) {}
|
||||
|
||||
Loading…
Reference in new issue