berkshelf 1.0.0.rc1 → 1.0.0.rc2
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/.travis.yml +2 -0
- data/Gemfile +11 -11
- data/Guardfile +1 -1
- data/README.md +1 -1
- data/berkshelf.gemspec +10 -11
- data/features/config.feature +1 -1
- data/features/cookbook_command.feature +1 -1
- data/features/default_locations.feature +6 -6
- data/features/groups_install.feature +3 -3
- data/features/init_command.feature +1 -1
- data/features/lockfile.feature +1 -1
- data/features/support/env.rb +1 -1
- data/features/upload_command.feature +1 -1
- data/lib/berkshelf.rb +14 -14
- data/lib/berkshelf/base_generator.rb +1 -1
- data/lib/berkshelf/berksfile.rb +22 -22
- data/lib/berkshelf/cached_cookbook.rb +1 -1
- data/lib/berkshelf/cli.rb +1 -1
- data/lib/berkshelf/cookbook_generator.rb +1 -1
- data/lib/berkshelf/cookbook_source.rb +1 -1
- data/lib/berkshelf/cookbook_store.rb +2 -2
- data/lib/berkshelf/core_ext/file_utils.rb +1 -1
- data/lib/berkshelf/core_ext/pathname.rb +2 -2
- data/lib/berkshelf/formatters.rb +1 -1
- data/lib/berkshelf/formatters/json.rb +1 -1
- data/lib/berkshelf/git.rb +2 -2
- data/lib/berkshelf/init_generator.rb +1 -1
- data/lib/berkshelf/location.rb +2 -2
- data/lib/berkshelf/locations/chef_api_location.rb +15 -8
- data/lib/berkshelf/locations/git_location.rb +2 -2
- data/lib/berkshelf/locations/site_location.rb +3 -3
- data/lib/berkshelf/resolver.rb +2 -2
- data/lib/berkshelf/vagrant/action/validate.rb +3 -3
- data/lib/berkshelf/vagrant/middleware.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/spec/spec_helper.rb +6 -5
- data/spec/unit/berkshelf/berksfile_spec.rb +9 -9
- data/spec/unit/berkshelf/config_spec.rb +1 -1
- data/spec/unit/berkshelf/cookbook_source_spec.rb +3 -3
- data/spec/unit/berkshelf/cookbook_store_spec.rb +1 -1
- data/spec/unit/berkshelf/downloader_spec.rb +3 -3
- data/spec/unit/berkshelf/git_spec.rb +1 -1
- data/spec/unit/berkshelf/location_spec.rb +3 -3
- data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +10 -12
- data/spec/unit/berkshelf/locations/git_location_spec.rb +2 -2
- data/spec/unit/berkshelf/lockfile_spec.rb +1 -1
- data/spec/unit/berkshelf/resolver_spec.rb +5 -5
- metadata +38 -54
@@ -50,7 +50,7 @@ module Berkshelf
|
|
50
50
|
empty_directory target.join("providers")
|
51
51
|
empty_directory target.join("recipes")
|
52
52
|
empty_directory target.join("resources")
|
53
|
-
|
53
|
+
|
54
54
|
template "default_recipe.erb", target.join("recipes/default.rb")
|
55
55
|
template "metadata.rb.erb", target.join("metadata.rb")
|
56
56
|
template license_file, target.join("LICENSE")
|
@@ -107,7 +107,7 @@ module Berkshelf
|
|
107
107
|
if @location.is_a?(PathLocation)
|
108
108
|
@cached_cookbook = CachedCookbook.from_path(location.path)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
@locked_version = Solve::Version.new(options[:locked_version]) if options[:locked_version]
|
112
112
|
|
113
113
|
add_group(options[:group]) if options[:group]
|
@@ -44,7 +44,7 @@ module Berkshelf
|
|
44
44
|
[].tap do |cookbooks|
|
45
45
|
storage_path.each_child do |p|
|
46
46
|
cached_cookbook = CachedCookbook.from_store_path(p)
|
47
|
-
|
47
|
+
|
48
48
|
next unless cached_cookbook
|
49
49
|
next if filter && cached_cookbook.cookbook_name != filter
|
50
50
|
|
@@ -76,7 +76,7 @@ module Berkshelf
|
|
76
76
|
cookbooks(name).each { |cookbook| graph.artifacts(name, cookbook.version) }
|
77
77
|
|
78
78
|
name, version = Solve.it!(graph, [[name, constraint]]).first
|
79
|
-
|
79
|
+
|
80
80
|
cookbook(name, version)
|
81
81
|
rescue Solve::Errors::NoSolutionError
|
82
82
|
nil
|
@@ -16,7 +16,7 @@ module FileUtils
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
# If we encounter Errno::EACCES, which seems to happen occasionally on Windows,
|
19
|
+
# If we encounter Errno::EACCES, which seems to happen occasionally on Windows,
|
20
20
|
# try to copy and delete the file instead of moving it.
|
21
21
|
#
|
22
22
|
# @see https://github.com/RiotGames/berkshelf/issues/140
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Pathname
|
2
|
-
# Returns true or false if the path of the instantiated
|
3
|
-
# Pathname or a parent directory contains a Tryhard Pack
|
2
|
+
# Returns true or false if the path of the instantiated
|
3
|
+
# Pathname or a parent directory contains a Tryhard Pack
|
4
4
|
# data directory.
|
5
5
|
#
|
6
6
|
# @return [Boolean]
|
data/lib/berkshelf/formatters.rb
CHANGED
@@ -49,7 +49,7 @@ module Berkshelf
|
|
49
49
|
|
50
50
|
# @author Michael Ivey <ivey@gweezlebur.com>
|
51
51
|
#
|
52
|
-
# @abstract Include and override {#install} {#use} {#upload}
|
52
|
+
# @abstract Include and override {#install} {#use} {#upload}
|
53
53
|
# {#msg} {#error} to implement.
|
54
54
|
#
|
55
55
|
# Implement {#cleanup_hook} to run any steps required to run after the task is finished
|
data/lib/berkshelf/git.rb
CHANGED
@@ -26,7 +26,7 @@ module Berkshelf
|
|
26
26
|
unless cmd.exitstatus == 0
|
27
27
|
raise GitError.new(cmd.stderr)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
cmd.stdout.chomp
|
31
31
|
end
|
32
32
|
|
@@ -102,7 +102,7 @@ module Berkshelf
|
|
102
102
|
# "https://github.com/reset/solve.git"
|
103
103
|
# @example Valid SSH protocol URI
|
104
104
|
# "git@github.com:reset/solve.git"
|
105
|
-
#
|
105
|
+
#
|
106
106
|
# @param [String] uri
|
107
107
|
#
|
108
108
|
# @return [Boolean]
|
data/lib/berkshelf/location.rb
CHANGED
@@ -2,7 +2,7 @@ module Berkshelf
|
|
2
2
|
# @author Jamie Winsor <jamie@vialstudios.com>
|
3
3
|
module Location
|
4
4
|
OPSCODE_COMMUNITY_API = 'http://cookbooks.opscode.com/api/v1/cookbooks'.freeze
|
5
|
-
|
5
|
+
|
6
6
|
module ClassMethods
|
7
7
|
# Returns the location identifier key for the class
|
8
8
|
#
|
@@ -32,7 +32,7 @@ module Berkshelf
|
|
32
32
|
#
|
33
33
|
# @example:
|
34
34
|
# constraint = Solve::Constraint.new("~> 0.101.2")
|
35
|
-
# versions = {
|
35
|
+
# versions = {
|
36
36
|
# "1.0.0" => "http://cookbooks.opscode.com/api/v1/cookbooks/nginx/versions/1_0_0",
|
37
37
|
# "2.0.0" => "http://cookbooks.opscode.com/api/v1/cookbooks/nginx/versions/2_0_0"
|
38
38
|
# }
|
@@ -45,7 +45,7 @@ module Berkshelf
|
|
45
45
|
uri =~ URI.regexp(['http', 'https'])
|
46
46
|
end
|
47
47
|
|
48
|
-
# @raise [InvalidChefAPILocation] if the given object is not a String containing a
|
48
|
+
# @raise [InvalidChefAPILocation] if the given object is not a String containing a
|
49
49
|
# valid Chef API URI
|
50
50
|
#
|
51
51
|
# @see validate_uri
|
@@ -130,16 +130,14 @@ module Berkshelf
|
|
130
130
|
# @return [Berkshelf::CachedCookbook]
|
131
131
|
def download(destination)
|
132
132
|
version, uri = target_version
|
133
|
-
|
134
|
-
|
135
|
-
scratch = download_files(cookbook.manifest)
|
133
|
+
scratch = download_files(download_manifest(uri))
|
136
134
|
|
137
135
|
cb_path = File.join(destination, "#{name}-#{version}")
|
138
136
|
FileUtils.mv(scratch, cb_path)
|
139
137
|
|
140
138
|
cached = CachedCookbook.from_store_path(cb_path)
|
141
139
|
validate_cached(cached)
|
142
|
-
|
140
|
+
|
143
141
|
set_downloaded_status(true)
|
144
142
|
cached
|
145
143
|
end
|
@@ -148,7 +146,7 @@ module Berkshelf
|
|
148
146
|
# The keys are version strings and the values are URLs to download the cookbook version.
|
149
147
|
#
|
150
148
|
# @example
|
151
|
-
# {
|
149
|
+
# {
|
152
150
|
# "0.101.2" => "https://api.opscode.com/organizations/vialstudios/cookbooks/nginx/0.101.2",
|
153
151
|
# "0.101.5" => "https://api.opscode.com/organizations/vialstudios/cookbooks/nginx/0.101.5"
|
154
152
|
# }
|
@@ -200,6 +198,15 @@ module Berkshelf
|
|
200
198
|
|
201
199
|
attr_reader :rest
|
202
200
|
|
201
|
+
# Retrieve a cookbooks manifest from the given URL
|
202
|
+
#
|
203
|
+
# @param [String] uri
|
204
|
+
#
|
205
|
+
# @return [Hash]
|
206
|
+
def download_manifest(uri)
|
207
|
+
Chef::CookbookVersion.json_create(rest.get_rest(uri)).manifest
|
208
|
+
end
|
209
|
+
|
203
210
|
# Returns an array containing the version and download URL for the cookbook version that
|
204
211
|
# should be downloaded for this location.
|
205
212
|
#
|
@@ -210,7 +217,7 @@ module Berkshelf
|
|
210
217
|
def target_version
|
211
218
|
if version_constraint
|
212
219
|
solution = self.class.solve_for_constraint(version_constraint, versions)
|
213
|
-
|
220
|
+
|
214
221
|
unless solution
|
215
222
|
raise NoSolution, "No cookbook version of '#{name}' found at #{self} that would satisfy constraint (#{version_constraint})."
|
216
223
|
end
|
@@ -268,7 +275,7 @@ module Berkshelf
|
|
268
275
|
|
269
276
|
self.class.validate_node_name!(options[:node_name])
|
270
277
|
self.class.validate_client_key!(options[:client_key])
|
271
|
-
self.class.validate_uri!(options[:chef_api])
|
278
|
+
self.class.validate_uri!(options[:chef_api])
|
272
279
|
end
|
273
280
|
end
|
274
281
|
end
|
@@ -45,7 +45,7 @@ module Berkshelf
|
|
45
45
|
end
|
46
46
|
|
47
47
|
unless File.chef_cookbook?(tmp_clone)
|
48
|
-
msg = "Cookbook '#{name}' not found at git: #{uri}"
|
48
|
+
msg = "Cookbook '#{name}' not found at git: #{uri}"
|
49
49
|
msg << " with branch '#{branch}'" if branch
|
50
50
|
raise CookbookNotFound, msg
|
51
51
|
end
|
@@ -53,7 +53,7 @@ module Berkshelf
|
|
53
53
|
cb_path = File.join(destination, "#{self.name}-#{Git.rev_parse(tmp_clone)}")
|
54
54
|
FileUtils.rm_rf(cb_path)
|
55
55
|
FileUtils.mv(tmp_clone, cb_path)
|
56
|
-
|
56
|
+
|
57
57
|
cached = CachedCookbook.from_store_path(cb_path)
|
58
58
|
validate_cached(cached)
|
59
59
|
|
@@ -57,7 +57,7 @@ module Berkshelf
|
|
57
57
|
|
58
58
|
cached = CachedCookbook.from_store_path(cb_path)
|
59
59
|
validate_cached(cached)
|
60
|
-
|
60
|
+
|
61
61
|
set_downloaded_status(true)
|
62
62
|
cached
|
63
63
|
end
|
@@ -66,7 +66,7 @@ module Berkshelf
|
|
66
66
|
# name of this location.
|
67
67
|
#
|
68
68
|
# @example
|
69
|
-
# {
|
69
|
+
# {
|
70
70
|
# "0.101.2" => "http://cookbooks.opscode.com/api/v1/cookbooks/nginx/versions/0_101_2",
|
71
71
|
# "0.101.0" => "http://cookbooks.opscode.com/api/v1/cookbooks/nginx/versions/0_101_0"
|
72
72
|
# }
|
@@ -142,7 +142,7 @@ module Berkshelf
|
|
142
142
|
def target_version
|
143
143
|
if version_constraint
|
144
144
|
solution = self.class.solve_for_constraint(version_constraint, versions)
|
145
|
-
|
145
|
+
|
146
146
|
unless solution
|
147
147
|
raise NoSolution, "No cookbook version of '#{name}' found at #{self} that would satisfy constraint (#{version_constraint})."
|
148
148
|
end
|
data/lib/berkshelf/resolver.rb
CHANGED
@@ -47,7 +47,7 @@ module Berkshelf
|
|
47
47
|
use_source(source) || install_source(source)
|
48
48
|
|
49
49
|
graph.artifacts(source.name, source.cached_cookbook.version)
|
50
|
-
|
50
|
+
|
51
51
|
if include_dependencies
|
52
52
|
add_source_dependencies(source)
|
53
53
|
end
|
@@ -142,7 +142,7 @@ module Berkshelf
|
|
142
142
|
# CookbookSource.
|
143
143
|
#
|
144
144
|
# @return [Boolean]
|
145
|
-
def use_source(source)
|
145
|
+
def use_source(source)
|
146
146
|
if source.downloaded?
|
147
147
|
cached = source.cached_cookbook
|
148
148
|
source.location.validate_cached(cached)
|
@@ -16,13 +16,13 @@ module Berkshelf
|
|
16
16
|
def call(env)
|
17
17
|
recorder = ::Vagrant::Config::ErrorRecorder.new
|
18
18
|
env[:vm].config.berkshelf.validate(env[:vm].env, recorder)
|
19
|
-
|
19
|
+
|
20
20
|
unless recorder.errors.empty?
|
21
|
-
raise ::Vagrant::Errors::ConfigValidationFailed,
|
21
|
+
raise ::Vagrant::Errors::ConfigValidationFailed,
|
22
22
|
messages: ::Vagrant::Util::TemplateRenderer.render("config/validation_failed", errors: { berkshelf: recorder })
|
23
23
|
end
|
24
24
|
|
25
|
-
@app.call(env)
|
25
|
+
@app.call(env)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/berkshelf/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
2
3
|
require 'bundler'
|
3
4
|
require 'spork'
|
4
5
|
require 'vcr'
|
5
6
|
|
6
7
|
Spork.prefork do
|
7
|
-
require 'rspec'
|
8
|
-
require 'pp'
|
9
8
|
require 'json_spec'
|
9
|
+
require 'pp'
|
10
|
+
require 'rspec'
|
10
11
|
require 'webmock/rspec'
|
11
|
-
|
12
|
+
|
12
13
|
APP_ROOT = File.expand_path('../../', __FILE__)
|
13
|
-
|
14
|
+
|
14
15
|
Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
|
15
16
|
|
16
17
|
VCR.configure do |c|
|
@@ -22,7 +23,7 @@ Spork.prefork do
|
|
22
23
|
config.include Berkshelf::RSpec::FileSystemMatchers
|
23
24
|
config.include JsonSpec::Helpers
|
24
25
|
config.include Berkshelf::RSpec::ChefAPI
|
25
|
-
|
26
|
+
|
26
27
|
config.mock_with :rspec
|
27
28
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
28
29
|
config.filter_run focus: true
|
@@ -10,7 +10,7 @@ cookbook 'nginx', '< 0.101.2'
|
|
10
10
|
cookbook 'ssh_known_hosts2', :git => 'https://github.com/erikh/chef-ssh_known_hosts2.git'
|
11
11
|
EOF
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
describe "ClassMethods" do
|
15
15
|
subject { Berksfile }
|
16
16
|
|
@@ -36,7 +36,7 @@ EOF
|
|
36
36
|
it "returns the expanded filepath of the vendor directory" do
|
37
37
|
cached_cookbooks = Array.new
|
38
38
|
tmpdir = Dir.mktmpdir(nil, tmp_path)
|
39
|
-
|
39
|
+
|
40
40
|
subject.vendor(cached_cookbooks, tmpdir).should eql(tmpdir)
|
41
41
|
end
|
42
42
|
end
|
@@ -93,7 +93,7 @@ EOF
|
|
93
93
|
|
94
94
|
it "sends the add_source message with an array of groups determined by the parameter passed to the group block" do
|
95
95
|
subject.should_receive(:add_source).with(name, nil, group: [group])
|
96
|
-
|
96
|
+
|
97
97
|
subject.group group do
|
98
98
|
subject.cookbook name
|
99
99
|
end
|
@@ -108,7 +108,7 @@ EOF
|
|
108
108
|
|
109
109
|
it "sends the add_source message with an explicit version constraint and the path to the cookbook" do
|
110
110
|
subject.should_receive(:add_source).with("example_cookbook", "= 0.5.0", path: cb_path.to_s)
|
111
|
-
|
111
|
+
|
112
112
|
subject.metadata
|
113
113
|
end
|
114
114
|
end
|
@@ -147,11 +147,11 @@ EOF
|
|
147
147
|
subject.chef_api(uri, options)
|
148
148
|
end
|
149
149
|
|
150
|
-
context "given the symbol :
|
151
|
-
it "sends an add_location message with the the type :chef_api and the URI :
|
152
|
-
subject.should_receive(:add_location).with(:chef_api, :
|
150
|
+
context "given the symbol :config" do
|
151
|
+
it "sends an add_location message with the the type :chef_api and the URI :config" do
|
152
|
+
subject.should_receive(:add_location).with(:chef_api, :config, {})
|
153
153
|
|
154
|
-
subject.chef_api(:
|
154
|
+
subject.chef_api(:config)
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
@@ -384,7 +384,7 @@ EOF
|
|
384
384
|
|
385
385
|
it "delegates 'add_location' to the downloader" do
|
386
386
|
subject.downloader.should_receive(:add_location).with(type, value, options)
|
387
|
-
|
387
|
+
|
388
388
|
subject.add_location(type, value, options)
|
389
389
|
end
|
390
390
|
end
|
@@ -117,7 +117,7 @@ module Berkshelf
|
|
117
117
|
after(:each) do
|
118
118
|
subject.class_variable_set :@@location_keys, @original
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "adds a location key and the associated class to the list of valid locations" do
|
122
122
|
subject.add_location_key(:git, subject.class)
|
123
123
|
|
@@ -129,7 +129,7 @@ module Berkshelf
|
|
129
129
|
it "does not add duplicate location keys to the list of location keys" do
|
130
130
|
subject.add_location_key(:git, subject.class)
|
131
131
|
subject.add_location_key(:git, subject.class)
|
132
|
-
|
132
|
+
|
133
133
|
subject.location_keys.should have(1).item
|
134
134
|
subject.location_keys.should include(:git)
|
135
135
|
end
|
@@ -228,7 +228,7 @@ module Berkshelf
|
|
228
228
|
describe "#to_s" do
|
229
229
|
it "contains the name, constraint, and groups" do
|
230
230
|
source = CookbookSource.new("artifact", constraint: "= 0.10.0")
|
231
|
-
|
231
|
+
|
232
232
|
source.to_s.should eql("artifact (= 0.10.0) groups: [:default]")
|
233
233
|
end
|
234
234
|
|
@@ -102,7 +102,7 @@ module Berkshelf
|
|
102
102
|
end
|
103
103
|
|
104
104
|
context "given a value for the filter parameter" do
|
105
|
-
it "returns only the CachedCookbooks whose name match the filter" do
|
105
|
+
it "returns only the CachedCookbooks whose name match the filter" do
|
106
106
|
subject.cookbooks("mysql").should have(1).item
|
107
107
|
end
|
108
108
|
end
|
@@ -54,7 +54,7 @@ module Berkshelf
|
|
54
54
|
source.should_receive(:cached_cookbook=).with(cached_cookbook)
|
55
55
|
end
|
56
56
|
|
57
|
-
it "sends 'download' to the source's location and sets the source's cached_cookbook to the result" do
|
57
|
+
it "sends 'download' to the source's location and sets the source's cached_cookbook to the result" do
|
58
58
|
subject.download(source).should be_true
|
59
59
|
end
|
60
60
|
|
@@ -70,11 +70,11 @@ module Berkshelf
|
|
70
70
|
context "when the source does not have a location" do
|
71
71
|
before(:each) do
|
72
72
|
source.stub(:location).and_return(nil)
|
73
|
-
subject.stub(:locations).and_return([{type: :chef_api, value: :
|
73
|
+
subject.stub(:locations).and_return([{type: :chef_api, value: :config, options: Hash.new}])
|
74
74
|
end
|
75
75
|
|
76
76
|
it "sends the 'download' message to the default location" do
|
77
|
-
Location.should_receive(:init).with(source.name, source.version_constraint, chef_api: :
|
77
|
+
Location.should_receive(:init).with(source.name, source.version_constraint, chef_api: :config).and_return(location)
|
78
78
|
location.should_receive(:download).with(subject.storage_path).and_return(cached_cookbook)
|
79
79
|
source.should_receive(:cached_cookbook=).with(cached_cookbook)
|
80
80
|
|