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
0de922d1
Commit
0de922d1
authored
Apr 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make environment config export variables
parent
2e1b5076
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
18 deletions
+8
-18
packer/environment.go
packer/environment.go
+7
-17
packer/environment_test.go
packer/environment_test.go
+1
-1
No files found.
packer/environment.go
View file @
0de922d1
...
...
@@ -34,34 +34,30 @@ type Command interface {
// if you're building a custom Packer binary, you could instantiate multiple
// environments and run them in parallel.
type
Environment
struct
{
builder
map
[
string
]
Builder
builder
Factory
BuilderFactory
command
map
[
string
]
Command
ui
Ui
}
// This struct configures new environments.
type
EnvironmentConfig
struct
{
builder
map
[
string
]
Builder
c
ommand
map
[
string
]
Command
u
i
Ui
BuilderFactory
BuilderFactory
C
ommand
map
[
string
]
Command
U
i
Ui
}
// This creates a new environment
func
NewEnvironment
(
config
*
EnvironmentConfig
)
*
Environment
{
env
:=
&
Environment
{}
env
.
builder
=
make
(
map
[
string
]
Builder
)
env
.
command
=
make
(
map
[
string
]
Command
)
if
config
!=
nil
{
for
k
,
v
:=
range
config
.
builder
{
env
.
builder
[
k
]
=
v
}
for
k
,
v
:=
range
config
.
command
{
for
k
,
v
:=
range
config
.
Command
{
env
.
command
[
k
]
=
v
}
env
.
ui
=
config
.
ui
env
.
builderFactory
=
config
.
BuilderFactory
env
.
ui
=
config
.
Ui
}
if
_
,
ok
:=
env
.
command
[
"build"
];
!
ok
{
...
...
@@ -79,12 +75,6 @@ func NewEnvironment(config *EnvironmentConfig) *Environment {
return
env
}
// Looks up a builder with the given name and returns an interface
// to access it.
func
(
e
*
Environment
)
Builder
(
name
string
)
Builder
{
return
e
.
builder
[
name
]
}
// Executes a command as if it was typed on the command-line interface.
// The return value is the exit code of the command.
func
(
e
*
Environment
)
Cli
(
args
[]
string
)
int
{
...
...
packer/environment_test.go
View file @
0de922d1
...
...
@@ -83,7 +83,7 @@ func TestEnvironment_SettingUi(t *testing.T) {
ui
:=
&
ReaderWriterUi
{
new
(
bytes
.
Buffer
),
new
(
bytes
.
Buffer
)}
config
:=
&
EnvironmentConfig
{}
config
.
u
i
=
ui
config
.
U
i
=
ui
env
:=
NewEnvironment
(
config
)
...
...
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