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
d74dacc4
Commit
d74dacc4
authored
May 23, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Core.Build
parent
ded13a8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
packer/core.go
packer/core.go
+29
-0
packer/testing.go
packer/testing.go
+44
-0
No files found.
packer/core.go
View file @
d74dacc4
...
...
@@ -47,6 +47,35 @@ func NewCore(c *CoreConfig) (*Core, error) {
},
nil
}
// Build returns the Build object for the given name.
func
(
c
*
Core
)
Build
(
n
string
)
(
Build
,
error
)
{
// Setup the builder
configBuilder
,
ok
:=
c
.
template
.
Builders
[
n
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"no such build found: %s"
,
n
)
}
builder
,
err
:=
c
.
components
.
Builder
(
configBuilder
.
Type
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error initializing builder '%s': %s"
,
configBuilder
.
Type
,
err
)
}
if
builder
==
nil
{
return
nil
,
fmt
.
Errorf
(
"builder type not found: %s"
,
configBuilder
.
Type
)
}
// TODO: template process name
return
&
coreBuild
{
name
:
n
,
builder
:
builder
,
builderConfig
:
configBuilder
.
Config
,
builderType
:
configBuilder
.
Type
,
variables
:
c
.
variables
,
},
nil
}
// Validate does a full validation of the template.
//
// This will automatically call template.Validate() in addition to doing
...
...
packer/testing.go
0 → 100644
View file @
d74dacc4
package
packer
import
(
"bytes"
"io/ioutil"
"os"
"testing"
)
func
TestCoreConfig
(
t
*
testing
.
T
)
*
CoreConfig
{
// Create a UI that is effectively /dev/null everywhere
var
buf
bytes
.
Buffer
ui
:=
&
BasicUi
{
Reader
:
&
buf
,
Writer
:
ioutil
.
Discard
,
ErrorWriter
:
ioutil
.
Discard
,
}
// Create some test components
components
:=
ComponentFinder
{
Builder
:
func
(
n
string
)
(
Builder
,
error
)
{
if
n
!=
"test"
{
return
nil
,
nil
}
return
&
MockBuilder
{},
nil
},
}
return
&
CoreConfig
{
Cache
:
&
FileCache
{
CacheDir
:
os
.
TempDir
()},
Components
:
components
,
Ui
:
ui
,
}
}
func
TestCore
(
t
*
testing
.
T
,
c
*
CoreConfig
)
*
Core
{
core
,
err
:=
NewCore
(
c
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
return
core
}
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