Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
7497db67
Commit
7497db67
authored
Jun 18, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaked some of the UI/UX around GOMAXPROCS
parent
0880d448
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
post-processor/compress/post-processor.go
post-processor/compress/post-processor.go
+16
-8
No files found.
post-processor/compress/post-processor.go
View file @
7497db67
...
@@ -60,6 +60,11 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
...
@@ -60,6 +60,11 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
errs
:=
new
(
packer
.
MultiError
)
errs
:=
new
(
packer
.
MultiError
)
// If there is no explicit number of Go threads to use, then set it
if
os
.
Getenv
(
"GOMAXPROCS"
)
==
""
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
}
if
p
.
config
.
OutputPath
==
""
{
if
p
.
config
.
OutputPath
==
""
{
p
.
config
.
OutputPath
=
"packer_{{.BuildName}}_{{.Provider}}"
p
.
config
.
OutputPath
=
"packer_{{.BuildName}}_{{.Provider}}"
}
}
...
@@ -124,11 +129,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -124,11 +129,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
var
output
io
.
WriteCloser
var
output
io
.
WriteCloser
switch
p
.
config
.
Algorithm
{
switch
p
.
config
.
Algorithm
{
case
"lz4"
:
case
"lz4"
:
ui
.
Say
(
fmt
.
Sprintf
(
"Preparing lz4 compression for %s"
,
target
))
ui
.
Say
(
fmt
.
Sprintf
(
"Using lz4 compression with %d cores for %s"
,
runtime
.
GOMAXPROCS
(
-
1
),
target
))
output
,
err
=
makeLZ4Writer
(
outputFile
,
p
.
config
.
CompressionLevel
)
output
,
err
=
makeLZ4Writer
(
outputFile
,
p
.
config
.
CompressionLevel
)
defer
output
.
Close
()
defer
output
.
Close
()
case
"pgzip"
:
case
"pgzip"
:
ui
.
Say
(
fmt
.
Sprintf
(
"Preparing gzip compression for %s"
,
target
))
ui
.
Say
(
fmt
.
Sprintf
(
"Using pgzip compression with %d cores for %s"
,
runtime
.
GOMAXPROCS
(
-
1
),
target
))
output
,
err
=
makePgzipWriter
(
outputFile
,
p
.
config
.
CompressionLevel
)
output
,
err
=
makePgzipWriter
(
outputFile
,
p
.
config
.
CompressionLevel
)
defer
output
.
Close
()
defer
output
.
Close
()
default
:
default
:
...
@@ -137,13 +144,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -137,13 +144,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
compression
:=
p
.
config
.
Algorithm
compression
:=
p
.
config
.
Algorithm
if
compression
==
""
{
if
compression
==
""
{
compression
=
"no"
compression
=
"no
compression
"
}
}
// Build an archive, if we're supposed to do that.
// Build an archive, if we're supposed to do that.
switch
p
.
config
.
Archive
{
switch
p
.
config
.
Archive
{
case
"tar"
:
case
"tar"
:
ui
.
Say
(
fmt
.
Sprintf
(
"Tarring %s with %s
compression
"
,
target
,
compression
))
ui
.
Say
(
fmt
.
Sprintf
(
"Tarring %s with %s"
,
target
,
compression
))
err
=
createTarArchive
(
artifact
.
Files
(),
output
)
err
=
createTarArchive
(
artifact
.
Files
(),
output
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
keep
,
fmt
.
Errorf
(
"Error creating tar: %s"
,
err
)
return
nil
,
keep
,
fmt
.
Errorf
(
"Error creating tar: %s"
,
err
)
...
@@ -155,7 +162,6 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -155,7 +162,6 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
return
nil
,
keep
,
fmt
.
Errorf
(
"Error creating zip: %s"
,
err
)
return
nil
,
keep
,
fmt
.
Errorf
(
"Error creating zip: %s"
,
err
)
}
}
default
:
default
:
ui
.
Say
(
fmt
.
Sprintf
(
"Copying %s with %s compression"
,
target
,
compression
))
// Filename indicates no tarball (just compress) so we'll do an io.Copy
// Filename indicates no tarball (just compress) so we'll do an io.Copy
// into our compressor.
// into our compressor.
if
len
(
artifact
.
Files
())
!=
1
{
if
len
(
artifact
.
Files
())
!=
1
{
...
@@ -163,18 +169,20 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
...
@@ -163,18 +169,20 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
"Can only have 1 input file when not using tar/zip. Found %d "
+
"Can only have 1 input file when not using tar/zip. Found %d "
+
"files: %v"
,
len
(
artifact
.
Files
()),
artifact
.
Files
())
"files: %v"
,
len
(
artifact
.
Files
()),
artifact
.
Files
())
}
}
archiveFile
:=
artifact
.
Files
()[
0
]
ui
.
Say
(
fmt
.
Sprintf
(
"Archiving %s with %s"
,
archiveFile
,
compression
))
source
,
err
:=
os
.
Open
(
ar
tifact
.
Files
()[
0
]
)
source
,
err
:=
os
.
Open
(
ar
chiveFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
keep
,
fmt
.
Errorf
(
return
nil
,
keep
,
fmt
.
Errorf
(
"Failed to open source file %s for reading: %s"
,
"Failed to open source file %s for reading: %s"
,
ar
tifact
.
Files
()[
0
]
,
err
)
ar
chiveFile
,
err
)
}
}
defer
source
.
Close
()
defer
source
.
Close
()
if
_
,
err
=
io
.
Copy
(
output
,
source
);
err
!=
nil
{
if
_
,
err
=
io
.
Copy
(
output
,
source
);
err
!=
nil
{
return
nil
,
keep
,
fmt
.
Errorf
(
"Failed to compress %s: %s"
,
return
nil
,
keep
,
fmt
.
Errorf
(
"Failed to compress %s: %s"
,
ar
tifact
.
Files
()[
0
]
,
err
)
ar
chiveFile
,
err
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment