berkshelf 1.0.0.rc2 → 1.0.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Thorfile +22 -6
- data/berkshelf.gemspec +1 -0
- data/features/update.feature +1 -1
- data/generator_files/metadata.rb.erb +2 -2
- data/lib/berkshelf/berksfile.rb +0 -1
- data/lib/berkshelf/cli.rb +1 -1
- data/lib/berkshelf/config.rb +33 -7
- data/lib/berkshelf/init_generator.rb +1 -1
- data/lib/berkshelf/locations/chef_api_location.rb +0 -14
- data/lib/berkshelf/vagrant/action/install.rb +4 -0
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf.rb +1 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/chef_api.rb +1 -2
- data/spec/unit/berkshelf/cookbook_store_spec.rb +1 -1
- data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +7 -7
- data/spec/unit/berkshelf/lockfile_spec.rb +2 -31
- metadata +18 -2
data/Thorfile
CHANGED
@@ -38,25 +38,41 @@ class Default < Thor
|
|
38
38
|
|
39
39
|
desc "all", "Run all tests"
|
40
40
|
def all
|
41
|
-
|
42
|
-
|
41
|
+
unless run_unit && run_acceptance
|
42
|
+
exit 1
|
43
|
+
end
|
43
44
|
end
|
44
45
|
|
45
46
|
desc "ci", "Run all possible tests on Travis-CI"
|
46
47
|
def ci
|
47
48
|
ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing
|
48
|
-
|
49
|
-
|
49
|
+
unless run_unit("--tag ~chef_server") && run_acceptance("--tags ~@chef_server")
|
50
|
+
exit 1
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
desc "unit", "Run unit tests"
|
53
55
|
def unit
|
54
|
-
|
56
|
+
unless run_unit
|
57
|
+
exit 1
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
desc "acceptance", "Run acceptance tests"
|
58
62
|
def acceptance
|
59
|
-
|
63
|
+
unless run_acceptance
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
no_tasks do
|
69
|
+
def run_unit(*flags)
|
70
|
+
run "rspec --color --format=documentation #{flags.join(' ')} spec"
|
71
|
+
end
|
72
|
+
|
73
|
+
def run_acceptance(*flags)
|
74
|
+
run "cucumber --color --format pretty --tags ~@no_run #{flags.join(' ')}"
|
75
|
+
end
|
60
76
|
end
|
61
77
|
end
|
62
78
|
|
data/berkshelf.gemspec
CHANGED
data/features/update.feature
CHANGED
@@ -10,7 +10,7 @@ Feature: update
|
|
10
10
|
"""
|
11
11
|
Given I write to "Berksfile.lock" with:
|
12
12
|
"""
|
13
|
-
cookbook 'artifact', :locked_version => '0.0
|
13
|
+
cookbook 'artifact', :locked_version => '0.1.0'
|
14
14
|
"""
|
15
15
|
When I run the update command
|
16
16
|
Then the file "Berksfile.lock" should contain exactly:
|
@@ -5,8 +5,8 @@ license "<%= license_name %>"
|
|
5
5
|
description "Installs/Configures <%= name %>"
|
6
6
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
7
7
|
<% if options[:scmversion] -%>
|
8
|
-
version IO.read(File.join(File.dirname(__FILE__), 'VERSION')) rescue "0.0
|
8
|
+
version IO.read(File.join(File.dirname(__FILE__), 'VERSION')) rescue "0.1.0"
|
9
9
|
<% else -%>
|
10
|
-
version "0.0
|
10
|
+
version "0.1.0"
|
11
11
|
<% end -%>
|
12
12
|
|
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -384,7 +384,6 @@ module Berkshelf
|
|
384
384
|
# @option options [URI, String, Hash] :proxy
|
385
385
|
# URI, String, or Hash of HTTP proxy options
|
386
386
|
def upload(options = {})
|
387
|
-
options[:organization] ||= ChefAPILocation.extract_organization(Chef::Config[:chef_server_url])
|
388
387
|
uploader = Uploader.new(options)
|
389
388
|
solution = resolve(options)
|
390
389
|
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -160,7 +160,7 @@ module Berkshelf
|
|
160
160
|
desc: "Upload all cookbooks even if a frozen one exists on the target Chef Server"
|
161
161
|
option :ssl_verify,
|
162
162
|
type: :boolean,
|
163
|
-
default:
|
163
|
+
default: nil,
|
164
164
|
desc: "Disable/Enable SSL verification when uploading cookbooks"
|
165
165
|
desc "upload", "Upload the Cookbooks specified by a Berksfile or a Berksfile.lock to a Chef Server"
|
166
166
|
def upload
|
data/lib/berkshelf/config.rb
CHANGED
@@ -6,17 +6,42 @@ module Berkshelf
|
|
6
6
|
class Config < Chozo::Config::JSON
|
7
7
|
FILENAME = "config.json".freeze
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# List taken from: http://wiki.opscode.com/display/chef/Chef+Configuration+Settings
|
10
|
+
# Listed in order of preferred preference
|
11
|
+
KNIFE_LOCATIONS = [
|
12
|
+
'./.chef/knife.rb',
|
13
|
+
'~/.chef/knife.rb',
|
14
|
+
'/etc/chef/solo.rb',
|
15
|
+
'/etc/chef/client.rb'
|
16
|
+
].freeze
|
11
17
|
|
18
|
+
class << self
|
12
19
|
# @return [String]
|
13
20
|
def path
|
14
|
-
File.join(Berkshelf.berkshelf_path, FILENAME)
|
21
|
+
@path || File.join(Berkshelf.berkshelf_path, FILENAME)
|
15
22
|
end
|
16
23
|
|
17
|
-
# @
|
24
|
+
# @param [String] new_path
|
25
|
+
def path=(new_path)
|
26
|
+
@path = File.expand_path(new_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String, nil]
|
18
30
|
def chef_config_path
|
19
|
-
@chef_config_path ||=
|
31
|
+
@chef_config_path ||= begin
|
32
|
+
possibles = KNIFE_LOCATIONS.dup
|
33
|
+
|
34
|
+
unless ENV['BERKSHELF_CHEF_CONFIG'].nil?
|
35
|
+
possibles.unshift(ENV['BERKSHELF_CHEF_CONFIG'])
|
36
|
+
end
|
37
|
+
|
38
|
+
location = possibles.find do |location|
|
39
|
+
File.exists?(File.expand_path(location))
|
40
|
+
end
|
41
|
+
location ||= "~/.chef/knife.rb"
|
42
|
+
|
43
|
+
File.expand_path(location)
|
44
|
+
end
|
20
45
|
end
|
21
46
|
|
22
47
|
# @param [String] value
|
@@ -86,7 +111,7 @@ module Berkshelf
|
|
86
111
|
default: Hash.new
|
87
112
|
attribute 'vagrant.vm.network.bridged',
|
88
113
|
type: Boolean,
|
89
|
-
default:
|
114
|
+
default: false
|
90
115
|
attribute 'vagrant.vm.network.hostonly',
|
91
116
|
type: String,
|
92
117
|
default: '33.33.33.10'
|
@@ -95,6 +120,7 @@ module Berkshelf
|
|
95
120
|
default: 'chef_solo'
|
96
121
|
attribute 'ssl.verify',
|
97
122
|
type: Boolean,
|
98
|
-
default: true
|
123
|
+
default: true,
|
124
|
+
required: true
|
99
125
|
end
|
100
126
|
end
|
@@ -56,20 +56,6 @@ module Berkshelf
|
|
56
56
|
|
57
57
|
true
|
58
58
|
end
|
59
|
-
|
60
|
-
# Retrieves the organization of a Chef API URI. If the URI does not contain an
|
61
|
-
# organization then nil will be returned.
|
62
|
-
#
|
63
|
-
# @param [String] uri
|
64
|
-
#
|
65
|
-
# @raise [InvalidChefAPILocation]
|
66
|
-
#
|
67
|
-
# @return [String, nil]
|
68
|
-
def extract_organization(uri)
|
69
|
-
validate_uri!(uri)
|
70
|
-
|
71
|
-
URI(uri).path.split('organizations/')[1]
|
72
|
-
end
|
73
59
|
end
|
74
60
|
|
75
61
|
include Location
|
@@ -34,6 +34,10 @@ module Berkshelf
|
|
34
34
|
|
35
35
|
def configure_cookbooks_path(env)
|
36
36
|
Berkshelf::Vagrant.provisioners(:chef_solo, env[:vm].config).each do |provisioner|
|
37
|
+
unless provisioner.config.cookbooks_path.is_a?(Array)
|
38
|
+
provisioner.config.cookbooks_path = Array(provisioner.config.cookbooks_path)
|
39
|
+
end
|
40
|
+
|
37
41
|
provisioner.config.cookbooks_path.unshift(self.shelf)
|
38
42
|
end
|
39
43
|
end
|
data/lib/berkshelf/version.rb
CHANGED
data/lib/berkshelf.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,8 @@ Spork.prefork do
|
|
11
11
|
require 'webmock/rspec'
|
12
12
|
|
13
13
|
APP_ROOT = File.expand_path('../../', __FILE__)
|
14
|
+
ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, "tmp", "berkshelf")
|
15
|
+
ENV["BERKSHELF_CHEF_CONFIG"] = File.join(APP_ROOT, "tmp", "knife.rb")
|
14
16
|
|
15
17
|
Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
|
16
18
|
|
data/spec/support/chef_api.rb
CHANGED
@@ -103,8 +103,7 @@ EOF
|
|
103
103
|
@uploader ||= Berkshelf::Uploader.new(
|
104
104
|
server_url: Chef::Config[:chef_server_url],
|
105
105
|
client_name: Chef::Config[:node_name],
|
106
|
-
client_key: Chef::Config[:client_key]
|
107
|
-
organization: Berkshelf::ChefAPILocation.extract_organization(Chef::Config[:chef_server_url])
|
106
|
+
client_key: Chef::Config[:client_key]
|
108
107
|
)
|
109
108
|
end
|
110
109
|
end
|
@@ -61,7 +61,7 @@ module Berkshelf
|
|
61
61
|
|
62
62
|
context "when there is no matching cookbook for the given name and constraint" do
|
63
63
|
let(:version) { Solve::Version.new("1.0.0") }
|
64
|
-
let(:constraint) { Solve::Constraint.new("= 0.0
|
64
|
+
let(:constraint) { Solve::Constraint.new("= 0.1.0") }
|
65
65
|
|
66
66
|
before(:each) do
|
67
67
|
subject.stub(:cookbooks).and_return([ double('badcache', name: 'none', version: version) ])
|
@@ -66,16 +66,16 @@ module Berkshelf
|
|
66
66
|
context "given the symbol :config for the value of chef_api:" do
|
67
67
|
before(:each) { @loc = subject.new("nginx", constraint, chef_api: :config) }
|
68
68
|
|
69
|
-
it "uses the value of Chef
|
70
|
-
@loc.uri.should eql(
|
69
|
+
it "uses the value of Berkshelf::Chef.instance.chef.chef_server_url for the uri attribute" do
|
70
|
+
@loc.uri.should eql(Berkshelf::Config.instance.chef.chef_server_url)
|
71
71
|
end
|
72
72
|
|
73
|
-
it "uses the value of Chef
|
74
|
-
@loc.node_name.should eql(
|
73
|
+
it "uses the value of Berkshelf::Chef.instance.chef.node_name for the node_name attribute" do
|
74
|
+
@loc.node_name.should eql(Berkshelf::Config.instance.chef.node_name)
|
75
75
|
end
|
76
76
|
|
77
|
-
it "uses the value of Chef
|
78
|
-
@loc.client_key.should eql(
|
77
|
+
it "uses the value of Berkshelf::Chef.instance.chef.client_key for the client_key attribute" do
|
78
|
+
@loc.client_key.should eql(Berkshelf::Config.instance.chef.client_key)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -228,7 +228,7 @@ module Berkshelf
|
|
228
228
|
end
|
229
229
|
|
230
230
|
it "returns a string containing the location key and the Chef API URI" do
|
231
|
-
subject.to_s.should eql("chef_api: '#{
|
231
|
+
subject.to_s.should eql("chef_api: '#{Berkshelf::Config.instance.chef.chef_server_url}'")
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -1,34 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
let(:downloader) { Downloader.new(Berkshelf.cookbook_store) }
|
6
|
-
|
7
|
-
describe "without a lockfile in place already" do
|
8
|
-
before(:all) do
|
9
|
-
@old_dir = Dir.pwd
|
10
|
-
Dir.chdir fixtures_path.join("lockfile_spec", "without_lock")
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:all) do
|
14
|
-
FileUtils.rm(fixtures_path.join("lockfile_spec", "without_lock", "Berksfile.lock"))
|
15
|
-
Dir.chdir(@old_dir)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be able to write a Berksfile.lock from a list of cookbooks" do
|
19
|
-
resolver = Resolver.new(downloader, sources: CookbookSource.new('nginx', constraint: '= 0.101.0'))
|
20
|
-
resolver.resolve
|
21
|
-
|
22
|
-
Lockfile.new(resolver.sources).write
|
23
|
-
|
24
|
-
File.read('Berksfile.lock').split(/\r?\n/).should =~ [
|
25
|
-
"cookbook 'bluepill', :locked_version => '1.1.0'",
|
26
|
-
"cookbook 'build-essential', :locked_version => '1.1.2'",
|
27
|
-
"cookbook 'nginx', :locked_version => '0.101.0'",
|
28
|
-
"cookbook 'ohai', :locked_version => '1.0.2'",
|
29
|
-
"cookbook 'runit', :locked_version => '0.15.0'"
|
30
|
-
]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
3
|
+
describe Berkshelf::Lockfile do
|
4
|
+
pending
|
34
5
|
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: 1.0.0.
|
4
|
+
version: 1.0.0.rc3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,8 +12,24 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-11-
|
15
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: yajl-ruby
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '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'
|
17
33
|
- !ruby/object:Gem::Dependency
|
18
34
|
name: activesupport
|
19
35
|
requirement: !ruby/object:Gem::Requirement
|