Merge pull request #634 from rasa/skip-gzip-compression-when-level-is-0-v2
post-processor/vagrant: skip gzip compression if compression_level=0
This commit is contained in:
commit
7a623fcd5d
|
@ -11,6 +11,7 @@ FEATURES:
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
* Vagrant post-processor skips gzip compression when compression_level=0
|
||||||
* builder/amazon/all: Can now specify a list of multiple security group
|
* builder/amazon/all: Can now specify a list of multiple security group
|
||||||
IDs to apply. [GH-499]
|
IDs to apply. [GH-499]
|
||||||
* builder/amazon/all: AWS API requests are now retried when a temporary
|
* builder/amazon/all: AWS API requests are now retried when a temporary
|
||||||
|
|
|
@ -2,6 +2,7 @@ package vagrant
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
|
"compress/flate"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -52,13 +53,22 @@ func DirToBox(dst, dir string, ui packer.Ui, level int) error {
|
||||||
}
|
}
|
||||||
defer dstF.Close()
|
defer dstF.Close()
|
||||||
|
|
||||||
gzipWriter, err := gzip.NewWriterLevel(dstF, level)
|
var tarOrGzipWriter io.Writer
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer gzipWriter.Close()
|
|
||||||
|
|
||||||
tarWriter := tar.NewWriter(gzipWriter)
|
if level != flate.NoCompression {
|
||||||
|
log.Printf("Compressing with gzip compression level %v", level)
|
||||||
|
gzipWriter, err := gzip.NewWriterLevel(dstF, level)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer gzipWriter.Close()
|
||||||
|
tarOrGzipWriter = gzipWriter
|
||||||
|
} else {
|
||||||
|
log.Printf("Skipping gzip compression")
|
||||||
|
tarOrGzipWriter = dstF
|
||||||
|
}
|
||||||
|
|
||||||
|
tarWriter := tar.NewWriter(tarOrGzipWriter)
|
||||||
defer tarWriter.Close()
|
defer tarWriter.Close()
|
||||||
|
|
||||||
// This is the walk func that tars each of the files in the dir
|
// This is the walk func that tars each of the files in the dir
|
||||||
|
|
Loading…
Reference in New Issue