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
42d749ab
Commit
42d749ab
authored
Jun 10, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Light style and typo cleanup
parent
c4fc365c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
plugin/post-processor-compress/main.go
plugin/post-processor-compress/main.go
+1
-1
post-processor/compress/post-processor.go
post-processor/compress/post-processor.go
+14
-14
No files found.
plugin/post-processor-compress/main.go
View file @
42d749ab
...
...
@@ -10,6 +10,6 @@ func main() {
if
err
!=
nil
{
panic
(
err
)
}
server
.
RegisterPostProcessor
(
new
(
compress
.
Compress
PostProcessor
))
server
.
RegisterPostProcessor
(
new
(
compress
.
PostProcessor
))
server
.
Serve
()
}
post-processor/compress/post-processor.go
View file @
42d749ab
...
...
@@ -45,11 +45,11 @@ type Config struct {
ctx
*
interpolate
.
Context
}
type
Compress
PostProcessor
struct
{
type
PostProcessor
struct
{
cfg
Config
}
func
(
p
*
Compress
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
p
.
cfg
.
Compression
=
-
1
err
:=
config
.
Decode
(
&
p
.
cfg
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
...
...
@@ -109,7 +109,7 @@ func (p *CompressPostProcessor) Configure(raws ...interface{}) error {
}
func
(
p
*
Compress
PostProcessor
)
fillMetadata
(
metadata
Metadata
,
files
[]
string
)
Metadata
{
func
(
p
*
PostProcessor
)
fillMetadata
(
metadata
Metadata
,
files
[]
string
)
Metadata
{
// layout shows by example how the reference time should be represented.
const
layout
=
"2006-01-02_15-04-05"
t
:=
time
.
Now
()
...
...
@@ -133,9 +133,9 @@ func (p *CompressPostProcessor) fillMetadata(metadata Metadata, files []string)
return
metadata
}
func
(
p
*
Compress
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
)
{
newartifact
:=
&
Artifact
{
builderId
:
artifact
.
BuilderId
(),
dir
:
p
.
cfg
.
OutputPath
}
var
metafile
string
=
filepath
.
Join
(
p
.
cfg
.
OutputPath
,
"metadata"
)
metafile
:
=
filepath
.
Join
(
p
.
cfg
.
OutputPath
,
"metadata"
)
_
,
err
:=
os
.
Stat
(
newartifact
.
dir
)
if
err
==
nil
{
...
...
@@ -206,7 +206,7 @@ func (p *CompressPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifa
return
newartifact
,
p
.
cfg
.
KeepInputArtifact
,
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpTAR
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpTAR
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
fw
,
err
:=
os
.
Create
(
dst
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"tar error: %s"
,
err
)
...
...
@@ -225,7 +225,7 @@ func (p *CompressPostProcessor) cmpTAR(src []string, dst string) ([]string, erro
target
,
_
:=
os
.
Readlink
(
name
)
header
,
err
:=
tar
.
FileInfoHeader
(
fi
,
target
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"tar er
or
r: %s"
,
err
)
return
nil
,
fmt
.
Errorf
(
"tar er
ro
r: %s"
,
err
)
}
if
err
=
tw
.
WriteHeader
(
header
);
err
!=
nil
{
...
...
@@ -246,7 +246,7 @@ func (p *CompressPostProcessor) cmpTAR(src []string, dst string) ([]string, erro
return
[]
string
{
dst
},
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpGZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpGZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
var
res
[]
string
for
_
,
name
:=
range
src
{
filename
:=
filepath
.
Join
(
dst
,
filepath
.
Base
(
name
))
...
...
@@ -279,7 +279,7 @@ func (p *CompressPostProcessor) cmpGZIP(src []string, dst string) ([]string, err
return
res
,
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpPGZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpPGZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
var
res
[]
string
for
_
,
name
:=
range
src
{
filename
:=
filepath
.
Join
(
dst
,
filepath
.
Base
(
name
))
...
...
@@ -312,7 +312,7 @@ func (p *CompressPostProcessor) cmpPGZIP(src []string, dst string) ([]string, er
return
res
,
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpLZ4
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpLZ4
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
var
res
[]
string
for
_
,
name
:=
range
src
{
filename
:=
filepath
.
Join
(
dst
,
filepath
.
Base
(
name
))
...
...
@@ -348,7 +348,7 @@ func (p *CompressPostProcessor) cmpLZ4(src []string, dst string) ([]string, erro
return
res
,
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpBGZF
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpBGZF
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
var
res
[]
string
for
_
,
name
:=
range
src
{
filename
:=
filepath
.
Join
(
dst
,
filepath
.
Base
(
name
))
...
...
@@ -381,11 +381,11 @@ func (p *CompressPostProcessor) cmpBGZF(src []string, dst string) ([]string, err
return
res
,
nil
}
func
(
p
*
Compress
PostProcessor
)
cmpE2FS
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpE2FS
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
panic
(
"not implemented"
)
}
func
(
p
*
Compress
PostProcessor
)
cmpZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
func
(
p
*
PostProcessor
)
cmpZIP
(
src
[]
string
,
dst
string
)
([]
string
,
error
)
{
fw
,
err
:=
os
.
Create
(
dst
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"zip error: %s"
,
err
)
...
...
@@ -398,7 +398,7 @@ func (p *CompressPostProcessor) cmpZIP(src []string, dst string) ([]string, erro
for
_
,
name
:=
range
src
{
header
,
err
:=
zw
.
Create
(
name
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"zip er
or
r: %s"
,
err
)
return
nil
,
fmt
.
Errorf
(
"zip er
ro
r: %s"
,
err
)
}
fr
,
err
:=
os
.
Open
(
name
)
...
...
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