berkshelf 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.4.6
2
+
3
+ - Backport bug fixes from 2.0.2
4
+
1
5
  # 1.4.4
2
6
 
3
7
  - Bump Ridley dependency to 0.12, bringing in many bugfixes.
@@ -29,7 +33,7 @@
29
33
 
30
34
  # 1.3.1
31
35
  - Support for Vagrant 1.1.x
32
- - Move Berkshelf Vagrant plugin into it's [own repository](https://github.com/RiotGames/berkshelf-vagrant)
36
+ - Move Berkshelf Vagrant plugin into it's [own repository](https://github.com/RiotGames/vagrant-berkshelf)
33
37
  - Added -d flag to output debug information in berks command
34
38
  - Various bug fixes in uploading cookbooks
35
39
 
data/CONTRIBUTING.md CHANGED
@@ -34,9 +34,7 @@ Bundler will install all gems and their dependencies required for testing and de
34
34
 
35
35
  ### Running unit (RSpec) and acceptance (Cucumber) tests
36
36
 
37
- Simply copy the `spec/knife.rb.sample` to `spec/knife.rb`, and point it at a
38
- chef server. Berkshelf tests may upload and destroy cookbooks on your chef
39
- server, so be sure to configure a server safe for this task.
37
+ We use Chef Zero - an in-memory Chef Server for running tests. It is automatically managed by the Specs and Cukes. Simply run:
40
38
 
41
39
  $ bundle exec guard start
42
40
 
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec
4
3
 
5
4
  group :development do
6
- gem 'chef-zero', '>= 0.9.9'
5
+ gem 'chef-zero', '~> 1.1'
7
6
  gem 'coolline'
8
7
  gem 'guard', '>= 1.5.0'
9
8
  gem 'guard-cane'
@@ -34,12 +33,3 @@ group :development do
34
33
  gem 'win32console', require: false
35
34
  end
36
35
  end
37
-
38
- group :test do
39
- gem 'fuubar'
40
- gem 'json_spec'
41
- gem 'rake', '>= 0.9.2.2'
42
- gem 'rspec'
43
- gem 'thor'
44
- gem 'webmock'
45
- end
data/Thorfile CHANGED
@@ -46,9 +46,7 @@ class Default < Thor
46
46
  desc "ci", "Run all possible tests on Travis-CI"
47
47
  def ci
48
48
  ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing
49
- unless run_unit("--tag ~chef_server") && run_acceptance("--tags ~@chef_server") && run_quality
50
- exit 1
51
- end
49
+ all
52
50
  end
53
51
 
54
52
  desc "unit", "Run unit tests"
data/berkshelf.gemspec CHANGED
@@ -3,30 +3,30 @@ require File.expand_path('../lib/berkshelf/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.authors = [
6
- "Jamie Winsor",
7
- "Josiah Kiehl",
8
- "Michael Ivey",
9
- "Justin Campbell"
6
+ 'Jamie Winsor',
7
+ 'Josiah Kiehl',
8
+ 'Michael Ivey',
9
+ 'Justin Campbell'
10
10
  ]
11
11
  s.email = [
12
- "reset@riotgames.com",
13
- "jkiehl@riotgames.com",
14
- "michael.ivey@riotgames.com",
15
- "justin.campbell@riotgames.com"
12
+ 'reset@riotgames.com',
13
+ 'jkiehl@riotgames.com',
14
+ 'michael.ivey@riotgames.com',
15
+ 'justin.campbell@riotgames.com'
16
16
  ]
17
17
 
18
18
  s.description = %q{Manages a Cookbook's, or an Application's, Cookbook dependencies}
19
19
  s.summary = s.description
20
- s.homepage = "http://berkshelf.com"
21
- s.license = "Apache 2.0"
20
+ s.homepage = 'http://berkshelf.com'
21
+ s.license = 'Apache 2.0'
22
22
  s.files = `git ls-files`.split($\)
23
23
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
24
24
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
25
- s.name = "berkshelf"
26
- s.require_paths = ["lib"]
25
+ s.name = 'berkshelf'
26
+ s.require_paths = ['lib']
27
27
  s.version = Berkshelf::VERSION
28
- s.required_ruby_version = ">= 1.9.1"
29
- s.required_rubygems_version = ">= 1.8.0"
28
+ s.required_ruby_version = '>= 1.9.1'
29
+ s.required_rubygems_version = '>= 1.8.0'
30
30
 
31
31
  s.add_dependency 'celluloid', '>= 0.14.0'
32
32
  s.add_dependency 'yajl-ruby'
@@ -45,14 +45,23 @@ Gem::Specification.new do |s|
45
45
  s.add_dependency 'retryable'
46
46
  s.add_dependency 'addressable'
47
47
 
48
- s.add_development_dependency 'aruba'
49
- s.add_development_dependency 'cane'
50
- s.add_development_dependency 'json_spec'
51
- s.add_development_dependency 'rake', '>= 0.9.2.2'
52
- s.add_development_dependency 'rspec'
53
- s.add_development_dependency 'simplecov'
54
- s.add_development_dependency 'spork'
55
- s.add_development_dependency 'thor'
56
- s.add_development_dependency 'webmock'
57
- s.add_development_dependency 'vcr', '~> 2.4.0'
48
+ s.add_development_dependency 'aruba', '~> 0.5'
49
+ s.add_development_dependency 'cane', '~> 2.5'
50
+ s.add_development_dependency 'chef-zero', '~> 1.0'
51
+ s.add_development_dependency 'fuubar', '~> 1.1'
52
+ s.add_development_dependency 'json_spec', '~> 1.1'
53
+ s.add_development_dependency 'rake', '~> 0.9'
54
+ s.add_development_dependency 'rspec', '~> 2.13'
55
+ s.add_development_dependency 'spork', '~> 0.9'
56
+ s.add_development_dependency 'vcr', '~> 2.4'
57
+ s.add_development_dependency 'webmock', '~> 1.11'
58
+ s.add_development_dependency 'yard', '~> 0.8'
59
+
60
+ # Guard extensions for development
61
+ s.add_development_dependency 'guard', '~> 1.8'
62
+ s.add_development_dependency 'guard-cane'
63
+ s.add_development_dependency 'guard-cucumber'
64
+ s.add_development_dependency 'guard-rspec'
65
+ s.add_development_dependency 'guard-spork'
66
+ s.add_development_dependency 'guard-yard'
58
67
  end
@@ -9,59 +9,59 @@ Feature: Berksfile default locations
9
9
  Given I write to "Berksfile" with:
10
10
  """
11
11
  chef_api :config
12
- site 'http://cookbooks.opscode.com/api/v1/cookbooks'
12
+ site :opscode
13
13
 
14
- cookbook "artifact", "= 0.10.0"
14
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
15
15
  """
16
16
  And the Chef server has cookbooks:
17
- | artifact | 0.10.0 |
18
- When I run the install command
17
+ | berkshelf-cookbook-fixture | 1.0.0 |
18
+ When I successfully run `berks install`
19
19
  Then the output should contain:
20
20
  """
21
- Installing artifact (0.10.0) from chef_api:
21
+ Installing berkshelf-cookbook-fixture (1.0.0) from chef_api:
22
22
  """
23
23
  And the cookbook store should have the cookbooks:
24
- | artifact | 0.10.0 |
24
+ | berkshelf-cookbook-fixture | 1.0.0 |
25
25
  And the exit status should be 0
26
26
 
27
- @chef_server
27
+ @chef_server @focus
28
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
29
29
  Given I write to "Berksfile" with:
30
30
  """
31
- chef_api :config
32
- site 'http://cookbooks.opscode.com/api/v1/cookbooks'
31
+ # chef_api :config
32
+ site :opscode
33
33
 
34
- cookbook "artifact", "= 0.10.0"
34
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
35
35
  """
36
36
  And the Chef server does not have the cookbooks:
37
- | artifact | 0.10.0 |
38
- When I run the install command
37
+ | berkshelf-cookbook-fixture | 1.0.0 |
38
+ When I successfully run `berks install`
39
39
  Then the output should contain:
40
40
  """
41
- Installing artifact (0.10.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
41
+ Installing berkshelf-cookbook-fixture (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
42
42
  """
43
43
  And the cookbook store should have the cookbooks:
44
- | artifact | 0.10.0 |
44
+ | berkshelf-cookbook-fixture | 1.0.0 |
45
45
  And the exit status should be 0
46
46
 
47
47
  @chef_server
48
48
  Scenario: with a default site(1) and chef_api(2) location with a cookbook source that is satisfied by the site(1) location
49
49
  Given I write to "Berksfile" with:
50
50
  """
51
- site 'http://cookbooks.opscode.com/api/v1/cookbooks'
51
+ site :opscode
52
52
  chef_api :config
53
53
 
54
- cookbook "artifact", "= 0.10.0"
54
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
55
55
  """
56
56
  And the Chef server has cookbooks:
57
- | artifact | 0.10.0 |
57
+ | berkshelf-cookbook-fixture | 1.0.0 |
58
58
  When I run the install command
59
59
  Then the output should contain:
60
60
  """
61
- Installing artifact (0.10.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
61
+ Installing berkshelf-cookbook-fixture (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
62
62
  """
63
63
  And the cookbook store should have the cookbooks:
64
- | artifact | 0.10.0 |
64
+ | berkshelf-cookbook-fixture | 1.0.0 |
65
65
  And the exit status should be 0
66
66
 
67
67
  @chef_server
@@ -70,17 +70,17 @@ Feature: Berksfile default locations
70
70
  """
71
71
  chef_api :config
72
72
 
73
- cookbook 'artifact', '= 0.10.0', site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
73
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0', site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
74
74
  """
75
75
  And the Chef server has cookbooks:
76
- | artifact | 0.10.0 |
76
+ | berkshelf-cookbook-fixture | 1.0.0 |
77
77
  When I run the install command
78
78
  Then the output should contain:
79
79
  """
80
- Installing artifact (0.10.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
80
+ Installing berkshelf-cookbook-fixture (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
81
81
  """
82
82
  And the cookbook store should have the cookbooks:
83
- | artifact | 0.10.0 |
83
+ | berkshelf-cookbook-fixture | 1.0.0 |
84
84
  And the exit status should be 0
85
85
 
86
86
  @chef_server
@@ -89,14 +89,14 @@ Feature: Berksfile default locations
89
89
  """
90
90
  chef_api :config
91
91
 
92
- cookbook 'artifact', '= 0.10.0'
92
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
93
93
  """
94
94
  And the Chef server does not have the cookbooks:
95
- | artifact | 0.10.0 |
95
+ | berkshelf-cookbook-fixture | 1.0.0 |
96
96
  When I run the install command
97
97
  Then the output should contain:
98
98
  """
99
- Cookbook 'artifact' not found in any of the default locations
99
+ Cookbook 'berkshelf-cookbook-fixture' not found in any of the default locations
100
100
  """
101
101
  And the CLI should exit with the status code for error "CookbookNotFound"
102
102
 
@@ -106,7 +106,7 @@ Feature: Berksfile default locations
106
106
  site 'http://cookbooks.opscode.com/api/v1/cookbooks'
107
107
  site 'http://cookbooks.opscode.com/api/v1/cookbooks'
108
108
 
109
- cookbook 'artifact', '= 0.10.0'
109
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
110
110
  """
111
111
  When I run the install command
112
112
  Then the output should contain:
@@ -121,7 +121,7 @@ Feature: Berksfile default locations
121
121
  site 'http://cookbooks.opscode.com/api/v1/cookbooks'
122
122
  site 'http://cookbooks.opscode.com/api/v2/cookbooks'
123
123
 
124
- cookbook 'artifact', '= 0.10.0'
124
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0'
125
125
  """
126
126
  When I run the install command
127
127
  Then the exit status should be 0
@@ -90,14 +90,13 @@ Feature: install cookbooks from a Berksfile
90
90
  """
91
91
  When I successfully run `berks install`
92
92
  Then the cookbook store should have the git cookbooks:
93
- | artifact | 1.5.0 | master |
93
+ | artifact | 1.7.0 | master |
94
94
  And the output should contain:
95
95
  """
96
- Installing artifact (1.5.0) from git: 'git://github.com/RiotGames/artifact-cookbook.git' with branch: 'master'
96
+ Installing artifact (1.7.0) from git: 'git://github.com/RiotGames/artifact-cookbook.git' with branch: 'master'
97
97
  """
98
98
  And the exit status should be 0
99
99
 
100
-
101
100
  Scenario: installing a Berksfile that contains a Git location with a ref
102
101
  Given I write to "Berksfile" with:
103
102
  """
@@ -306,6 +305,20 @@ Feature: install cookbooks from a Berksfile
306
305
  | cuke-test | 1.0.0 |
307
306
  And the exit status should be 0
308
307
 
308
+ Scenario: when the :site is not defined
309
+ Given I write to "Berksfile" with:
310
+ """
311
+ cookbook 'berkshelf-cookbook-fixture', '1.0.0', site: nil
312
+ """
313
+ When I successfully run `berks install`
314
+ Then the output should contain:
315
+ """
316
+ Installing berkshelf-cookbook-fixture (1.0.0) from site:
317
+ """
318
+ And the cookbook store should have the cookbooks:
319
+ | berkshelf-cookbook-fixture | 1.0.0 |
320
+ And the exit status should be 0
321
+
309
322
  Scenario: with a chef_api source location specifying :config when a Berkshelf config is not found at the given path
310
323
  Given I write to "Berksfile" with:
311
324
  """
@@ -3,9 +3,11 @@ Feature: outdated command
3
3
  I want to know what cookbooks are outdated before I run update
4
4
  So that I can decide whether to update everything at once
5
5
 
6
+ @slow_process
6
7
  Scenario: Running berks outdated with no version constraints
7
8
  Given I write to "Berksfile" with:
8
9
  """
10
+ site :opscode
9
11
  cookbook "artifact"
10
12
  cookbook "build-essential"
11
13
  """
@@ -19,9 +21,11 @@ Feature: outdated command
19
21
  All cookbooks up to date
20
22
  """
21
23
 
24
+ @slow_process
22
25
  Scenario: Running berks outdated with satisfied version constraints
23
26
  Given I write to "Berksfile" with:
24
27
  """
28
+ site :opscode
25
29
  cookbook "artifact", ">= 0.11.0"
26
30
  cookbook "build-essential", ">= 1.0.0"
27
31
  """
@@ -35,9 +39,11 @@ Feature: outdated command
35
39
  All cookbooks up to date
36
40
  """
37
41
 
42
+ @slow_process
38
43
  Scenario: Running berks outdated with unsatisfied version constraints
39
44
  Given I write to "Berksfile" with:
40
45
  """
46
+ site :opscode
41
47
  cookbook "artifact", "~> 0.9.0"
42
48
  cookbook "build-essential", "~> 0.7.0"
43
49
  """
@@ -6,6 +6,7 @@ Feature: show command
6
6
  Scenario: Running the show command with an installed cookbook name
7
7
  Given I write to "Berksfile" with:
8
8
  """
9
+ site :opscode
9
10
  cookbook "build-essential", "1.2.0"
10
11
  cookbook "chef-client", "1.2.0"
11
12
  cookbook "mysql", "1.2.4"
@@ -11,8 +11,8 @@ Spork.prefork do
11
11
  APP_ROOT = File.expand_path('../../../', __FILE__)
12
12
 
13
13
  ENV['RUBY_ENV'] = 'test'
14
- ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, "tmp", "berkshelf")
15
- ENV["BERKSHELF_CHEF_CONFIG"] = File.join(APP_ROOT, "spec", "knife.rb")
14
+ ENV['BERKSHELF_PATH'] = File.join(APP_ROOT, 'tmp', 'berkshelf')
15
+ ENV['BERKSHELF_CHEF_CONFIG'] = File.join(APP_ROOT, 'spec', 'config', 'knife.rb')
16
16
 
17
17
  # Workaround for RSA Fingerprint prompt in Travis CI
18
18
  git_ssh_path = '/tmp/git_ssh.sh'
@@ -35,7 +35,7 @@ Spork.prefork do
35
35
  clean_cookbook_store
36
36
  generate_berks_config(File.join(ENV["BERKSHELF_PATH"], 'config.json'))
37
37
  @aruba_io_wait_seconds = 5
38
- @aruba_timeout_seconds = 16
38
+ @aruba_timeout_seconds = 30
39
39
  end
40
40
 
41
41
  Before('@slow_process') do
@@ -43,6 +43,15 @@ Spork.prefork do
43
43
  @aruba_io_wait_seconds = 10
44
44
  end
45
45
 
46
+ # Chef Zero
47
+ require 'chef_zero/server'
48
+ @server = ChefZero::Server.new(port: 4000, generate_real_keys: false)
49
+ @server.start_background
50
+
51
+ at_exit do
52
+ @server.stop if @server && @server.running?
53
+ end
54
+
46
55
  def cookbook_store
47
56
  Pathname.new(File.join(ENV["BERKSHELF_PATH"], "cookbooks"))
48
57
  end
@@ -71,7 +80,5 @@ Spork.prefork do
71
80
  end
72
81
 
73
82
  Spork.each_run do
74
- Berkshelf::RSpec::Knife.load_knife_config(File.join(APP_ROOT, 'spec/knife.rb'))
75
-
76
83
  require 'berkshelf'
77
84
  end
@@ -216,3 +216,17 @@ Feature: upload command
216
216
  | ntp |
217
217
  | vim |
218
218
  And the exit status should be 0
219
+
220
+ Scenario: Raise exception uploading an invalid cookbook
221
+ Given a cookbook named "cookbook with spaces"
222
+ And I write to "Berksfile" with:
223
+ """
224
+ cookbook 'cookbook with spaces', path: './cookbook with spaces'
225
+ """
226
+ When I run `berks upload`
227
+ Then the output should contain:
228
+ """
229
+ The cookbook 'cookbook with spaces' has invalid filenames:
230
+ """
231
+ And the CLI should exit with the status code for error "InvalidCookbookFiles"
232
+
@@ -7,7 +7,6 @@ Feature: install cookbooks to a given vendor path
7
7
  Given I write to "Berksfile" with:
8
8
  """
9
9
  site :opscode
10
-
11
10
  cookbook "artifact", "0.10.0"
12
11
  """
13
12
  When I run the install command with flags:
@@ -506,6 +506,8 @@ module Berkshelf
506
506
  solution.each do |cb|
507
507
  Berkshelf.formatter.upload(cb.cookbook_name, cb.version, conn.server_url)
508
508
 
509
+ validate_files!(cb)
510
+
509
511
  begin
510
512
  conn.cookbook.upload(cb.path, upload_opts.merge(name: cb.cookbook_name))
511
513
  rescue Ridley::Errors::FrozenCookbook => ex
@@ -602,5 +604,20 @@ module Berkshelf
602
604
  def update_lockfile(sources)
603
605
  Berkshelf::Lockfile.update!(sources)
604
606
  end
607
+
608
+ # Validate that the given cookbook does not have "bad" files. Currently
609
+ # this means including spaces in filenames (such as recipes)
610
+ #
611
+ # @param [Berkshelf::CachedCookbook] cookbook
612
+ # the Cookbook to validate
613
+ def validate_files!(cookbook)
614
+ path = cookbook.path.to_s
615
+
616
+ files = Dir.glob(File.join(path, '**', '*.rb')).select do |f|
617
+ f =~ /[[:space:]]/
618
+ end
619
+
620
+ raise Berkshelf::InvalidCookbookFiles.new(cookbook, files) unless files.empty?
621
+ end
605
622
  end
606
623
  end