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
8ffbc2ef
Commit
8ffbc2ef
authored
May 08, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Start pulling out the global config stuff
parent
8a78de02
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
23 deletions
+54
-23
command/build/command.go
command/build/command.go
+1
-1
config.go
config.go
+47
-0
packer.go
packer.go
+3
-21
packer/environment.go
packer/environment.go
+2
-0
plugin/command-build/Makefile
plugin/command-build/Makefile
+1
-1
No files found.
command/build/command.go
View file @
8ffbc2ef
...
@@ -49,5 +49,5 @@ func (Command) Run(env packer.Environment, args []string) int {
...
@@ -49,5 +49,5 @@ func (Command) Run(env packer.Environment, args []string) int {
}
}
func
(
Command
)
Synopsis
()
string
{
func
(
Command
)
Synopsis
()
string
{
return
"build image(s) from tempate"
return
"build image(s) from temp
l
ate"
}
}
config.go
0 → 100644
View file @
8ffbc2ef
package
main
import
(
"fmt"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
"log"
"os/exec"
)
type
config
struct
{
builds
map
[
string
]
string
commands
map
[
string
]
string
}
func
defaultConfig
()
(
result
*
config
)
{
commands
:=
[]
string
{
"build"
}
result
=
new
(
config
)
result
.
builds
=
make
(
map
[
string
]
string
)
result
.
commands
=
make
(
map
[
string
]
string
)
for
_
,
name
:=
range
commands
{
result
.
commands
[
name
]
=
fmt
.
Sprintf
(
"packer-command-%s"
,
name
)
}
return
}
func
(
c
*
config
)
Commands
()
(
result
[]
string
)
{
result
=
make
([]
string
,
0
,
len
(
c
.
commands
))
for
name
,
_
:=
range
c
.
commands
{
result
=
append
(
result
,
name
)
}
return
}
func
(
c
*
config
)
LoadCommand
(
name
string
)
(
packer
.
Command
,
error
)
{
log
.
Printf
(
"Loading command: %s
\n
"
,
name
)
commandBin
,
ok
:=
c
.
commands
[
name
]
if
!
ok
{
log
.
Printf
(
"Command not found: %s
\n
"
,
name
)
return
nil
,
nil
}
return
plugin
.
Command
(
exec
.
Command
(
commandBin
))
}
packer.go
View file @
8ffbc2ef
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"io/ioutil"
"io/ioutil"
"log"
"log"
"os"
"os"
"os/exec"
)
)
func
main
()
{
func
main
()
{
...
@@ -22,27 +21,10 @@ func main() {
...
@@ -22,27 +21,10 @@ func main() {
defer
plugin
.
CleanupClients
()
defer
plugin
.
CleanupClients
()
commands
:=
map
[
string
]
string
{
config
:=
defaultConfig
()
"build"
:
"packer-build"
,
}
commandKeys
:=
make
([]
string
,
0
,
len
(
commands
))
for
k
,
_
:=
range
commands
{
commandKeys
=
append
(
commandKeys
,
k
)
}
envConfig
:=
packer
.
DefaultEnvironmentConfig
()
envConfig
:=
packer
.
DefaultEnvironmentConfig
()
envConfig
.
Commands
=
commandKeys
envConfig
.
Commands
=
config
.
Commands
()
envConfig
.
CommandFunc
=
func
(
n
string
)
(
packer
.
Command
,
error
)
{
envConfig
.
CommandFunc
=
config
.
LoadCommand
log
.
Printf
(
"Loading command: %s
\n
"
,
n
)
commandBin
,
ok
:=
commands
[
n
]
if
!
ok
{
log
.
Printf
(
"Command not found: %s
\n
"
,
n
)
return
nil
,
nil
}
return
plugin
.
Command
(
exec
.
Command
(
commandBin
))
}
env
,
err
:=
packer
.
NewEnvironment
(
envConfig
)
env
,
err
:=
packer
.
NewEnvironment
(
envConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
packer/environment.go
View file @
8ffbc2ef
...
@@ -153,6 +153,8 @@ func (e *coreEnvironment) printHelp() {
...
@@ -153,6 +153,8 @@ func (e *coreEnvironment) printHelp() {
command
,
err
:=
e
.
commandFunc
(
key
)
command
,
err
:=
e
.
commandFunc
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
synopsis
=
fmt
.
Sprintf
(
"Error loading command: %s"
,
err
.
Error
())
synopsis
=
fmt
.
Sprintf
(
"Error loading command: %s"
,
err
.
Error
())
}
else
if
command
==
nil
{
continue
}
else
{
}
else
{
synopsis
=
command
.
Synopsis
()
synopsis
=
command
.
Synopsis
()
}
}
...
...
plugin/command-build/Makefile
View file @
8ffbc2ef
plugin
:
plugin
:
go get
-d
-v
./...
go get
-d
-v
./...
go build
-v
-o
$(ROOTDIR)
/bin/packer-build
go build
-v
-o
$(ROOTDIR)
/bin/packer-
command-
build
format
:
format
:
go
fmt
./...
go
fmt
./...
...
...
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