berkshelf 1.3.0.rc1 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,12 +27,13 @@ Gem::Specification.new do |s|
27
27
  s.version = Berkshelf::VERSION
28
28
  s.required_ruby_version = ">= 1.9.1"
29
29
 
30
+ s.add_dependency 'celluloid', '>= 0.13.0'
30
31
  s.add_dependency 'yajl-ruby'
31
- s.add_dependency 'activesupport', '~> 3.2'
32
- s.add_dependency 'mixlib-shellout'
33
- s.add_dependency 'mixlib-config'
32
+ s.add_dependency 'activesupport', '>= 3.2.0'
33
+ s.add_dependency 'mixlib-shellout', '~> 1.1'
34
+ s.add_dependency 'mixlib-config', '~> 1.1'
34
35
  s.add_dependency 'faraday', '>= 0.8.5'
35
- s.add_dependency 'ridley', '>= 0.8.5'
36
+ s.add_dependency 'ridley', '>= 0.8.6'
36
37
  s.add_dependency 'chozo', '>= 0.6.1'
37
38
  s.add_dependency 'hashie', '>= 2.0.2'
38
39
  s.add_dependency 'minitar'
@@ -34,9 +34,9 @@ Feature: cookbook creation with a config file
34
34
  Then the resulting "sparkle_motion" Vagrantfile should contain:
35
35
  | config.vm.box = "my_box" |
36
36
  | config.vm.box_url = "http://files.vagrantup.com/lucid64.box" |
37
- | config.vm.forward_port 12345, 54321 |
38
- | config.vm.network :hostonly, "12.34.56.78" |
39
- | config.vm.network :bridged |
37
+ | config.vm.network :forwarded_port, guest: 12345, host: 54321 |
38
+ | config.vm.network :private_network, ip: "12.34.56.78" |
39
+ | config.vm.network :public_network |
40
40
  And the exit status should be 0
41
41
 
42
42
  Scenario: creating a new cookbook using a partial Berkshelf config
@@ -54,7 +54,7 @@ Feature: cookbook creation with a config file
54
54
  """
55
55
  When I run the cookbook command to create "sparkle_motion"
56
56
  Then the resulting "sparkle_motion" Vagrantfile should contain:
57
- | config.vm.forward_port 12345, 54321 |
57
+ | config.vm.network :forwarded_port, guest: 12345, host: 54321 |
58
58
  And the exit status should be 0
59
59
 
60
60
  Scenario: creating a new cookbook using an invalid Berkshelf config
@@ -91,8 +91,8 @@ Feature: cookbook creation with a config file
91
91
  """
92
92
  When I run the cookbook command to create "sparkle_motion"
93
93
  Then the resulting "sparkle_motion" Vagrantfile should contain:
94
- | config.vm.provision :chef_client |
95
- | chef.chef_server_url = "localhost:4000" |
94
+ | config.vm.provision :chef_client |
95
+ | chef.chef_server_url = "localhost:4000" |
96
96
  | chef.validation_client_name = "my_client-validator" |
97
- | chef.validation_key_path = "/a/b/c/my_client-validator.pem" |
97
+ | chef.validation_key_path = "/a/b/c/my_client-validator.pem" |
98
98
  Then the exit status should be 0
@@ -20,6 +20,7 @@ require 'thor'
20
20
  require 'tmpdir'
21
21
  require 'uri'
22
22
  require 'zlib'
23
+ require 'celluloid'
23
24
 
24
25
  require 'berkshelf/version'
25
26
  require 'berkshelf/core_ext'
@@ -77,6 +78,11 @@ module Berkshelf
77
78
  ENV["BERKSHELF_PATH"] || File.expand_path("~/.berkshelf")
78
79
  end
79
80
 
81
+ # @return [Logger]
82
+ def log
83
+ Celluloid.logger
84
+ end
85
+
80
86
  # @return [String]
81
87
  def tmp_dir
82
88
  File.join(berkshelf_path, "tmp")
@@ -30,6 +30,10 @@ module Berkshelf
30
30
  Berkshelf::Config.path = @options[:config]
31
31
  end
32
32
 
33
+ if @options[:debug]
34
+ Berkshelf.log.level = ::Logger::DEBUG
35
+ end
36
+
33
37
  if @options[:quiet]
34
38
  Berkshelf.ui.mute!
35
39
  end
@@ -65,6 +69,11 @@ module Berkshelf
65
69
  desc: "Silence all informational output.",
66
70
  aliases: "-q",
67
71
  default: false
72
+ class_option :debug,
73
+ type: :boolean,
74
+ desc: "Output debug information",
75
+ aliases: "-d",
76
+ default: false
68
77
 
69
78
  method_option :force,
70
79
  type: :boolean,
@@ -149,4 +149,5 @@ module Berkshelf
149
149
  class InvalidVersionConstraint < BerkshelfError; status_code(122); end
150
150
  class CommunitySiteError < BerkshelfError; status_code(123); end
151
151
  class CookbookValidationFailure < BerkshelfError; status_code(124); end
152
+ class ClientKeyFileNotFound < BerkshelfError; status_code(125); end
152
153
  end
@@ -84,7 +84,14 @@ module Berkshelf
84
84
  # the name of the client to use to communicate with the Chef API.
85
85
  # @option options [String] :client_key (Berkshelf::Config.instance.chef.client_key)
86
86
  # the filepath to the authentication key for the client
87
- # @option options [Boolean] :verify_ssl (Berkshelf::Config.instance.chef.ssl.verify)
87
+ # @option options [Boolean] :verify_ssl (Berkshelf::Config.instance.chef.ssl.verify)
88
+ #
89
+ # @raise [ClientKeyFileNotFound] if the value for :client_key does not contain a filepath
90
+ # pointing to a readable file containing a Chef client key.
91
+ #
92
+ # If the :chef_api option is given the symbol :config and your Berkshelf config does not
93
+ # have a value for chef.client_key which points to a readable file containing a Chef
94
+ # client key.
88
95
  def initialize(name, version_constraint, options = {})
89
96
  options = options.reverse_merge(
90
97
  client_key: Berkshelf::Config.instance.chef.client_key,
@@ -134,6 +141,8 @@ module Berkshelf
134
141
  # Why do we use a class function for defining our finalizer?
135
142
  # http://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/
136
143
  ObjectSpace.define_finalizer(self, self.class.finalizer)
144
+ rescue Ridley::Errors::ClientKeyFileNotFound => ex
145
+ raise ClientKeyFileNotFound, ex
137
146
  end
138
147
 
139
148
  # @param [#to_s] destination
@@ -159,10 +168,14 @@ module Berkshelf
159
168
  def target_cookbook
160
169
  return @target_cookbook unless @target_cookbook.nil?
161
170
 
162
- @target_cookbook = if version_constraint
163
- conn.cookbook.satisfy(name, version_constraint)
164
- else
165
- conn.cookbook.latest_version(name)
171
+ begin
172
+ @target_cookbook = if version_constraint
173
+ conn.cookbook.satisfy(name, version_constraint)
174
+ else
175
+ conn.cookbook.latest_version(name)
176
+ end
177
+ rescue Ridley::Errors::HTTPNotFound
178
+ @target_cookbook = nil
166
179
  end
167
180
 
168
181
  if @target_cookbook.nil?
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "1.3.0.rc1"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -10,8 +10,8 @@ Spork.prefork do
10
10
  require 'vcr'
11
11
 
12
12
  APP_ROOT = File.expand_path('../../', __FILE__)
13
- ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, "tmp", "berkshelf")
14
- ENV["BERKSHELF_CHEF_CONFIG"] = File.join(APP_ROOT, "tmp", "knife.rb")
13
+ ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, "spec", "tmp", "berkshelf")
14
+ ENV["BERKSHELF_CHEF_CONFIG"] = File.join(APP_ROOT, "spec", "tmp", "knife.rb")
15
15
 
16
16
  Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
17
17
 
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Berkshelf::ChefAPILocation, :chef_server do
4
4
  let(:test_chef_api) { "https://chefserver:8081" }
5
+ let(:node_name) { "reset" }
6
+ let(:client_key) { fixtures_path.join("reset.pem").to_s }
5
7
 
6
8
  describe "ClassMethods" do
7
9
  subject { described_class }
@@ -11,9 +13,6 @@ describe Berkshelf::ChefAPILocation, :chef_server do
11
13
  let(:constraint) { double('constraint') }
12
14
 
13
15
  describe "::initialize" do
14
- let(:node_name) { "reset" }
15
- let(:client_key) { fixtures_path.join("reset.pem").to_s }
16
-
17
16
  before(:each) do
18
17
  @location = subject.new("nginx",
19
18
  constraint,
@@ -104,7 +103,7 @@ describe Berkshelf::ChefAPILocation, :chef_server do
104
103
  end
105
104
 
106
105
  subject do
107
- described_class.new('nginx', nil, chef_api: :config)
106
+ described_class.new('nginx', nil, chef_api: test_chef_api, node_name: node_name, client_key: client_key)
108
107
  end
109
108
 
110
109
  describe "#target_cookbook" do
@@ -133,7 +132,7 @@ describe Berkshelf::ChefAPILocation, :chef_server do
133
132
 
134
133
  describe "#to_s" do
135
134
  it "returns a string containing the location key and the Chef API URI" do
136
- subject.to_s.should eql("chef_api: '#{Berkshelf::Config.instance.chef.chef_server_url}'")
135
+ subject.to_s.should eql("chef_api: '#{test_chef_api}'")
137
136
  end
138
137
  end
139
138
  end
@@ -52,5 +52,11 @@ describe Berkshelf do
52
52
  end
53
53
  end
54
54
  end
55
+
56
+ describe "::log" do
57
+ it "returns an instance of Logger" do
58
+ subject.log.should be_a(::Logger)
59
+ end
60
+ end
55
61
  end
56
62
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.rc1
5
- prerelease: 6
4
+ version: 1.3.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jamie Winsor
@@ -14,6 +14,22 @@ bindir: bin
14
14
  cert_chain: []
15
15
  date: 2013-03-20 00:00:00.000000000 Z
16
16
  dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: celluloid
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.13.0
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.0
17
33
  - !ruby/object:Gem::Dependency
18
34
  name: yajl-ruby
19
35
  requirement: !ruby/object:Gem::Requirement
@@ -35,49 +51,49 @@ dependencies:
35
51
  requirement: !ruby/object:Gem::Requirement
36
52
  none: false
37
53
  requirements:
38
- - - ~>
54
+ - - ! '>='
39
55
  - !ruby/object:Gem::Version
40
- version: '3.2'
56
+ version: 3.2.0
41
57
  type: :runtime
42
58
  prerelease: false
43
59
  version_requirements: !ruby/object:Gem::Requirement
44
60
  none: false
45
61
  requirements:
46
- - - ~>
62
+ - - ! '>='
47
63
  - !ruby/object:Gem::Version
48
- version: '3.2'
64
+ version: 3.2.0
49
65
  - !ruby/object:Gem::Dependency
50
66
  name: mixlib-shellout
51
67
  requirement: !ruby/object:Gem::Requirement
52
68
  none: false
53
69
  requirements:
54
- - - ! '>='
70
+ - - ~>
55
71
  - !ruby/object:Gem::Version
56
- version: '0'
72
+ version: '1.1'
57
73
  type: :runtime
58
74
  prerelease: false
59
75
  version_requirements: !ruby/object:Gem::Requirement
60
76
  none: false
61
77
  requirements:
62
- - - ! '>='
78
+ - - ~>
63
79
  - !ruby/object:Gem::Version
64
- version: '0'
80
+ version: '1.1'
65
81
  - !ruby/object:Gem::Dependency
66
82
  name: mixlib-config
67
83
  requirement: !ruby/object:Gem::Requirement
68
84
  none: false
69
85
  requirements:
70
- - - ! '>='
86
+ - - ~>
71
87
  - !ruby/object:Gem::Version
72
- version: '0'
88
+ version: '1.1'
73
89
  type: :runtime
74
90
  prerelease: false
75
91
  version_requirements: !ruby/object:Gem::Requirement
76
92
  none: false
77
93
  requirements:
78
- - - ! '>='
94
+ - - ~>
79
95
  - !ruby/object:Gem::Version
80
- version: '0'
96
+ version: '1.1'
81
97
  - !ruby/object:Gem::Dependency
82
98
  name: faraday
83
99
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +117,7 @@ dependencies:
101
117
  requirements:
102
118
  - - ! '>='
103
119
  - !ruby/object:Gem::Version
104
- version: 0.8.5
120
+ version: 0.8.6
105
121
  type: :runtime
106
122
  prerelease: false
107
123
  version_requirements: !ruby/object:Gem::Requirement
@@ -109,7 +125,7 @@ dependencies:
109
125
  requirements:
110
126
  - - ! '>='
111
127
  - !ruby/object:Gem::Version
112
- version: 0.8.5
128
+ version: 0.8.6
113
129
  - !ruby/object:Gem::Dependency
114
130
  name: chozo
115
131
  requirement: !ruby/object:Gem::Requirement
@@ -591,9 +607,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
591
607
  required_rubygems_version: !ruby/object:Gem::Requirement
592
608
  none: false
593
609
  requirements:
594
- - - ! '>'
610
+ - - ! '>='
595
611
  - !ruby/object:Gem::Version
596
- version: 1.3.1
612
+ version: '0'
613
+ segments:
614
+ - 0
615
+ hash: 1990198724109386499
597
616
  requirements: []
598
617
  rubyforge_project:
599
618
  rubygems_version: 1.8.24