Merge pull request #2313 from mitchellh/b-compress-crash

This commit is contained in:
Chris Bednarski 2015-06-24 21:49:30 -07:00
commit 6bb480e2f7
2 changed files with 13 additions and 20 deletions

View File

@ -19,6 +19,18 @@ import (
"github.com/pierrec/lz4" "github.com/pierrec/lz4"
) )
var (
// ErrInvalidCompressionLevel is returned when the compression level passed
// to gzip is not in the expected range. See compress/flate for details.
ErrInvalidCompressionLevel = fmt.Errorf(
"Invalid compression level. Expected an integer from -1 to 9.")
ErrWrongInputCount = fmt.Errorf(
"Can only have 1 input file when not using tar/zip")
filenamePattern = regexp.MustCompile(`(?:\.([a-z0-9]+))`)
)
type Config struct { type Config struct {
common.PackerConfig `mapstructure:",squash"` common.PackerConfig `mapstructure:",squash"`
@ -35,21 +47,9 @@ type Config struct {
} }
type PostProcessor struct { type PostProcessor struct {
config *Config config Config
} }
var (
// ErrInvalidCompressionLevel is returned when the compression level passed
// to gzip is not in the expected range. See compress/flate for details.
ErrInvalidCompressionLevel = fmt.Errorf(
"Invalid compression level. Expected an integer from -1 to 9.")
ErrWrongInputCount = fmt.Errorf(
"Can only have 1 input file when not using tar/zip")
filenamePattern = regexp.MustCompile(`(?:\.([a-z0-9]+))`)
)
func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) Configure(raws ...interface{}) error {
err := config.Decode(&p.config, &config.DecodeOpts{ err := config.Decode(&p.config, &config.DecodeOpts{
Interpolate: true, Interpolate: true,
@ -109,7 +109,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
} }
return nil return nil
} }
func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) { func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {

View File

@ -9,7 +9,6 @@ import (
"testing" "testing"
"github.com/mitchellh/packer/builder/file" "github.com/mitchellh/packer/builder/file"
env "github.com/mitchellh/packer/helper/builder/testing"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template" "github.com/mitchellh/packer/template"
) )
@ -187,11 +186,6 @@ func setup(t *testing.T) (packer.Ui, packer.Artifact, error) {
} }
func testArchive(t *testing.T, config string) packer.Artifact { func testArchive(t *testing.T, config string) packer.Artifact {
if os.Getenv(env.TestEnvVar) == "" {
t.Skip(fmt.Sprintf(
"Acceptance tests skipped unless env '%s' set", env.TestEnvVar))
}
ui, artifact, err := setup(t) ui, artifact, err := setup(t)
if err != nil { if err != nil {
t.Fatalf("Error bootstrapping test: %s", err) t.Fatalf("Error bootstrapping test: %s", err)