post-processor/compress: Boilerplate for the compress PP
This commit is contained in:
parent
b34bc1a0c9
commit
0a90d3e791
|
@ -30,6 +30,10 @@ const defaultConfig = `
|
|||
"validate": "packer-command-validate"
|
||||
},
|
||||
|
||||
"post-processors": {
|
||||
"compress": "packer-post-processor-compress"
|
||||
},
|
||||
|
||||
"provisioners": {
|
||||
"shell": "packer-provisioner-shell"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/packer/post-processor/compress"
|
||||
"github.com/mitchellh/packer/packer/plugin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
plugin.ServePostProcessor(new(compress.PostProcessor))
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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
|
||||
}
|
Loading…
Reference in New Issue