berkshelf 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ 1.9.3-p429
@@ -1,3 +1,9 @@
1
+ # 2.0.1
2
+
3
+ * Improve performance of `berks upload`. It will now properly respect the Lockfile
4
+ * Fix debug/verbose logging
5
+ * You can now specify an alternate configuration with -c once again
6
+
1
7
  # 2.0.0
2
8
 
3
9
  * Huge improvements to the Lockfile
@@ -406,10 +406,10 @@ Feature: Creating and reading the Berkshelf lockfile
406
406
  """
407
407
  Berkshelf could not find compatible versions for cookbook 'berkshelf-cookbook-fixture':
408
408
  In Berksfile:
409
- berkshelf-cookbook-fixture (1.0.0)
409
+ berkshelf-cookbook-fixture (~> 1.3.0)
410
410
 
411
411
  In Berksfile.lock:
412
- berkshelf-cookbook-fixture (~> 1.3.0)
412
+ berkshelf-cookbook-fixture (1.0.0)
413
413
 
414
414
  Try running `berks update berkshelf-cookbook-fixture, which will try to find 'berkshelf-cookbook-fixture' matching '~> 1.3.0'
415
415
  """
@@ -28,6 +28,7 @@ module Berkshelf
28
28
  include Berkshelf::Mixin::Logging
29
29
 
30
30
  attr_accessor :ui
31
+ attr_accessor :logger
31
32
  attr_writer :cookbook_store
32
33
 
33
34
  # @return [Pathname]
@@ -65,11 +66,6 @@ module Berkshelf
65
66
  # the new configuration file to use
66
67
  attr_writer :chef_config
67
68
 
68
- # @return [Logger]
69
- def logger
70
- Celluloid.logger
71
- end
72
-
73
69
  # @return [String]
74
70
  def tmp_dir
75
71
  File.join(berkshelf_path, 'tmp')
@@ -162,3 +158,6 @@ require_relative 'berkshelf/resolver'
162
158
  require_relative 'berkshelf/test' if ENV['RUBY_ENV'] == 'test'
163
159
  require_relative 'berkshelf/ui'
164
160
  require_relative 'berkshelf/version'
161
+
162
+ Ridley.logger = Celluloid.logger = Berkshelf.logger = Logger.new(STDOUT)
163
+ Berkshelf.logger.level = Logger::WARN
@@ -498,6 +498,8 @@ module Berkshelf
498
498
  outdated
499
499
  end
500
500
 
501
+ # Upload the cookbooks installed by this Berksfile
502
+ #
501
503
  # @option options [Boolean] :force (false)
502
504
  # Upload the Cookbook even if the version already exists and is frozen on the
503
505
  # target Chef Server
@@ -521,29 +523,24 @@ module Berkshelf
521
523
  # @option options [String] :server_url
522
524
  # An overriding Chef Server to upload the cookbooks to
523
525
  #
524
- # @raise [UploadFailure] if you are uploading cookbooks with an invalid or not-specified client key
526
+ # @raise [UploadFailure]
527
+ # if you are uploading cookbooks with an invalid or not-specified client key
525
528
  # @raise [Berkshelf::FrozenCookbook]
526
529
  # if an attempt to upload a cookbook which has been frozen on the target server is made
527
530
  # and the :halt_on_frozen option was true
528
531
  def upload(options = {})
529
- options = options.reverse_merge(
530
- force: false,
531
- freeze: true,
532
- skip_dependencies: false,
533
- halt_on_frozen: false
534
- )
532
+ options = options.reverse_merge(force: false, freeze: true, skip_dependencies: false, halt_on_frozen: false)
535
533
 
536
- solution = resolve(sources(options), options)[:solution]
537
- upload_opts = options.slice(:force, :freeze)
538
- conn = ridley_connection(options)
534
+ cached_cookbooks = install(options)
535
+ upload_opts = options.slice(:force, :freeze)
536
+ conn = ridley_connection(options)
539
537
 
540
- solution.each do |cb|
541
- Berkshelf.formatter.upload(cb.cookbook_name, cb.version, conn.server_url)
542
-
543
- validate_files!(cb)
538
+ cached_cookbooks.each do |cookbook|
539
+ Berkshelf.formatter.upload(cookbook.cookbook_name, cookbook.version, conn.server_url)
540
+ validate_files!(cookbook)
544
541
 
545
542
  begin
546
- conn.cookbook.upload(cb.path, upload_opts.merge(name: cb.cookbook_name))
543
+ conn.cookbook.upload(cookbook.path, upload_opts.merge(name: cookbook.cookbook_name))
547
544
  rescue Ridley::Errors::FrozenCookbook => ex
548
545
  if options[:halt_on_frozen]
549
546
  raise Berkshelf::FrozenCookbook, ex
@@ -54,6 +54,7 @@ module Berkshelf
54
54
  end
55
55
 
56
56
  private
57
+
57
58
  def pretty_map(hash, padding)
58
59
  hash.map { |k,v| "#{k} (#{v})" }.join("\n" + ' '*padding)
59
60
  end
@@ -32,7 +32,7 @@ module Berkshelf
32
32
  unless File.exist?(@options[:config])
33
33
  raise ConfigNotFound.new(:berkshelf, @options[:config])
34
34
  end
35
- Berkshelf::Config.path = @options[:config]
35
+ Berkshelf::Config.set_path(@options[:config])
36
36
  end
37
37
 
38
38
  if @options[:debug]
@@ -28,8 +28,9 @@ module Berkshelf
28
28
  end
29
29
 
30
30
  # @param [String] new_path
31
- def path=(new_path)
32
- @path = File.expand_path(new_path)
31
+ def set_path(new_path)
32
+ @instance = nil
33
+ @path = File.expand_path(new_path)
33
34
  end
34
35
 
35
36
  # @return [String, nil]
@@ -253,10 +253,10 @@ module Berkshelf
253
253
  [
254
254
  "Berkshelf could not find compatible versions for cookbook '#{@source.name}':",
255
255
  " In Berksfile:",
256
- " #{@locked_source.name} (#{@locked_source.locked_version})",
256
+ " #{@source.name} (#{@source.version_constraint})",
257
257
  "",
258
258
  " In Berksfile.lock:",
259
- " #{@source.name} (#{@source.version_constraint})",
259
+ " #{@locked_source.name} (#{@locked_source.locked_version})",
260
260
  "",
261
261
  "Try running `berks update #{@source.name}, which will try to find '#{@source.name}' matching '#{@source.version_constraint}'.",
262
262
  ].join("\n")
@@ -1,5 +1,5 @@
1
1
  module Berkshelf
2
- Logger = Celluloid::Logger
2
+ Logger = Celluloid::Logger.dup
3
3
 
4
4
  Logger.module_eval do
5
5
  def self.fatal(string)
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -403,18 +403,16 @@ describe Berkshelf::Berksfile do
403
403
  end
404
404
 
405
405
  describe '#upload' do
406
- let(:upload) { subject.upload(options) }
407
406
  let(:options) { Hash.new }
408
- let(:ssl) { double('ssl', verify: true) }
409
- let(:chef) {
410
- double('chef',
407
+ let(:chef_config) do
408
+ double('chef-config',
411
409
  node_name: 'fake-client',
412
410
  client_key: 'client-key',
413
411
  chef_server_url: 'http://configured-chef-server/'
414
412
  )
415
- }
416
- let(:berkshelf_config) { double('berks', ssl: ssl, chef: chef) }
417
- let(:default_ridley_options) {
413
+ end
414
+ let(:berkshelf_config) { double('berkshelf-config', ssl: double(verify: true), chef: chef_config) }
415
+ let(:default_ridley_options) do
418
416
  {
419
417
  client_name: 'fake-client',
420
418
  client_key: 'client-key',
@@ -422,55 +420,36 @@ describe Berkshelf::Berksfile do
422
420
  verify: true
423
421
  }
424
422
  }
425
- }
423
+ end
424
+ let(:installed_cookbooks) { Array.new }
425
+
426
+ let(:upload) { subject.upload(options) }
426
427
 
427
428
  before do
428
429
  Berkshelf::Config.stub(:instance).and_return(berkshelf_config)
429
- subject.stub(:resolve).and_return(solution: [], sources: [])
430
+ subject.should_receive(:install).and_return(installed_cookbooks)
430
431
  end
431
432
 
432
- context 'when there is no :server_url' do
433
- let(:chef) do
434
- double('chef',
435
- node_name: 'fake-client',
436
- client_key: 'client-key',
437
- chef_server_url: nil
438
- )
439
- end
433
+ context 'when there is no value for :chef_server_url' do
434
+ before { chef_config.stub(chef_server_url: nil) }
440
435
  let(:message) { 'Missing required attribute in your Berkshelf configuration: chef.server_url' }
441
436
 
442
437
  it 'raises an error' do
443
- expect {
444
- upload
445
- }.to raise_error(Berkshelf::ChefConnectionError, message)
438
+ expect { upload }.to raise_error(Berkshelf::ChefConnectionError, message)
446
439
  end
447
440
  end
448
441
 
449
- context 'when there is no :client_name' do
450
- let(:chef) do
451
- double('chef',
452
- node_name: nil,
453
- client_key: 'client-key',
454
- chef_server_url: 'http://configured-chef-server/'
455
- )
456
- end
442
+ context 'when there is no value for :client_name' do
443
+ before { chef_config.stub(node_name: nil) }
457
444
  let(:message) { 'Missing required attribute in your Berkshelf configuration: chef.node_name' }
458
445
 
459
446
  it 'raises an error' do
460
- expect {
461
- upload
462
- }.to raise_error(Berkshelf::ChefConnectionError, message)
447
+ expect { upload }.to raise_error(Berkshelf::ChefConnectionError, message)
463
448
  end
464
449
  end
465
450
 
466
- context 'when there is no :client_key' do
467
- let(:chef) do
468
- double('chef',
469
- node_name: 'fake-client',
470
- client_key: nil,
471
- chef_server_url: 'http://configured-chef-server/'
472
- )
473
- end
451
+ context 'when there is no value for :client_key' do
452
+ before { chef_config.stub(client_key: nil) }
474
453
  let(:message) { 'Missing required attribute in your Berkshelf configuration: chef.client_key' }
475
454
 
476
455
  it 'raises an error' do
@@ -52,4 +52,13 @@ describe Berkshelf::Config do
52
52
  end
53
53
  end
54
54
  end
55
+
56
+ describe "::set_path" do
57
+ subject(:set_path) { described_class.set_path("/tmp/other_path.json") }
58
+
59
+ it "sets the #instance to nil" do
60
+ set_path
61
+ expect(described_class.instance_variable_get(:@instance)).to be_nil
62
+ end
63
+ end
55
64
  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: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-06-06 00:00:00.000000000 Z
16
+ date: 2013-06-07 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport