berkshelf 0.6.0.beta2 → 0.6.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -2
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/README.md +1 -0
- data/Thorfile +7 -0
- data/berkshelf.gemspec +4 -1
- data/features/config.feature +97 -0
- data/features/config_command.feature +10 -0
- data/features/cookbook_command.feature +12 -12
- data/features/default_locations.feature +5 -0
- data/features/install.feature +16 -0
- data/features/json_formatter.feature +1 -1
- data/features/step_definitions/cli_steps.rb +5 -1
- data/features/step_definitions/filesystem_steps.rb +45 -23
- data/features/upload_command.feature +4 -4
- data/generator_files/Gemfile.erb +2 -2
- data/generator_files/Vagrantfile.erb +34 -13
- data/generator_files/config.json +22 -0
- data/lib/berkshelf/cli.rb +24 -9
- data/lib/berkshelf/config.rb +51 -0
- data/lib/berkshelf/config_generator.rb +8 -0
- data/lib/berkshelf/config_validator.rb +78 -0
- data/lib/berkshelf/cookbook_generator.rb +2 -2
- data/lib/berkshelf/core_ext/file_utils.rb +36 -0
- data/lib/berkshelf/downloader.rb +41 -14
- data/lib/berkshelf/errors.rb +20 -0
- data/lib/berkshelf/formatters/human_readable.rb +7 -0
- data/lib/berkshelf/git.rb +13 -3
- data/lib/berkshelf/init_generator.rb +17 -4
- data/lib/berkshelf/locations/chef_api_location.rb +1 -1
- data/lib/berkshelf/locations/git_location.rb +1 -1
- data/lib/berkshelf/locations/site_location.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf.rb +17 -10
- data/spec/support/knife.rb +1 -1
- data/spec/support/matchers/file_system_matchers.rb +16 -1
- data/spec/unit/berkshelf/config_spec.rb +91 -0
- data/spec/unit/berkshelf/config_validator_spec.rb +68 -0
- data/spec/unit/berkshelf/cookbook_source_spec.rb +4 -4
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +23 -0
- data/spec/unit/berkshelf/init_generator_spec.rb +34 -32
- data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +1 -1
- data/spec/unit/berkshelf/lockfile_spec.rb +2 -2
- data/spec/unit/berkshelf/resolver_spec.rb +1 -1
- data/spec/unit/berkshelf/uploader_spec.rb +1 -1
- metadata +68 -5
- data/lib/vagrant_init.rb +0 -2
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Berkshelf
|
2
|
+
[![Build Status](https://travis-ci.org/RiotGames/berkshelf.png)](https://travis-ci.org/RiotGames/berkshelf)
|
2
3
|
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/RiotGames/berkshelf)
|
3
4
|
|
4
5
|
Manage a Cookbook or an Application's Cookbook dependencies
|
data/Thorfile
CHANGED
@@ -36,6 +36,13 @@ class Default < Thor
|
|
36
36
|
exec "cucumber --color --format progress --tags ~@no_run"
|
37
37
|
end
|
38
38
|
|
39
|
+
desc "ci", "Run all test suites"
|
40
|
+
def ci
|
41
|
+
ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing
|
42
|
+
exec "rspec --tag ~chef_server --tag ~focus spec &&
|
43
|
+
cucumber --format progress --tags ~@chef_server"
|
44
|
+
end
|
45
|
+
|
39
46
|
class VCR < Thor
|
40
47
|
namespace :vcr
|
41
48
|
|
data/berkshelf.gemspec
CHANGED
@@ -16,14 +16,17 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.version = Berkshelf::VERSION
|
17
17
|
s.required_ruby_version = ">= 1.9.1"
|
18
18
|
|
19
|
+
s.add_runtime_dependency 'chozo', '>= 0.1.0'
|
19
20
|
s.add_runtime_dependency 'ridley', '>= 0.0.5'
|
20
|
-
s.add_runtime_dependency 'solve', '>= 0.
|
21
|
+
s.add_runtime_dependency 'solve', '>= 0.4.0.rc1'
|
21
22
|
s.add_runtime_dependency 'chef', '~> 10.12'
|
22
23
|
s.add_runtime_dependency 'minitar'
|
23
24
|
s.add_runtime_dependency 'thor', '~> 0.16.0'
|
24
25
|
s.add_runtime_dependency 'vagrant', '~> 1.0.5'
|
25
26
|
s.add_runtime_dependency 'activesupport'
|
26
27
|
s.add_runtime_dependency 'multi_json'
|
28
|
+
s.add_runtime_dependency 'hashie'
|
29
|
+
s.add_runtime_dependency 'activemodel'
|
27
30
|
|
28
31
|
s.add_development_dependency 'redcarpet'
|
29
32
|
s.add_development_dependency 'cucumber'
|
@@ -0,0 +1,97 @@
|
|
1
|
+
Feature: cookbook creation with a config file
|
2
|
+
As a Cookbook author
|
3
|
+
I want to quickly generate a cookbook with my own customizations
|
4
|
+
So that I don't have to spend time modifying the default generated output each time
|
5
|
+
|
6
|
+
Scenario: creating a new cookbook when no Berkshelf config exists
|
7
|
+
Given I do not have a Berkshelf config file
|
8
|
+
When I run the cookbook command to create "sparkle_motion"
|
9
|
+
Then the resulting "sparkle_motion" Vagrantfile should contain:
|
10
|
+
| config.vm.host_name = "sparkle_motion-berkshelf" |
|
11
|
+
| config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal" |
|
12
|
+
| config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box" |
|
13
|
+
And the exit status should be 0
|
14
|
+
|
15
|
+
Scenario: creating a new cookbook using a Berkshelf config
|
16
|
+
Given I have a Berkshelf config file containing:
|
17
|
+
"""
|
18
|
+
{
|
19
|
+
"vagrant": {
|
20
|
+
"vm": {
|
21
|
+
"box": "my_box",
|
22
|
+
"box_url": "http://files.vagrantup.com/lucid64.box",
|
23
|
+
"forward_port": {
|
24
|
+
"12345": "54321"
|
25
|
+
},
|
26
|
+
"host_name": "my_host",
|
27
|
+
"network": {
|
28
|
+
"bridged": true,
|
29
|
+
"hostonly": "12.34.56.78"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
"""
|
35
|
+
When I run the cookbook command to create "sparkle_motion"
|
36
|
+
Then the resulting "sparkle_motion" Vagrantfile should contain:
|
37
|
+
| config.vm.box = "my_box" |
|
38
|
+
| config.vm.box_url = "http://files.vagrantup.com/lucid64.box" |
|
39
|
+
| config.vm.forward_port 12345, 54321 |
|
40
|
+
| config.vm.host_name = "my_host" |
|
41
|
+
| config.vm.network :hostonly, "12.34.56.78" |
|
42
|
+
| config.vm.network :bridged |
|
43
|
+
And the exit status should be 0
|
44
|
+
|
45
|
+
Scenario: creating a new cookbook using a partial Berkshelf config
|
46
|
+
Given I have a Berkshelf config file containing:
|
47
|
+
"""
|
48
|
+
{
|
49
|
+
"vagrant": {
|
50
|
+
"vm": {
|
51
|
+
"forward_port": {
|
52
|
+
"12345": "54321"
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
"""
|
58
|
+
When I run the cookbook command to create "sparkle_motion"
|
59
|
+
Then the resulting "sparkle_motion" Vagrantfile should contain:
|
60
|
+
| config.vm.forward_port 12345, 54321 |
|
61
|
+
And the exit status should be 0
|
62
|
+
|
63
|
+
Scenario: creating a new cookbook using an invalid Berkshelf config
|
64
|
+
Given I have a Berkshelf config file containing:
|
65
|
+
"""
|
66
|
+
{
|
67
|
+
"wat": null
|
68
|
+
}
|
69
|
+
"""
|
70
|
+
When I run the cookbook command to create "sparkle_motion"
|
71
|
+
Then the output should contain "Invalid configuration"
|
72
|
+
And the output should contain "wat is not a valid key"
|
73
|
+
And the CLI should exit with the status code for error "InvalidConfiguration"
|
74
|
+
|
75
|
+
Scenario: creating a new cookbook with a chef client config
|
76
|
+
Given I have a Berkshelf config file containing:
|
77
|
+
"""
|
78
|
+
{
|
79
|
+
"vagrant": {
|
80
|
+
"chef": {
|
81
|
+
"chef_server_url": "localhost:4000",
|
82
|
+
"validation_client_name": "my_client-validator",
|
83
|
+
"validation_key_path": "/a/b/c/my_client-validator.pem"
|
84
|
+
},
|
85
|
+
"vm": {
|
86
|
+
"provision": "chef_client"
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
"""
|
91
|
+
When I run the cookbook command to create "sparkle_motion"
|
92
|
+
Then the resulting "sparkle_motion" Vagrantfile should contain:
|
93
|
+
| config.vm.provision :chef_client |
|
94
|
+
| chef.chef_server_url = "localhost:4000" |
|
95
|
+
| chef.validation_client_name = "my_client-validator" |
|
96
|
+
| chef.validation_key_path = "/a/b/c/my_client-validator.pem" |
|
97
|
+
Then the exit status should be 0
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: config command
|
2
|
+
As a Cookbook author
|
3
|
+
I want to quickly generate a Berkshelf config
|
4
|
+
So I can easily tell which options are available to me
|
5
|
+
|
6
|
+
Scenario: creating a new config
|
7
|
+
Given I do not have a Berkshelf config file
|
8
|
+
When I run the config command
|
9
|
+
Then I should have a Berkshelf config file
|
10
|
+
And the exit status should be 0
|
@@ -8,18 +8,6 @@ Feature: cookbook command
|
|
8
8
|
Then I should have a new cookbook skeleton "sparkle_motion"
|
9
9
|
And the exit status should be 0
|
10
10
|
|
11
|
-
Scenario: creating a new cookbook skeleton with Vagrant support
|
12
|
-
When I run the cookbook command to create "sparkle_motion" with options:
|
13
|
-
| --vagrant |
|
14
|
-
Then I should have a new cookbook skeleton "sparkle_motion" with Vagrant support
|
15
|
-
And the exit status should be 0
|
16
|
-
|
17
|
-
Scenario: creating a new cookbook skeleton with Git support
|
18
|
-
When I run the cookbook command to create "sparkle_motion" with options:
|
19
|
-
| --git |
|
20
|
-
Then I should have a new cookbook skeleton "sparkle_motion" with Git support
|
21
|
-
And the exit status should be 0
|
22
|
-
|
23
11
|
Scenario: creating a new cookbook skeleton with Foodcritic support
|
24
12
|
When I run the cookbook command to create "sparkle_motion" with options:
|
25
13
|
| --foodcritic |
|
@@ -37,3 +25,15 @@ Feature: cookbook command
|
|
37
25
|
| --no-bundler |
|
38
26
|
Then I should have a new cookbook skeleton "sparkle_motion" without Bundler support
|
39
27
|
And the exit status should be 0
|
28
|
+
|
29
|
+
Scenario: creating a new cookbook skeleton without Git support
|
30
|
+
When I run the cookbook command to create "sparkle_motion" with options:
|
31
|
+
| --skip-git |
|
32
|
+
Then I should have a new cookbook skeleton "sparkle_motion" without Git support
|
33
|
+
And the exit status should be 0
|
34
|
+
|
35
|
+
Scenario: creating a new cookbook skeleton without Vagrant support
|
36
|
+
When I run the cookbook command to create "sparkle_motion" with options:
|
37
|
+
| --skip-vagrant |
|
38
|
+
Then I should have a new cookbook skeleton "sparkle_motion" without Vagrant support
|
39
|
+
And the exit status should be 0
|
@@ -4,6 +4,7 @@ Feature: Berksfile default locations
|
|
4
4
|
So I can set the precedence of where cookbook sources are downloaded from or define an alternate location for all
|
5
5
|
cookbook sources to attempt to retrieve from
|
6
6
|
|
7
|
+
@chef_server
|
7
8
|
Scenario: with a default chef_api(1) and site(2) location with a cookbook source that is satisfied by the chef_api(1) location
|
8
9
|
Given I write to "Berksfile" with:
|
9
10
|
"""
|
@@ -23,6 +24,7 @@ Feature: Berksfile default locations
|
|
23
24
|
| artifact | 0.10.0 |
|
24
25
|
And the exit status should be 0
|
25
26
|
|
27
|
+
@chef_server
|
26
28
|
Scenario: with a default chef_api(1) and site(2) location with a cookbook source that is not satisfied by the chef_api(1) location
|
27
29
|
Given I write to "Berksfile" with:
|
28
30
|
"""
|
@@ -42,6 +44,7 @@ Feature: Berksfile default locations
|
|
42
44
|
| artifact | 0.10.0 |
|
43
45
|
And the exit status should be 0
|
44
46
|
|
47
|
+
@chef_server
|
45
48
|
Scenario: with a default site(1) and chef_api(2) location with a cookbook source that is satisfied by the site(1) location
|
46
49
|
Given I write to "Berksfile" with:
|
47
50
|
"""
|
@@ -61,6 +64,7 @@ Feature: Berksfile default locations
|
|
61
64
|
| artifact | 0.10.0 |
|
62
65
|
And the exit status should be 0
|
63
66
|
|
67
|
+
@chef_server
|
64
68
|
Scenario: with a default chef_api(1) location and a cookbook source that is satisfied by the chef_api(1) location but has an explicit location set
|
65
69
|
Given I write to "Berksfile" with:
|
66
70
|
"""
|
@@ -79,6 +83,7 @@ Feature: Berksfile default locations
|
|
79
83
|
| artifact | 0.10.0 |
|
80
84
|
And the exit status should be 0
|
81
85
|
|
86
|
+
@chef_server
|
82
87
|
Scenario: with a defualt chef_api(1) location and a cookbook source that is not satisfied by it
|
83
88
|
Given I write to "Berksfile" with:
|
84
89
|
"""
|
data/features/install.feature
CHANGED
@@ -194,6 +194,7 @@ Feature: install cookbooks from a Berksfile
|
|
194
194
|
"""
|
195
195
|
And the CLI should exit with the status code for error "InternalError"
|
196
196
|
|
197
|
+
@chef_server
|
197
198
|
Scenario: with a cookbook definition containing a chef_api source location
|
198
199
|
Given I write to "Berksfile" with:
|
199
200
|
"""
|
@@ -258,3 +259,18 @@ Feature: install cookbooks from a Berksfile
|
|
258
259
|
Source 'artifact' is a 'chef_api' location with a URL for it's value but is missing options: 'node_name', 'client_key'.
|
259
260
|
"""
|
260
261
|
And the CLI should exit with the status code for error "InvalidChefAPILocation"
|
262
|
+
|
263
|
+
Scenario: with a git error during download
|
264
|
+
Given I write to "Berksfile" with:
|
265
|
+
"""
|
266
|
+
cookbook "ohai"
|
267
|
+
cookbook "doesntexist", git: "git://github.com/asdjhfkljashflkjashfakljsf"
|
268
|
+
"""
|
269
|
+
When I run the install command
|
270
|
+
Then the output should contain:
|
271
|
+
"""
|
272
|
+
Installing ohai (1.1.2) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
|
273
|
+
Failed to download doesntexist from git: 'git://github.com/asdjhfkljashflkjashfakljsf'
|
274
|
+
An error occured during Git execution:
|
275
|
+
"""
|
276
|
+
And the CLI should exit with the status code for error "GitError"
|
@@ -29,7 +29,7 @@ Feature: --format json
|
|
29
29
|
And the JSON at "cookbooks/0/version" should be "1.2.4"
|
30
30
|
And the JSON should not have "cookbooks/0/location"
|
31
31
|
|
32
|
-
@
|
32
|
+
@chef_server
|
33
33
|
Scenario: JSON output when running the upload command
|
34
34
|
Given a Berksfile with path location sources to fixtures:
|
35
35
|
| example_cookbook | example_cookbook-0.5.0 |
|
@@ -59,13 +59,17 @@ When /^I run the upload command with flags:$/ do |flags|
|
|
59
59
|
end
|
60
60
|
|
61
61
|
When /^I run the cookbook command to create "(.*?)"$/ do |name|
|
62
|
-
run_simple(unescape("berks cookbook #{name}"))
|
62
|
+
run_simple(unescape("berks cookbook #{name}"), false)
|
63
63
|
end
|
64
64
|
|
65
65
|
When /^I run the cookbook command to create "(.*?)" with options:$/ do |name, options|
|
66
66
|
run_simple(unescape("berks cookbook #{name} #{options.raw.join(" ")}"))
|
67
67
|
end
|
68
68
|
|
69
|
+
When /^I run the config command$/ do
|
70
|
+
run_simple unescape("berks config")
|
71
|
+
end
|
72
|
+
|
69
73
|
Then /^the CLI should exit with the status code for error "(.*?)"$/ do |error_constant|
|
70
74
|
exit_status = Berkshelf.const_get(error_constant).status_code
|
71
75
|
assert_exit_status(exit_status)
|
@@ -18,6 +18,16 @@ Given /^I do not have a Berksfile\.lock$/ do
|
|
18
18
|
in_current_dir { FileUtils.rm_f(Berkshelf::Lockfile::DEFAULT_FILENAME) }
|
19
19
|
end
|
20
20
|
|
21
|
+
Given /^I have a Berkshelf config file containing:$/ do |contents|
|
22
|
+
write_file File.expand_path("~/.berkshelf/config.json"), contents
|
23
|
+
end
|
24
|
+
|
25
|
+
Given /^I do not have a Berkshelf config file$/ do
|
26
|
+
file = File.expand_path "~/.berkshelf/config.json"
|
27
|
+
|
28
|
+
remove_file file if File.exists? file
|
29
|
+
end
|
30
|
+
|
21
31
|
Given /^the cookbook "(.*?)" has the file "(.*?)" with:$/ do |cookbook_name, file_name, content|
|
22
32
|
write_file(File.join(cookbook_name, file_name), content)
|
23
33
|
end
|
@@ -85,27 +95,17 @@ Then /^I should have a new cookbook skeleton "(.*?)"$/ do |name|
|
|
85
95
|
directory "templates" do
|
86
96
|
directory "default"
|
87
97
|
end
|
88
|
-
file "
|
89
|
-
file "
|
98
|
+
file ".gitignore"
|
99
|
+
file "chefignore"
|
90
100
|
file "Berksfile" do
|
91
101
|
contains "metadata"
|
92
102
|
end
|
93
|
-
file "chefignore"
|
94
|
-
file "Berksfile"
|
95
103
|
file "Gemfile" do
|
96
104
|
contains "gem 'berkshelf'"
|
97
|
-
end
|
98
|
-
}
|
99
|
-
end
|
100
|
-
|
101
|
-
Then /^I should have a new cookbook skeleton "(.*?)" with Vagrant support$/ do |name|
|
102
|
-
steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
|
103
|
-
|
104
|
-
cb_path = Pathname.new(current_dir).join(name)
|
105
|
-
cb_path.should have_structure {
|
106
|
-
file "Gemfile" do
|
107
105
|
contains "gem 'vagrant'"
|
108
106
|
end
|
107
|
+
file "metadata.rb"
|
108
|
+
file "README.md"
|
109
109
|
file "Vagrantfile" do
|
110
110
|
contains "require 'berkshelf/vagrant'"
|
111
111
|
contains "recipe[#{name}::default]"
|
@@ -113,15 +113,6 @@ Then /^I should have a new cookbook skeleton "(.*?)" with Vagrant support$/ do |
|
|
113
113
|
}
|
114
114
|
end
|
115
115
|
|
116
|
-
Then /^I should have a new cookbook skeleton "(.*?)" with Git support$/ do |name|
|
117
|
-
steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
|
118
|
-
|
119
|
-
cb_path = Pathname.new(current_dir).join(name)
|
120
|
-
cb_path.should have_structure {
|
121
|
-
file ".gitignore"
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
116
|
Then /^I should have a new cookbook skeleton "(.*?)" with Foodcritic support$/ do |name|
|
126
117
|
steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
|
127
118
|
|
@@ -178,6 +169,21 @@ Then /^I should have a new cookbook skeleton "(.*?)" without Bundler support$/ d
|
|
178
169
|
}
|
179
170
|
end
|
180
171
|
|
172
|
+
Then /^I should have a new cookbook skeleton "(.*?)" without Git support$/ do |name|
|
173
|
+
Pathname.new(current_dir).join(name).should have_structure {
|
174
|
+
no_file ".gitignore"
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
Then /^I should have a new cookbook skeleton "(.*?)" without Vagrant support$/ do |name|
|
179
|
+
Pathname.new(current_dir).join(name).should have_structure {
|
180
|
+
file "Gemfile" do
|
181
|
+
does_not_contain "gem 'vagrant'"
|
182
|
+
end
|
183
|
+
no_file "Vagrantfile"
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
181
187
|
Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
|
182
188
|
check_file_presence(files.raw.map{|file_row| File.join(name, file_row[0])}, true)
|
183
189
|
end
|
@@ -195,6 +201,16 @@ Then /^the file "(.*?)" in the cookbook "(.*?)" should contain:$/ do |file_name,
|
|
195
201
|
}
|
196
202
|
end
|
197
203
|
|
204
|
+
Then /^the resulting "(.+)" Vagrantfile should contain:$/ do |cookbook_name, content|
|
205
|
+
Pathname.new(current_dir).join(cookbook_name).should have_structure {
|
206
|
+
file "Vagrantfile" do
|
207
|
+
content.respond_to?(:raw) ?
|
208
|
+
content.raw.flatten.each { |string| contains string } :
|
209
|
+
contains(content)
|
210
|
+
end
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
198
214
|
Then /^the directory "(.*?)" should have the following files:$/ do |name, files|
|
199
215
|
check_file_presence(files.raw.map{|file_row| File.join(name, file_row[0])}, true)
|
200
216
|
end
|
@@ -218,3 +234,9 @@ end
|
|
218
234
|
Then /^the current directory should not have the following files:$/ do |files|
|
219
235
|
check_file_presence(files.raw.map{|file_row| file_row[0]}, false)
|
220
236
|
end
|
237
|
+
|
238
|
+
Then /^I should have a Berkshelf config file$/ do
|
239
|
+
Pathname.new(ENV['HOME']).join(".berkshelf").should have_structure {
|
240
|
+
file "config.json"
|
241
|
+
}
|
242
|
+
end
|
@@ -3,7 +3,7 @@ Feature: upload command
|
|
3
3
|
I need a way to upload cookbooks to a Chef server that I have installed into my Bookshelf
|
4
4
|
So they are available to Chef clients
|
5
5
|
|
6
|
-
@no_run @
|
6
|
+
@no_run @chef_server
|
7
7
|
Scenario: running the upload command when the Sources in the Berksfile are already installed
|
8
8
|
Given I write to "Berksfile" with:
|
9
9
|
"""
|
@@ -23,7 +23,7 @@ Feature: upload command
|
|
23
23
|
| openssl | 1.0.0 |
|
24
24
|
And the exit status should be 0
|
25
25
|
|
26
|
-
@
|
26
|
+
@chef_server
|
27
27
|
Scenario: running the upload command when the Sources in the Berksfile have not been installed
|
28
28
|
Given I write to "Berksfile" with:
|
29
29
|
"""
|
@@ -42,7 +42,7 @@ Feature: upload command
|
|
42
42
|
| openssl | 1.0.0 |
|
43
43
|
And the exit status should be 0
|
44
44
|
|
45
|
-
@
|
45
|
+
@chef_server
|
46
46
|
Scenario: running the upload command with a Berksfile containing a source that has a path location
|
47
47
|
Given a Berksfile with path location sources to fixtures:
|
48
48
|
| example_cookbook | example_cookbook-0.5.0 |
|
@@ -55,7 +55,7 @@ Feature: upload command
|
|
55
55
|
| example_cookbook | 0.5.0 |
|
56
56
|
And the exit status should be 0
|
57
57
|
|
58
|
-
@
|
58
|
+
@chef_server
|
59
59
|
Scenario: running the upload command with a Berksfile containing a source that has a Git location
|
60
60
|
Given I write to "Berksfile" with:
|
61
61
|
"""
|
data/generator_files/Gemfile.erb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source :rubygems
|
2
2
|
|
3
3
|
gem 'berkshelf'
|
4
4
|
<% if options[:foodcritic] -%>
|
@@ -7,6 +7,6 @@ gem 'thor-foodcritic'
|
|
7
7
|
<% if options[:scmversion] -%>
|
8
8
|
gem 'thor-scmversion'
|
9
9
|
<% end -%>
|
10
|
-
<%
|
10
|
+
<% unless options[:skip_vagrant] -%>
|
11
11
|
gem 'vagrant', '~> 1.0.5'
|
12
12
|
<% end -%>
|
@@ -27,11 +27,24 @@ Vagrant::Config.run do |config|
|
|
27
27
|
# to skip installing and copying to Vagrant's shelf.
|
28
28
|
# config.berkshelf.except = []
|
29
29
|
|
30
|
-
|
30
|
+
<% if options[:berkshelf_config][:vagrant][:vm][:box].present? -%>
|
31
|
+
config.vm.host_name = "<%= options[:berkshelf_config][:vagrant][:vm][:host_name] %>"
|
32
|
+
<% else -%>
|
33
|
+
config.vm.host_name = "<%= "#{cookbook_name}-berkshelf" %>"
|
34
|
+
<% end -%>
|
35
|
+
|
31
36
|
|
32
37
|
# CentOS 6.3
|
38
|
+
<% if options[:berkshelf_config][:vagrant][:vm][:box].present? -%>
|
39
|
+
config.vm.box = "<%= options[:berkshelf_config][:vagrant][:vm][:box] %>"
|
40
|
+
<% else %>
|
33
41
|
config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal"
|
42
|
+
<% end -%>
|
43
|
+
<% if options[:berkshelf_config][:vagrant][:vm][:box_url].present? -%>
|
44
|
+
config.vm.box_url = "<%= options[:berkshelf_config][:vagrant][:vm][:box_url] %>"
|
45
|
+
<% else %>
|
34
46
|
config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
|
47
|
+
<% end -%>
|
35
48
|
|
36
49
|
# Boot with a GUI so you can see the screen. (Default is headless)
|
37
50
|
# config.vm.boot_mode = :gui
|
@@ -40,16 +53,22 @@ Vagrant::Config.run do |config|
|
|
40
53
|
# via the IP. Host-only networks can talk to the host machine as well as
|
41
54
|
# any other machines on the same network, but cannot be accessed (through this
|
42
55
|
# network interface) by any external networks.
|
43
|
-
config.vm.network :hostonly, "33.33.33.10"
|
56
|
+
# config.vm.network :hostonly, "33.33.33.10"
|
57
|
+
<% if options[:berkshelf_config][:vagrant][:vm][:network][:hostonly].present? -%>
|
58
|
+
config.vm.network :hostonly, "<%= options[:berkshelf_config][:vagrant][:vm][:network][:hostonly] %>"
|
59
|
+
<% end -%>
|
44
60
|
|
45
61
|
# Assign this VM to a bridged network, allowing you to connect directly to a
|
46
62
|
# network using the host's network device. This makes the VM appear as another
|
47
63
|
# physical device on your network.
|
48
|
-
|
64
|
+
<% unless options[:berkshelf_config][:vagrant][:vm][:network][:bridged].present? %># <% end %>config.vm.network :bridged
|
49
65
|
|
50
66
|
# Forward a port from the guest to the host, which allows for outside
|
51
67
|
# computers to access the VM, whereas host only networking does not.
|
52
68
|
# config.vm.forward_port 80, 8080
|
69
|
+
<% options[:berkshelf_config][:vagrant][:vm][:forward_port].each do |guest, host| %>
|
70
|
+
config.vm.forward_port <%= guest %>, <%= host %>
|
71
|
+
<% end if options[:berkshelf_config][:vagrant][:vm][:forward_port].present? %>
|
53
72
|
|
54
73
|
# Share an additional folder to the guest VM. The first argument is
|
55
74
|
# an identifier, the second is the path on the guest to mount the
|
@@ -59,6 +78,17 @@ Vagrant::Config.run do |config|
|
|
59
78
|
config.ssh.max_tries = 40
|
60
79
|
config.ssh.timeout = 120
|
61
80
|
|
81
|
+
<% if options[:berkshelf_config][:vagrant][:vm][:provision] == "chef_client" -%>
|
82
|
+
config.vm.provision :chef_client do |chef|
|
83
|
+
chef.chef_server_url = "<%= options[:berkshelf_config][:vagrant][:chef][:chef_server_url] %>"
|
84
|
+
chef.validation_client_name = "<%= options[:berkshelf_config][:vagrant][:chef][:validation_client_name] %>"
|
85
|
+
chef.validation_key_path = "<%= options[:berkshelf_config][:vagrant][:chef][:validation_key_path] %>"
|
86
|
+
|
87
|
+
chef.run_list = [
|
88
|
+
"recipe[<%= cookbook_name %>::default]"
|
89
|
+
]
|
90
|
+
end
|
91
|
+
<% else -%>
|
62
92
|
config.vm.provision :chef_solo do |chef|
|
63
93
|
chef.json = {
|
64
94
|
:mysql => {
|
@@ -72,14 +102,5 @@ Vagrant::Config.run do |config|
|
|
72
102
|
"recipe[<%= cookbook_name %>::default]"
|
73
103
|
]
|
74
104
|
end
|
75
|
-
|
76
|
-
# config.vm.provision :chef_client do |chef|
|
77
|
-
# chef.chef_server_url = 'https://api.opscode.com/organizations/vialstudios'
|
78
|
-
# chef.validation_client_name = 'vialstudios-validator'
|
79
|
-
# chef.validation_key_path = '/Users/reset/.chef/vialstudios-validator.pem'
|
80
|
-
#
|
81
|
-
# chef.run_list = [
|
82
|
-
# "recipe[<%= cookbook_name %>::default]"
|
83
|
-
# ]
|
84
|
-
# end
|
105
|
+
<% end -%>
|
85
106
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"vagrant": {
|
3
|
+
"chef": {
|
4
|
+
"chef_server_url": "https://api.opscode.com/organizations/ORGNAME",
|
5
|
+
"validation_client_name": "ORGNAME-validator",
|
6
|
+
"validation_key_path": "~/validation.pem"
|
7
|
+
},
|
8
|
+
"vm": {
|
9
|
+
"box": "base",
|
10
|
+
"box_url": "http://files.vagrantup.com/lucid64.box",
|
11
|
+
"forward_port": {
|
12
|
+
"80": "8080"
|
13
|
+
},
|
14
|
+
"host_name": "berkshelf-cookbook",
|
15
|
+
"network": {
|
16
|
+
"bridged": true,
|
17
|
+
"hostonly": "192.168.33.10"
|
18
|
+
},
|
19
|
+
"provision": "chef_solo"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -27,6 +27,11 @@ module Berkshelf
|
|
27
27
|
map 'ver' => :version
|
28
28
|
map 'book' => :cookbook
|
29
29
|
|
30
|
+
desc "config", "Generate a default Berkshelf configuration file"
|
31
|
+
def config
|
32
|
+
ConfigGenerator.new.invoke_all
|
33
|
+
end
|
34
|
+
|
30
35
|
class_option :config,
|
31
36
|
type: :string,
|
32
37
|
default: Berkshelf::DEFAULT_CONFIG,
|
@@ -145,21 +150,12 @@ module Berkshelf
|
|
145
150
|
Berkshelf.formatter.msg license
|
146
151
|
end
|
147
152
|
|
148
|
-
method_option :vagrant,
|
149
|
-
type: :boolean,
|
150
|
-
desc: "Creates a Vagrantfile and dynamically change other generated files to support Vagrant"
|
151
|
-
method_option :git,
|
152
|
-
type: :boolean,
|
153
|
-
desc: "Creates additional git specific files if your project will be managed by git"
|
154
153
|
method_option :foodcritic,
|
155
154
|
type: :boolean,
|
156
155
|
desc: "Creates a Thorfile with Foodcritic support to lint test your cookbook"
|
157
156
|
method_option :scmversion,
|
158
157
|
type: :boolean,
|
159
158
|
desc: "Creates a Thorfile with SCMVersion support to manage versions for continuous integration"
|
160
|
-
method_option :no_bundler,
|
161
|
-
type: :boolean,
|
162
|
-
desc: "Skips generation of a Gemfile and other Bundler specific support"
|
163
159
|
method_option :license,
|
164
160
|
type: :string,
|
165
161
|
default: "reserved",
|
@@ -173,8 +169,27 @@ module Berkshelf
|
|
173
169
|
type: :string,
|
174
170
|
desc: "Email address of cookbook maintainer",
|
175
171
|
aliases: "-e"
|
172
|
+
method_option :no_bundler,
|
173
|
+
type: :boolean,
|
174
|
+
desc: "Skips generation of a Gemfile and other Bundler specific support"
|
175
|
+
method_option :vagrant,
|
176
|
+
type: :boolean,
|
177
|
+
hide: true
|
178
|
+
method_option :skip_vagrant,
|
179
|
+
type: :boolean,
|
180
|
+
desc: "Skips adding a Vagrantfile and adding supporting gems to the Gemfile"
|
181
|
+
method_option :git,
|
182
|
+
type: :boolean,
|
183
|
+
hide: true
|
184
|
+
method_option :skip_git,
|
185
|
+
type: :boolean,
|
186
|
+
desc: "Skips adding a .gitignore and running git init in the cookbook directory"
|
187
|
+
|
176
188
|
desc "cookbook NAME", "Create a skeleton for a new cookbook"
|
177
189
|
def cookbook(name)
|
190
|
+
Berkshelf.formatter.deprecation "--git is now the default" if options[:git]
|
191
|
+
Berkshelf.formatter.deprecation "--vagrant is now the default" if options[:vagrant]
|
192
|
+
|
178
193
|
::Berkshelf::CookbookGenerator.new([name, File.join(Dir.pwd, name)], options).invoke_all
|
179
194
|
end
|
180
195
|
|