From 1831a0905525ce9ff148a106ca9eb1d7b81501e4 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 24 Jun 2015 17:47:00 -0700 Subject: [PATCH 1/2] Fix compress crash - Changed config from pointer to value to fix crash - Removed acceptance flag from compress tests since they would have caught this --- post-processor/compress/post-processor.go | 2 +- post-processor/compress/post-processor_test.go | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index 8b70bc456..72b85090b 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -35,7 +35,7 @@ type Config struct { } type PostProcessor struct { - config *Config + config Config } var ( diff --git a/post-processor/compress/post-processor_test.go b/post-processor/compress/post-processor_test.go index d7bca6c7a..db23cf3b1 100644 --- a/post-processor/compress/post-processor_test.go +++ b/post-processor/compress/post-processor_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/mitchellh/packer/builder/file" - env "github.com/mitchellh/packer/helper/builder/testing" "github.com/mitchellh/packer/packer" "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 { - if os.Getenv(env.TestEnvVar) == "" { - t.Skip(fmt.Sprintf( - "Acceptance tests skipped unless env '%s' set", env.TestEnvVar)) - } - ui, artifact, err := setup(t) if err != nil { t.Fatalf("Error bootstrapping test: %s", err) From eba28519db59f9a5253acd3c0aa17f109d3ea41a Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 24 Jun 2015 18:29:32 -0700 Subject: [PATCH 2/2] Move vars to the top and cleanup extra whitespace --- post-processor/compress/post-processor.go | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/post-processor/compress/post-processor.go b/post-processor/compress/post-processor.go index 72b85090b..bb6ce27bf 100644 --- a/post-processor/compress/post-processor.go +++ b/post-processor/compress/post-processor.go @@ -19,6 +19,18 @@ import ( "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 { common.PackerConfig `mapstructure:",squash"` @@ -38,18 +50,6 @@ type PostProcessor struct { 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 { err := config.Decode(&p.config, &config.DecodeOpts{ Interpolate: true, @@ -109,7 +109,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { } return nil - } func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (packer.Artifact, bool, error) {