Commit 0a90d3e7 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

post-processor/compress: Boilerplate for the compress PP

parent b34bc1a0
......@@ -30,6 +30,10 @@ const defaultConfig = `
"validate": "packer-command-validate"
},
"post-processors": {
"compress": "packer-post-processor-compress"
},
"provisioners": {
"shell": "packer-provisioner-shell"
}
......
package main
import (
"github.com/mitchellh/packer/post-processor/compress"
"github.com/mitchellh/packer/packer/plugin"
)
func main() {
plugin.ServePostProcessor(new(compress.PostProcessor))
}
// compress implements the packer.PostProcessor interface and adds a
// post-processor for compressing output.
package compress
import (
"errors"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/mapstructure"
)
type Config struct {
Format string
}
type PostProcessor struct {
config Config
}
func (p *PostProcessor) Configure(raw interface{}) error {
if err := mapstructure.Decode(raw, &p.config); err != nil {
return err
}
if p.config.Format == "" {
p.config.Format = "tar.gz"
}
if p.config.Format != "tar.gz" {
return errors.New("only 'tar.gz' is a supported format right now")
}
return nil
}
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, error) {
ui.Say("We made it to here.")
return nil, 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