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
759261dc
Commit
759261dc
authored
Mar 25, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bad commit message
parent
791e0482
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
32 deletions
+56
-32
packer.go
packer.go
+4
-32
packer/build.go
packer/build.go
+14
-0
packer/template.go
packer/template.go
+38
-0
No files found.
packer.go
View file @
759261dc
// This is the main package for the `packer` application.
package
main
import
"github.com/mitchellh/packer/packer"
import
"os"
type
RawTemplate
struct
{
Name
string
Builders
[]
map
[
string
]
interface
{}
Provisioners
[]
map
[
string
]
interface
{}
Outputs
[]
map
[
string
]
interface
{}
}
type
Builder
interface
{
ConfigInterface
()
interface
{}
Prepare
()
Build
()
}
type
Build
interface
{
Hook
(
name
string
)
}
import
(
"github.com/mitchellh/packer/packer"
"os"
)
func
main
()
{
env
:=
packer
.
NewEnvironment
()
os
.
Exit
(
env
.
Cli
(
os
.
Args
[
1
:
]))
/*
file, _ := ioutil.ReadFile("example.json")
var tpl RawTemplate
json.Unmarshal(file, &tpl)
fmt.Printf("%#v\n", tpl)
builderType, ok := tpl.Builders[0]["type"].(Build)
if !ok {
panic("OH NOES")
}
fmt.Printf("TYPE: %v\n", builderType)
*/
}
packer/build.go
0 → 100644
View file @
759261dc
package
packer
// A build struct represents a single build job, the result of which should
// be a single machine image artifact. This artifact may be comprised of
// multiple files, of course, but it should be for only a single provider
// (such as VirtualBox, EC2, etc.).
type
Build
struct
{
name
string
builder
Builder
}
type
Builder
interface
{
Prepare
()
}
packer/template.go
0 → 100644
View file @
759261dc
package
packer
import
"encoding/json"
// The rawTemplate struct represents the structure of a template read
// directly from a file. The builders and other components map just to
// "interface{}" pointers since we actually don't know what their contents
// are until we read the "type" field.
type
rawTemplate
struct
{
Name
string
Builders
[]
map
[
string
]
interface
{}
Provisioners
[]
map
[
string
]
interface
{}
Outputs
[]
map
[
string
]
interface
{}
}
type
Template
struct
{
Name
string
Builders
map
[
string
]
rawBuilderConfig
}
// The rawBuilderConfig struct represents a raw, unprocessed builder
// configuration. It contains the name of the builder as well as the
// raw configuration. If requested, this is used to compile into a full
// builder configuration at some point.
type
rawBuilderConfig
struct
{
builderName
string
rawConfig
interface
{}
}
func
parseTemplate
(
data
[]
byte
)
error
{
var
rawTpl
rawTemplate
err
:=
json
.
Unmarshal
(
data
,
&
rawTpl
)
if
err
!=
nil
{
return
err
}
return
nil
}
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