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
7fc30436
Commit
7fc30436
authored
Jul 14, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/fix: run the iso-md5 fixer
parent
ab2af979
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
command/fix/command.go
command/fix/command.go
+27
-0
command/fix/help.go
command/fix/help.go
+3
-2
No files found.
command/fix/command.go
View file @
7fc30436
package
fix
package
fix
import
(
import
(
"bytes"
"encoding/json"
"encoding/json"
"flag"
"flag"
"fmt"
"fmt"
...
@@ -47,6 +48,32 @@ func (c Command) Run(env packer.Environment, args []string) int {
...
@@ -47,6 +48,32 @@ func (c Command) Run(env packer.Environment, args []string) int {
// Close the file since we're done with that
// Close the file since we're done with that
tplF
.
Close
()
tplF
.
Close
()
// Run the template through the various fixers
fixers
:=
[]
Fixer
{
Fixers
[
"iso-md5"
]}
input
:=
templateData
for
_
,
fixer
:=
range
fixers
{
var
err
error
input
,
err
=
fixer
.
Fix
(
input
)
if
err
!=
nil
{
env
.
Ui
()
.
Error
(
fmt
.
Sprintf
(
"Error fixing: %s"
,
err
))
return
1
}
}
var
output
bytes
.
Buffer
encoder
:=
json
.
NewEncoder
(
&
output
)
if
err
:=
encoder
.
Encode
(
input
);
err
!=
nil
{
env
.
Ui
()
.
Error
(
fmt
.
Sprintf
(
"Error encoding: %s"
,
err
))
return
1
}
var
indented
bytes
.
Buffer
if
err
:=
json
.
Indent
(
&
indented
,
output
.
Bytes
(),
""
,
" "
);
err
!=
nil
{
env
.
Ui
()
.
Error
(
fmt
.
Sprintf
(
"Error encoding: %s"
,
err
))
return
1
}
env
.
Ui
()
.
Say
(
indented
.
String
())
return
0
return
0
}
}
...
...
command/fix/help.go
View file @
7fc30436
...
@@ -9,7 +9,8 @@ Usage: packer fix [options] TEMPLATE
...
@@ -9,7 +9,8 @@ Usage: packer fix [options] TEMPLATE
If the template cannot be fixed due to an error, the command will exit
If the template cannot be fixed due to an error, the command will exit
with a non-zero exit status. Error messages will appear on standard error.
with a non-zero exit status. Error messages will appear on standard error.
Options:
Fixes that are run:
iso-md5 Replaces "iso_md5" in builders with newer "iso_checksum"
-verbose Output each fix to standard error
`
`
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