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
73bbfab8
Commit
73bbfab8
authored
Jan 25, 2014
by
Bailey Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding chef-client provisioner
parent
1a57e389
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
740 additions
and
0 deletions
+740
-0
plugin/provisioner-chef-client/main.go
plugin/provisioner-chef-client/main.go
+10
-0
plugin/provisioner-chef-client/main_test.go
plugin/provisioner-chef-client/main_test.go
+1
-0
provisioner/chef-client/provisioner.go
provisioner/chef-client/provisioner.go
+546
-0
provisioner/chef-client/provisioner_test.go
provisioner/chef-client/provisioner_test.go
+183
-0
No files found.
plugin/provisioner-chef-client/main.go
0 → 100644
View file @
73bbfab8
package
main
import
(
"github.com/mitchellh/packer/packer/plugin"
"github.com/mitchellh/packer/provisioner/chef-client"
)
func
main
()
{
plugin
.
ServeProvisioner
(
new
(
chefclient
.
Provisioner
))
}
plugin/provisioner-chef-client/main_test.go
0 → 100644
View file @
73bbfab8
package
main
provisioner/chef-client/provisioner.go
0 → 100644
View file @
73bbfab8
This diff is collapsed.
Click to expand it.
provisioner/chef-client/provisioner_test.go
0 → 100644
View file @
73bbfab8
package
chefclient
import
(
"github.com/mitchellh/packer/packer"
"io/ioutil"
"os"
"testing"
)
func
testConfig
()
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{}
}
func
TestProvisioner_Impl
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
&
Provisioner
{}
if
_
,
ok
:=
raw
.
(
packer
.
Provisioner
);
!
ok
{
t
.
Fatalf
(
"must be a Provisioner"
)
}
}
func
TestProvisionerPrepare_configTemplate
(
t
*
testing
.
T
)
{
var
err
error
var
p
Provisioner
// Test no config template
config
:=
testConfig
()
delete
(
config
,
"config_template"
)
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
// Test with a file
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
Remove
(
tf
.
Name
())
config
=
testConfig
()
config
[
"config_template"
]
=
tf
.
Name
()
p
=
Provisioner
{}
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
// Test with a directory
td
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
RemoveAll
(
td
)
config
=
testConfig
()
config
[
"config_template"
]
=
td
p
=
Provisioner
{}
err
=
p
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have err"
)
}
}
func
TestProvisionerPrepare_cookbookPaths
(
t
*
testing
.
T
)
{
var
p
Provisioner
path1
,
err
:=
ioutil
.
TempDir
(
""
,
"cookbooks_one"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
path2
,
err
:=
ioutil
.
TempDir
(
""
,
"cookbooks_two"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
rolesPath
,
err
:=
ioutil
.
TempDir
(
""
,
"roles"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
dataBagsPath
,
err
:=
ioutil
.
TempDir
(
""
,
"data_bags"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
Remove
(
path1
)
defer
os
.
Remove
(
path2
)
defer
os
.
Remove
(
rolesPath
)
defer
os
.
Remove
(
dataBagsPath
)
config
:=
testConfig
()
config
[
"cookbook_paths"
]
=
[]
string
{
path1
,
path2
}
config
[
"roles_path"
]
=
rolesPath
config
[
"data_bags_path"
]
=
dataBagsPath
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
len
(
p
.
config
.
CookbookPaths
)
!=
2
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
CookbookPaths
)
}
if
p
.
config
.
CookbookPaths
[
0
]
!=
path1
||
p
.
config
.
CookbookPaths
[
1
]
!=
path2
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
CookbookPaths
)
}
if
p
.
config
.
RolesPath
!=
rolesPath
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
RolesPath
)
}
if
p
.
config
.
DataBagsPath
!=
dataBagsPath
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
DataBagsPath
)
}
}
func
TestProvisionerPrepare_dataBagsPath
(
t
*
testing
.
T
)
{
var
p
Provisioner
dataBagsPath
,
err
:=
ioutil
.
TempDir
(
""
,
"data_bags"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
Remove
(
dataBagsPath
)
config
:=
testConfig
()
config
[
"data_bags_path"
]
=
dataBagsPath
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
p
.
config
.
DataBagsPath
!=
dataBagsPath
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
DataBagsPath
)
}
}
func
TestProvisionerPrepare_rolesPath
(
t
*
testing
.
T
)
{
var
p
Provisioner
rolesPath
,
err
:=
ioutil
.
TempDir
(
""
,
"roles"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
Remove
(
rolesPath
)
config
:=
testConfig
()
config
[
"roles_path"
]
=
rolesPath
err
=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
p
.
config
.
RolesPath
!=
rolesPath
{
t
.
Fatalf
(
"unexpected: %#v"
,
p
.
config
.
RolesPath
)
}
}
func
TestProvisionerPrepare_json
(
t
*
testing
.
T
)
{
config
:=
testConfig
()
config
[
"json"
]
=
map
[
string
]
interface
{}{
"foo"
:
"{{ user `foo` }}"
,
}
config
[
packer
.
UserVariablesConfigKey
]
=
map
[
string
]
string
{
"foo"
:
`"bar\baz"`
,
}
var
p
Provisioner
err
:=
p
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
p
.
config
.
Json
[
"foo"
]
!=
`"bar\baz"`
{
t
.
Fatalf
(
"bad: %#v"
,
p
.
config
.
Json
)
}
}
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