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
5aa30caa
Commit
5aa30caa
authored
May 27, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/googlecompute: new interpolation
parent
931f3eb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
38 deletions
+12
-38
builder/googlecompute/config.go
builder/googlecompute/config.go
+12
-38
No files found.
builder/googlecompute/config.go
View file @
5aa30caa
...
...
@@ -7,7 +7,9 @@ import (
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
)
// Config is the configuration structure for the GCE builder. It stores
...
...
@@ -40,25 +42,23 @@ type Config struct {
privateKeyBytes
[]
byte
sshTimeout
time
.
Duration
stateTimeout
time
.
Duration
tpl
*
packer
.
ConfigTemplate
ctx
*
interpolate
.
Context
}
func
NewConfig
(
raws
...
interface
{})
(
*
Config
,
[]
string
,
error
)
{
c
:=
new
(
Config
)
md
,
err
:=
common
.
DecodeConfig
(
c
,
raws
...
)
err
:=
config
.
Decode
(
&
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"run_command"
,
},
},
},
raws
...
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
c
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
nil
,
nil
,
err
}
c
.
tpl
.
UserVars
=
c
.
PackerUserVars
// Prepare the errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
// Set defaults.
if
c
.
Network
==
""
{
c
.
Network
=
"default"
...
...
@@ -104,33 +104,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
.
SSHPort
=
22
}
// Process Templates
templates
:=
map
[
string
]
*
string
{
"account_file"
:
&
c
.
AccountFile
,
"disk_name"
:
&
c
.
DiskName
,
"image_name"
:
&
c
.
ImageName
,
"image_description"
:
&
c
.
ImageDescription
,
"instance_name"
:
&
c
.
InstanceName
,
"machine_type"
:
&
c
.
MachineType
,
"network"
:
&
c
.
Network
,
"project_id"
:
&
c
.
ProjectId
,
"source_image"
:
&
c
.
SourceImage
,
"source_image_project_id"
:
&
c
.
SourceImageProjectId
,
"ssh_username"
:
&
c
.
SSHUsername
,
"ssh_timeout"
:
&
c
.
RawSSHTimeout
,
"state_timeout"
:
&
c
.
RawStateTimeout
,
"zone"
:
&
c
.
Zone
,
}
for
n
,
ptr
:=
range
templates
{
var
err
error
*
ptr
,
err
=
c
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
n
,
err
))
}
}
var
errs
*
packer
.
MultiError
// Process required parameters.
if
c
.
ProjectId
==
""
{
...
...
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