berkshelf 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f5a7d0c79975c9b1f6c2a3407a1d649b68e9d1f
4
- data.tar.gz: 409e94aa67b4fc4ca58bf3cbfc4ba394307c4bf0
3
+ metadata.gz: 2f602bc76f25aadd31542d00b644abe495c9a0ae
4
+ data.tar.gz: ab05691e2bd055675d57e3940337770571124fb5
5
5
  SHA512:
6
- metadata.gz: 4f25d4557214df0297c370439d06ff22f3c8da2b94b72176cd086ad3461c441c68f7bf482e5b28be4f651731a8b9498d83c455ac050ed8b78d607bfcf1e5574f
7
- data.tar.gz: c571c05d0bb93b8c85524c22a06d8fb38cf4c470c346d419908baf10db1c15922dc0dad0c74b3c2518682cdd907f4de7e5dbd3ed3cd5917b7f029418f64140a0
6
+ metadata.gz: cf4fd42a2f32ea879fcefc8389323cbbd293f382b884f7b65fc17aaee93e5bc27b6a4594d07c3be84346da03a50197563f3ad1f6addaae50096d8f359ee68d35
7
+ data.tar.gz: 51824f49578a4ce7417797e158413afe3951f65d243b48de48905af27924a0561f2c5b8aaaf533a7f0758ca3b5c67fbf002e694c07c2f3dff04240f4f4b3ffc0
@@ -1,5 +1,15 @@
1
1
  > This is a high level digest of changes. For the complete CHANGELOG diff two tags in the project's [commit history](https://github.com/berkshelf/berkshelf/commits/master).
2
2
 
3
+ # 3.1.3
4
+
5
+ * Enhancements
6
+ * Updated out of date dependencies
7
+
8
+ * Bug fixes
9
+ * Skip loading of cached cookbooks that do not have a value for metadata
10
+ * SSL Verify option will be respected when communicating to an API server
11
+ * Fixed issue where some commands were unexpectedly crashing instead of informing the user that Git is not installed
12
+
3
13
  # 3.1.2
4
14
 
5
15
  * Enhancements
data/Gemfile CHANGED
@@ -31,5 +31,5 @@ group :guard do
31
31
  end
32
32
 
33
33
  group :test do
34
- gem 'berkshelf-api', "~> 1.3"
34
+ gem "berkshelf-api", github: "berkshelf/berkshelf-api"
35
35
  end
data/README.md CHANGED
@@ -39,15 +39,6 @@ Ruby 1.9 mode is required on all interpreters.
39
39
 
40
40
  Ruby 1.9.1 and 1.9.2 are not officially supported. If you encounter problems, please upgrade to Ruby 2.0 or 1.9.3.
41
41
 
42
- ## Shell Completion
43
-
44
- - [Bash](https://github.com/berkshelf/berkshelf-bash-plugin)
45
- - [ZSH](https://github.com/berkshelf/berkshelf-zsh-plugin)
46
-
47
- ## Plugins
48
-
49
- Please see [Plugins page](https://github.com/berkshelf/berkshelf/blob/master/PLUGINS.md) for more information.
50
-
51
42
  ## Configuration
52
43
 
53
44
  Berkshelf will search in specific locations for a configuration file. In order:
@@ -60,45 +51,19 @@ Berkshelf will search in specific locations for a configuration file. In order:
60
51
 
61
52
  You are encouraged to keep project-specific configuration in the `$PWD/.berkshelf` directory. A default configuration file is generated for you, but you can update the values to suit your needs.
62
53
 
63
- ## Github Cookbooks
64
-
65
- With Berkshelf 3 you can query a Berkshelf-API server (a server which indexes cookbooks from various sources and
66
- hosts it over a REST API) in order to resolve the cookbook dependencies. When you choose to host your own Berkshelf-API
67
- server, you can configure it to also index cookbooks hosted in various Github and/or Github Enterprise organizations.
68
-
69
- When doing so you should also configure Berkshelf so it can download cookbooks from your indexed Github organizations:
70
-
71
- {
72
- "github":[
73
- {
74
- "access_token": ""
75
- },
76
- {
77
- "access_token": "",
78
- "api_endpoint": "https://github.enterprise.local/api/v3",
79
- "web_endpoint": "https://github.enterprise.local",
80
- "ssl_verify": true
81
- }
82
- ]
83
- }
84
-
85
- The first subsection is used for any organization hosted on github.com. As this is the default, you do not have to set the
86
- endpoint info (these are known values for github.com). The second subsection is used when you also index cookbooks from
87
- organizations hosted on Github Enterprise. In this case you will need to specify the specific endpoint info so Berkshelf
88
- knows where to connect to. You can add as many subsections as you have endpoints.
89
-
90
- ## SSL Errors
91
-
92
- If you have trouble getting Berkshelf to successfully talk to an SSL Chef Server, you can try making sure you
93
- have a certificate bundle available to your shell. `export SSL_CERT_FILE=...path/to/cert/file...`
94
-
95
- If you need to disable SSL, you can in `~/.berkshelf/config.json` like so:
96
-
97
- {
98
- "ssl": {
99
- "verify": false
100
- }
101
- }
54
+ ## Shell Completion
55
+
56
+ - [Bash](https://github.com/berkshelf/berkshelf-bash-plugin)
57
+ - [ZSH](https://github.com/berkshelf/berkshelf-zsh-plugin)
58
+
59
+ ## Plugins
60
+
61
+ Please see [Plugins page](https://github.com/berkshelf/berkshelf/blob/master/PLUGINS.md) for more information.
62
+
63
+ ## Getting Help
64
+
65
+ * If you have an issue: report it on the [issue tracker](https://github.com/berkshelf/berkshelf/issues)
66
+ * If you have a question: visit the #chef or #berkshelf channel on irc.freenode.net
102
67
 
103
68
  ## Authors
104
69
 
@@ -32,13 +32,13 @@ Gem::Specification.new do |s|
32
32
 
33
33
  s.add_dependency 'addressable', '~> 2.3.4'
34
34
  s.add_dependency 'berkshelf-api-client', '~> 1.2'
35
- s.add_dependency 'buff-config', '~> 0.4'
36
- s.add_dependency 'buff-extensions', '~> 0.4'
35
+ s.add_dependency 'buff-config', '~> 1.0'
36
+ s.add_dependency 'buff-extensions', '~> 1.0'
37
37
  s.add_dependency 'buff-shell_out', '~> 0.1'
38
38
  s.add_dependency 'faraday', '~> 0.9.0'
39
39
  s.add_dependency 'minitar', '~> 0.5.4'
40
40
  s.add_dependency 'retryable', '~> 1.3.3'
41
- s.add_dependency 'ridley', '~> 3.1'
41
+ s.add_dependency 'ridley', '~> 4.0'
42
42
  s.add_dependency 'solve', '~> 1.1'
43
43
  s.add_dependency 'thor', '~> 0.18'
44
44
  s.add_dependency 'octokit', '~> 3.0'
@@ -451,7 +451,7 @@ Feature: berks install
451
451
  """
452
452
  Repository not found.
453
453
  """
454
- And the exit status should be "GitLocation::GitError"
454
+ And the exit status should be "GitError"
455
455
 
456
456
  Scenario: transitive dependencies in metadata
457
457
  Given the cookbook store contains a cookbook "fake" "1.0.0" with dependencies:
@@ -22,6 +22,7 @@ module Berkshelf
22
22
 
23
23
  module Mixin
24
24
  autoload :DSLEval, 'berkshelf/mixin/dsl_eval'
25
+ autoload :Git, 'berkshelf/mixin/git'
25
26
  autoload :Logging, 'berkshelf/mixin/logging'
26
27
  end
27
28
 
@@ -91,7 +91,7 @@ module Berkshelf
91
91
  type: Array,
92
92
  default: Array.new
93
93
  attribute 'raise_license_exception',
94
- type: Boolean,
94
+ type: Buff::Boolean,
95
95
  default: false
96
96
  attribute 'vagrant.vm.box',
97
97
  type: String,
@@ -108,13 +108,13 @@ module Berkshelf
108
108
  type: String,
109
109
  default: 'chef_solo'
110
110
  attribute 'vagrant.omnibus.enabled',
111
- type: Boolean,
111
+ type: Buff::Boolean,
112
112
  default: true
113
113
  attribute 'vagrant.omnibus.version',
114
114
  type: String,
115
115
  default: 'latest'
116
116
  attribute 'ssl.verify',
117
- type: Boolean,
117
+ type: Buff::Boolean,
118
118
  default: true,
119
119
  required: true
120
120
  attribute 'github',
@@ -94,6 +94,7 @@ module Berkshelf
94
94
  #
95
95
  # @return [Array<Berkshelf::CachedCookbook>]
96
96
  def cookbooks(filter = nil)
97
+ skipped_cookbooks = []
97
98
  cookbooks = storage_path.children.collect do |path|
98
99
  begin
99
100
  Semverse::Version.split(File.basename(path).slice(CachedCookbook::DIRNAME_REGEXP, 2))
@@ -103,9 +104,27 @@ module Berkshelf
103
104
  next
104
105
  end
105
106
 
106
- CachedCookbook.from_store_path(path)
107
+ begin
108
+ CachedCookbook.from_store_path(path)
109
+ rescue Ridley::Errors::MissingNameAttribute
110
+ # Skip cached cookbooks that do not have a name attribute.
111
+ skipped_cookbooks << File.basename(path)
112
+ next
113
+ end
107
114
  end.compact
108
115
 
116
+ if skipped_cookbooks.any?
117
+ msg = "Skipping cookbooks #{skipped_cookbooks}. Berkshelf can only interact "
118
+ msg << "with cookbooks which have defined the `name` attribute in their metadata.rb. If you "
119
+ msg << "are the maintainer of any of the above cookbooks, please add the name attribute to "
120
+ msg << "your cookbook. If you are not the maintainer, please file an issue or report the lack "
121
+ msg << "of a name attribute as a bug.\n\n"
122
+ msg << "You can remove each cookbook in #{skipped_cookbooks} from the Berkshelf shelf "
123
+ msg << "by using the `berks shelf uninstall` command:\n\n"
124
+ msg << " $ berkshelf shelf uninstall <name>"
125
+ Berkshelf.log.warn msg
126
+ end
127
+
109
128
  return cookbooks unless filter
110
129
 
111
130
  cookbooks.select do |cookbook|
@@ -479,4 +479,32 @@ module Berkshelf
479
479
  "is the standard error from the command:\n\n#{@output}"
480
480
  end
481
481
  end
482
+
483
+ # Git errors
484
+ # ------------------------------
485
+ class GitError < BerkshelfError; status_code(400); end
486
+
487
+ class GitNotInstalled < GitError
488
+ def initialize
489
+ super 'You need to install Git before you can download ' \
490
+ 'cookbooks from git repositories. For more information, please ' \
491
+ 'see the Git docs: http://git-scm.org. If you have git installed, ' \
492
+ 'please make sure it is in your $PATH and accessible by the user ' \
493
+ 'running this command.'
494
+ end
495
+ end
496
+
497
+ class GitCommandError < GitError
498
+ def initialize(command, path, stderr = nil)
499
+ out = "Git error: command `git #{command}` failed. If this error "
500
+ out << "persists, try removing the cache directory at '#{path}'."
501
+
502
+ if stderr
503
+ out << "Output from the command:\n\n"
504
+ out << stderr
505
+ end
506
+
507
+ super(out)
508
+ end
509
+ end
482
510
  end
@@ -4,6 +4,8 @@ rescue LoadError; end
4
4
 
5
5
  module Berkshelf
6
6
  class InitGenerator < BaseGenerator
7
+ include Mixin::Git
8
+
7
9
  def initialize(*args)
8
10
  super(*args)
9
11
  if @options[:cookbook_name]
@@ -75,7 +77,7 @@ module Berkshelf
75
77
 
76
78
  unless File.exists?(target.join('.git'))
77
79
  inside target do
78
- run 'git init', capture: true
80
+ git 'init'
79
81
  end
80
82
  end
81
83
  end
@@ -2,29 +2,7 @@ require 'buff/shell_out'
2
2
 
3
3
  module Berkshelf
4
4
  class GitLocation < BaseLocation
5
- class GitError < BerkshelfError; status_code(400); end
6
-
7
- class GitNotInstalled < GitError
8
- def initialize
9
- super 'You need to install Git before you can download ' \
10
- 'cookbooks from git repositories. For more information, please ' \
11
- 'see the Git docs: http://git-scm.org.'
12
- end
13
- end
14
-
15
- class GitCommandError < GitError
16
- def initialize(command, path, stderr = nil)
17
- out = "Git error: command `git #{command}` failed. If this error "
18
- out << "persists, try removing the cache directory at '#{path}'."
19
-
20
- if stderr
21
- out << "Output from the command:\n\n"
22
- out << stderr
23
- end
24
-
25
- super(out)
26
- end
27
- end
5
+ include Mixin::Git
28
6
 
29
7
  attr_reader :uri
30
8
  attr_reader :branch
@@ -150,29 +128,6 @@ module Berkshelf
150
128
 
151
129
  private
152
130
 
153
- # Perform a git command.
154
- #
155
- # @param [String] command
156
- # the command to run
157
- # @param [Boolean] error
158
- # whether to raise error if the command fails
159
- #
160
- # @raise [String]
161
- # the +$stdout+ from the command
162
- def git(command, error = true)
163
- unless Berkshelf.which('git') || Berkshelf.which('git.exe')
164
- raise GitNotInstalled.new
165
- end
166
-
167
- response = Buff::ShellOut.shell_out(%|git #{command}|)
168
-
169
- if error && !response.success?
170
- raise GitCommandError.new(command, cache_path, stderr = response.stderr)
171
- end
172
-
173
- response.stdout.strip
174
- end
175
-
176
131
  # Determine if this git repo has already been downloaded.
177
132
  #
178
133
  # @return [Boolean]
@@ -0,0 +1,30 @@
1
+ require 'buff/shell_out'
2
+
3
+ module Berkshelf
4
+ module Mixin
5
+ module Git
6
+ # Perform a git command.
7
+ #
8
+ # @param [String] command
9
+ # the command to run
10
+ # @param [Boolean] error
11
+ # whether to raise error if the command fails
12
+ #
13
+ # @raise [String]
14
+ # the +$stdout+ from the command
15
+ def git(command, error = true)
16
+ unless Berkshelf.which('git') || Berkshelf.which('git.exe')
17
+ raise GitNotInstalled.new
18
+ end
19
+
20
+ response = Buff::ShellOut.shell_out(%|git #{command}|)
21
+
22
+ if error && !response.success?
23
+ raise GitCommandError.new(command, cache_path, response.stderr)
24
+ end
25
+
26
+ response.stdout.strip
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,7 +10,7 @@ module Berkshelf
10
10
  # @param [String, Berkshelf::SourceURI] uri
11
11
  def initialize(uri)
12
12
  @uri = SourceURI.parse(uri)
13
- @api_client = APIClient.new(uri)
13
+ @api_client = APIClient.new(uri, ssl: {verify: Berkshelf::Config.instance.ssl.verify})
14
14
  @universe = nil
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = '3.1.2'
2
+ VERSION = "3.1.3"
3
3
  end
@@ -26,9 +26,11 @@ Spork.prefork do
26
26
  config.mock_with :rspec
27
27
  config.treat_symbols_as_metadata_keys_with_true_values = true
28
28
  config.filter_run focus: true
29
+ config.filter_run_excluding not_supported_on_windows: windows?
29
30
  config.run_all_when_everything_filtered = true
30
31
 
31
32
  config.before(:each) do
33
+ Berkshelf.logger = Berkshelf::Logger.new(nil)
32
34
  Berkshelf.set_format(:null)
33
35
  Berkshelf.ui.mute!
34
36
  end
@@ -76,7 +76,7 @@ module Berkshelf
76
76
  end
77
77
 
78
78
  metadata = [].tap do |a|
79
- a << "name '#{name}'"
79
+ a << "name '#{name}'" unless options[:without_name]
80
80
  a << "version '#{version}'"
81
81
  a << "license '#{options[:license]}'" if options[:license]
82
82
  a << "" # ensure newline
@@ -43,7 +43,13 @@ describe Berkshelf::CachedCookbook do
43
43
  describe '::checksum' do
44
44
  it 'returns a checksum of the given filepath' do
45
45
  path = fixtures_path.join('cookbooks', 'example_cookbook-0.5.0', 'README.md')
46
- expect(described_class.checksum(path)).to eq('6e21094b7a920e374e7261f50e9c4eef')
46
+ expected_md5 = if IO.binread(path).include?("\r\n")
47
+ # On windows, with git configured for auto crlf
48
+ "2414583f86c9eb68bdbb0be391939341"
49
+ else
50
+ "6e21094b7a920e374e7261f50e9c4eef"
51
+ end
52
+ expect(described_class.checksum(path)).to eq(expected_md5)
47
53
  end
48
54
 
49
55
  context 'given path does not exist' do
@@ -106,6 +106,16 @@ describe Berkshelf::CookbookStore do
106
106
  expect(subject.cookbooks('mysql')).to have(1).item
107
107
  end
108
108
  end
109
+
110
+ context 'when a there is a cookbook without a name attribute' do
111
+ before do
112
+ generate_cookbook(subject.storage_path, 'foo', '3.0.1', without_name: true)
113
+ end
114
+
115
+ it 'omits the broken cookbook' do
116
+ expect(subject.cookbooks('foo')).to be_empty
117
+ end
118
+ end
109
119
  end
110
120
 
111
121
  describe "#import"
@@ -236,13 +236,13 @@ module Berkshelf
236
236
 
237
237
  it 'raises an error if Git is not installed' do
238
238
  Berkshelf.stub(:which).and_return(false)
239
- expect { subject.git('foo') }.to raise_error(GitLocation::GitNotInstalled)
239
+ expect { subject.git('foo') }.to raise_error(GitNotInstalled)
240
240
  end
241
241
 
242
242
  it 'raises an error if the command fails' do
243
243
  shell_out = double('shell_out', success?: false, stderr: nil)
244
244
  Buff::ShellOut.stub(:shell_out).and_return(shell_out)
245
- expect { subject.git('foo') }.to raise_error(GitLocation::GitCommandError)
245
+ expect { subject.git('foo') }.to raise_error(GitCommandError)
246
246
  end
247
247
  end
248
248
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-05-08 00:00:00.000000000 Z
15
+ date: 2014-06-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -48,28 +48,28 @@ dependencies:
48
48
  requirements:
49
49
  - - "~>"
50
50
  - !ruby/object:Gem::Version
51
- version: '0.4'
51
+ version: '1.0'
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: '0.4'
58
+ version: '1.0'
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: buff-extensions
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '0.4'
65
+ version: '1.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '0.4'
72
+ version: '1.0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: buff-shell_out
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -132,14 +132,14 @@ dependencies:
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: '3.1'
135
+ version: '4.0'
136
136
  type: :runtime
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '3.1'
142
+ version: '4.0'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: solve
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -447,6 +447,7 @@ files:
447
447
  - lib/berkshelf/lockfile.rb
448
448
  - lib/berkshelf/logger.rb
449
449
  - lib/berkshelf/mixin/dsl_eval.rb
450
+ - lib/berkshelf/mixin/git.rb
450
451
  - lib/berkshelf/mixin/logging.rb
451
452
  - lib/berkshelf/packager.rb
452
453
  - lib/berkshelf/resolver.rb