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
55b0b586
Commit
55b0b586
authored
Aug 30, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/chef-solo: code re-org
parent
893c9e02
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
provisioner/chef-solo/provisioner.go
provisioner/chef-solo/provisioner.go
+40
-40
No files found.
provisioner/chef-solo/provisioner.go
View file @
55b0b586
...
...
@@ -145,46 +145,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
return
nil
}
func
(
p
*
Provisioner
)
processJsonUserVars
()
(
map
[
string
]
interface
{},
error
)
{
jsonBytes
,
err
:=
json
.
Marshal
(
p
.
config
.
Json
)
if
err
!=
nil
{
// This really shouldn't happen since we literally just unmarshalled
panic
(
err
)
}
// Copy the user variables so that we can restore them later, and
// make sure we make the quotes JSON-friendly in the user variables.
originalUserVars
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
p
.
config
.
tpl
.
UserVars
{
originalUserVars
[
k
]
=
v
}
// Make sure we reset them no matter what
defer
func
()
{
p
.
config
.
tpl
.
UserVars
=
originalUserVars
}()
// Make the current user variables JSON string safe.
for
k
,
v
:=
range
p
.
config
.
tpl
.
UserVars
{
v
=
strings
.
Replace
(
v
,
`\`
,
`\\`
,
-
1
)
v
=
strings
.
Replace
(
v
,
`"`
,
`\"`
,
-
1
)
p
.
config
.
tpl
.
UserVars
[
k
]
=
v
}
// Process the bytes with the template processor
jsonBytesProcessed
,
err
:=
p
.
config
.
tpl
.
Process
(
string
(
jsonBytes
),
nil
)
if
err
!=
nil
{
return
nil
,
err
}
var
result
map
[
string
]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
jsonBytesProcessed
),
&
result
);
err
!=
nil
{
return
nil
,
err
}
return
result
,
nil
}
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
error
{
if
!
p
.
config
.
SkipInstall
{
if
err
:=
p
.
installChef
(
ui
,
comm
);
err
!=
nil
{
...
...
@@ -361,6 +321,46 @@ func (p *Provisioner) installChef(ui packer.Ui, comm packer.Communicator) error
return
nil
}
func
(
p
*
Provisioner
)
processJsonUserVars
()
(
map
[
string
]
interface
{},
error
)
{
jsonBytes
,
err
:=
json
.
Marshal
(
p
.
config
.
Json
)
if
err
!=
nil
{
// This really shouldn't happen since we literally just unmarshalled
panic
(
err
)
}
// Copy the user variables so that we can restore them later, and
// make sure we make the quotes JSON-friendly in the user variables.
originalUserVars
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
p
.
config
.
tpl
.
UserVars
{
originalUserVars
[
k
]
=
v
}
// Make sure we reset them no matter what
defer
func
()
{
p
.
config
.
tpl
.
UserVars
=
originalUserVars
}()
// Make the current user variables JSON string safe.
for
k
,
v
:=
range
p
.
config
.
tpl
.
UserVars
{
v
=
strings
.
Replace
(
v
,
`\`
,
`\\`
,
-
1
)
v
=
strings
.
Replace
(
v
,
`"`
,
`\"`
,
-
1
)
p
.
config
.
tpl
.
UserVars
[
k
]
=
v
}
// Process the bytes with the template processor
jsonBytesProcessed
,
err
:=
p
.
config
.
tpl
.
Process
(
string
(
jsonBytes
),
nil
)
if
err
!=
nil
{
return
nil
,
err
}
var
result
map
[
string
]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
jsonBytesProcessed
),
&
result
);
err
!=
nil
{
return
nil
,
err
}
return
result
,
nil
}
var
DefaultConfigTemplate
=
`
cookbook_path [{{.CookbookPaths}}]
`
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