berkshelf 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/features/lockfile.feature +2 -2
- data/lib/berkshelf.rb +4 -5
- data/lib/berkshelf/berksfile.rb +12 -15
- data/lib/berkshelf/cached_cookbook.rb +1 -0
- data/lib/berkshelf/cli.rb +1 -1
- data/lib/berkshelf/config.rb +3 -2
- data/lib/berkshelf/errors.rb +2 -2
- data/lib/berkshelf/logger.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/spec/unit/berkshelf/berksfile_spec.rb +18 -39
- data/spec/unit/berkshelf/config_spec.rb +9 -0
- metadata +2 -2
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.3-
|
1
|
+
1.9.3-p429
|
data/CHANGELOG.md
CHANGED
data/features/lockfile.feature
CHANGED
@@ -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.
|
409
|
+
berkshelf-cookbook-fixture (~> 1.3.0)
|
410
410
|
|
411
411
|
In Berksfile.lock:
|
412
|
-
berkshelf-cookbook-fixture (
|
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
|
"""
|
data/lib/berkshelf.rb
CHANGED
@@ -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
|
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -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]
|
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
|
-
|
537
|
-
upload_opts
|
538
|
-
conn
|
534
|
+
cached_cookbooks = install(options)
|
535
|
+
upload_opts = options.slice(:force, :freeze)
|
536
|
+
conn = ridley_connection(options)
|
539
537
|
|
540
|
-
|
541
|
-
Berkshelf.formatter.upload(
|
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(
|
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
|
data/lib/berkshelf/cli.rb
CHANGED
data/lib/berkshelf/config.rb
CHANGED
data/lib/berkshelf/errors.rb
CHANGED
@@ -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
|
-
" #{@
|
256
|
+
" #{@source.name} (#{@source.version_constraint})",
|
257
257
|
"",
|
258
258
|
" In Berksfile.lock:",
|
259
|
-
" #{@
|
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")
|
data/lib/berkshelf/logger.rb
CHANGED
data/lib/berkshelf/version.rb
CHANGED
@@ -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(:
|
409
|
-
|
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('
|
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.
|
430
|
+
subject.should_receive(:install).and_return(installed_cookbooks)
|
430
431
|
end
|
431
432
|
|
432
|
-
context 'when there is no :
|
433
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
16
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|