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
fbb24d4a
Commit
fbb24d4a
authored
Aug 04, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed interpolation logic so .BuildName can be used in the output config option
parent
8f2a9de2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
post-processor/compress/post-processor.go
post-processor/compress/post-processor.go
+21
-23
No files found.
post-processor/compress/post-processor.go
View file @
fbb24d4a
...
@@ -55,9 +55,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
...
@@ -55,9 +55,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
Interpolate
:
true
,
Interpolate
:
true
,
InterpolateContext
:
&
p
.
config
.
ctx
,
InterpolateContext
:
&
p
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{},
Exclude
:
[]
string
{
"output"
},
},
},
},
raws
...
)
},
raws
...
)
if
err
!=
nil
{
return
err
}
errs
:=
new
(
packer
.
MultiError
)
errs
:=
new
(
packer
.
MultiError
)
...
@@ -67,16 +70,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
...
@@ -67,16 +70,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
}
if
p
.
config
.
OutputPath
==
""
{
if
p
.
config
.
OutputPath
==
""
{
p
.
config
.
OutputPath
=
"packer_{{.BuildName}}_{{.Provider}}"
p
.
config
.
OutputPath
=
"packer_{{.BuildName}}_{{.BuilderType}}"
}
if
err
=
interpolate
.
Validate
(
p
.
config
.
OutputPath
,
&
p
.
config
.
ctx
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error parsing target template: %s"
,
err
))
}
templates
:=
map
[
string
]
*
string
{
"output"
:
&
p
.
config
.
OutputPath
,
}
}
if
p
.
config
.
CompressionLevel
>
pgzip
.
BestCompression
{
if
p
.
config
.
CompressionLevel
>
pgzip
.
BestCompression
{
...
@@ -89,17 +83,9 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
...
@@ -89,17 +83,9 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p
.
config
.
CompressionLevel
=
pgzip
.
DefaultCompression
p
.
config
.
CompressionLevel
=
pgzip
.
DefaultCompression
}
}
for
key
,
ptr
:=
range
templates
{
if
err
=
interpolate
.
Validate
(
p
.
config
.
OutputPath
,
&
p
.
config
.
ctx
);
err
!=
nil
{
if
*
ptr
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error parsing target template: %s"
,
err
))
errs
,
fmt
.
Errorf
(
"%s must be set"
,
key
))
}
*
ptr
,
err
=
interpolate
.
Render
(
p
.
config
.
OutputPath
,
&
p
.
config
.
ctx
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
key
,
err
))
}
}
}
p
.
config
.
detectFromFilename
()
p
.
config
.
detectFromFilename
()
...
@@ -113,7 +99,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
...
@@ -113,7 +99,19 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
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
)
{
target
:=
p
.
config
.
OutputPath
// These are extra variables that will be made available for interpolation.
p
.
config
.
ctx
.
Data
=
map
[
string
]
string
{
"BuildName"
:
p
.
config
.
PackerBuildName
,
"BuilderType"
:
p
.
config
.
PackerBuilderType
,
}
target
,
err
:=
interpolate
.
Render
(
p
.
config
.
OutputPath
,
&
p
.
config
.
ctx
)
if
err
!=
nil
{
return
nil
,
false
,
fmt
.
Errorf
(
"Error interpolating output value: %s"
,
err
)
}
else
{
fmt
.
Println
(
target
)
}
keep
:=
p
.
config
.
KeepInputArtifact
keep
:=
p
.
config
.
KeepInputArtifact
newArtifact
:=
&
Artifact
{
Path
:
target
}
newArtifact
:=
&
Artifact
{
Path
:
target
}
...
...
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