berkshelf 3.0.0.beta2 → 3.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +0 -1
- data/Guardfile +0 -4
- data/README.md +1 -1
- data/Thorfile +2 -11
- data/berkshelf.gemspec +2 -5
- data/features/berksfile.feature +2 -10
- data/features/commands/apply.feature +31 -0
- data/features/{configure_command.feature → commands/configure.feature} +9 -11
- data/features/{contingent_command.feature → commands/contingent.feature} +10 -20
- data/features/{cookbook_command.feature → commands/cookbook.feature} +4 -11
- data/features/{init_command.feature → commands/init.feature} +10 -19
- data/features/{install_command.feature → commands/install.feature} +161 -82
- data/features/{list_command.feature → commands/list.feature} +4 -14
- data/features/{outdated_command.feature → commands/outdated.feature} +21 -63
- data/features/{package_command.feature → commands/package.feature} +11 -22
- data/features/{shelf → commands/shelf}/list.feature +3 -8
- data/features/{shelf → commands/shelf}/show.feature +5 -9
- data/features/{shelf → commands/shelf}/uninstall.feature +6 -10
- data/features/{show_command.feature → commands/show.feature} +13 -38
- data/features/commands/update.feature +48 -0
- data/features/commands/upload.feature +197 -0
- data/features/commands/vendor.feature +53 -0
- data/features/community_site.feature +39 -0
- data/features/config.feature +79 -9
- data/features/help.feature +10 -19
- data/features/json_formatter.feature +19 -44
- data/features/licenses.feature +27 -61
- data/features/lockfile.feature +120 -354
- data/features/resolver.feature +28 -0
- data/features/step_definitions/berksfile_steps.rb +39 -0
- data/features/step_definitions/chef/config_steps.rb +1 -1
- data/features/step_definitions/chef_server_steps.rb +27 -27
- data/features/step_definitions/config_steps.rb +3 -0
- data/features/step_definitions/filesystem_steps.rb +10 -0
- data/features/step_definitions/json_steps.rb +0 -7
- data/features/step_definitions/lockfile_steps.rb +53 -0
- data/features/step_definitions/utility_steps.rb +4 -4
- data/features/support/env.rb +1 -0
- data/generator_files/Berksfile.erb +1 -1
- data/generator_files/README.md.erb +62 -6
- data/generator_files/Vagrantfile.erb +15 -4
- data/lib/berkshelf.rb +2 -4
- data/lib/berkshelf/api_client.rb +5 -7
- data/lib/berkshelf/berksfile.rb +24 -20
- data/lib/berkshelf/cached_cookbook.rb +8 -1
- data/lib/berkshelf/cli.rb +5 -10
- data/lib/berkshelf/community_rest.rb +4 -5
- data/lib/berkshelf/config.rb +8 -2
- data/lib/berkshelf/cookbook_store.rb +9 -14
- data/lib/berkshelf/dependency.rb +16 -13
- data/lib/berkshelf/errors.rb +15 -1
- data/lib/berkshelf/formatters/json.rb +1 -1
- data/lib/berkshelf/init_generator.rb +17 -3
- data/lib/berkshelf/installer.rb +12 -1
- data/lib/berkshelf/logger.rb +7 -4
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/spec/spec_helper.rb +0 -9
- data/spec/support/chef_server.rb +24 -7
- data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +3 -3
- data/spec/unit/berkshelf/berksfile_spec.rb +35 -1
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +8 -0
- data/spec/unit/berkshelf/community_rest_spec.rb +76 -25
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +9 -3
- data/spec/unit/berkshelf/dependency_spec.rb +16 -1
- data/spec/unit/berkshelf/init_generator_spec.rb +71 -7
- metadata +44 -116
- data/.cane +0 -4
- data/features/apply_command.feature +0 -40
- data/features/groups_install.feature +0 -113
- data/features/update_command.feature +0 -136
- data/features/upload_command.feature +0 -327
- data/features/vendor_command.feature +0 -83
- data/lib/berkshelf/chef.rb +0 -7
- data/lib/berkshelf/chef/cookbook.rb +0 -5
- data/lib/berkshelf/chef/cookbook/chefignore.rb +0 -75
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_download/unpacks_the_archive.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/returns_the_cookbook_and_version_information.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/returns_the_version_number_of_the_latest_version_of_the_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_satisfy/returns_the_version_number_of_the_best_solution.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/returns_an_array_containing_an_item_for_each_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +0 -3694
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_source_as_sources.yml +0 -3829
- data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +0 -19
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Berkshelf resolver
|
2
|
+
Background:
|
3
|
+
* the Berkshelf API server's cache is empty
|
4
|
+
* the Chef Server has cookbooks:
|
5
|
+
| berkshelf | 1.0.0 |
|
6
|
+
| berkshelf | 2.0.0 |
|
7
|
+
* the Berkshelf API server's cache is up to date
|
8
|
+
* I have a Berksfile pointing at the local Berkshelf API with:
|
9
|
+
"""
|
10
|
+
cookbook 'berkshelf'
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: with DEBUG_RESOLVER=1
|
14
|
+
Given the environment variable DEBUG_RESOLVER is "1"
|
15
|
+
When I successfully run `berks install`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
Attempting to find a solution
|
19
|
+
Adding constraint berkshelf >= 0.0.0 from root
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: without DEBUG_RESOLVER
|
23
|
+
Given the environment variable DEBUG_RESOLVER is nil
|
24
|
+
When I successfully run `berks install`
|
25
|
+
Then the output should not contain:
|
26
|
+
"""
|
27
|
+
Attempting to find a solution
|
28
|
+
"""
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Given /I have a Berksfile pointing at the community API endpoint with:/ do |content|
|
2
|
+
steps %Q{
|
3
|
+
Given a file named "Berksfile" with:
|
4
|
+
"""
|
5
|
+
source '#{Berkshelf::Berksfile::DEFAULT_API_URL}'
|
6
|
+
|
7
|
+
#{content}
|
8
|
+
"""
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^I have a Berksfile pointing at the local Berkshelf API$/ do
|
13
|
+
steps %Q{
|
14
|
+
Given I have a Berksfile pointing at the local Berkshelf API with:
|
15
|
+
"""
|
16
|
+
"""
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
Given /^I have a Berksfile pointing at the local Berkshelf API with:$/ do |content|
|
21
|
+
steps %Q{
|
22
|
+
Given I have a Berksfile at "." pointing at the local Berkshelf API with:
|
23
|
+
"""
|
24
|
+
#{content}
|
25
|
+
"""
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
Given /^I have a Berksfile at "(.+)" pointing at the local Berkshelf API with:$/ do |path, content|
|
30
|
+
steps %Q{
|
31
|
+
Given a directory named "#{path}"
|
32
|
+
And a file named "#{path}/Berksfile" with:
|
33
|
+
"""
|
34
|
+
source 'http://0.0.0.0:#{BERKS_API_PORT}'
|
35
|
+
|
36
|
+
#{content}
|
37
|
+
"""
|
38
|
+
}
|
39
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
World(Berkshelf::RSpec::
|
1
|
+
World(Berkshelf::RSpec::ChefServer)
|
2
2
|
|
3
3
|
Given(/^the Chef Server is empty$/) do
|
4
4
|
Berkshelf::RSpec::ChefServer.reset!
|
@@ -6,48 +6,48 @@ end
|
|
6
6
|
|
7
7
|
Given /^the Chef Server has cookbooks:$/ do |cookbooks|
|
8
8
|
cookbooks.raw.each do |name, version|
|
9
|
-
|
10
|
-
cb_path = generate_cookbook(tmp_path, name, version)
|
11
|
-
upload_cookbook(cb_path, freeze: false, force: true)
|
9
|
+
chef_cookbook(name, { 'metadata.rb' => "version '#{version}'" })
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
13
|
Given /^the Chef Server has frozen cookbooks:$/ do |cookbooks|
|
16
14
|
cookbooks.raw.each do |name, version|
|
17
|
-
|
18
|
-
cb_path = generate_cookbook(tmp_path, name, version)
|
19
|
-
upload_cookbook(cb_path, freeze: true, force: true)
|
15
|
+
chef_cookbook(name, { 'metadata.rb' => "version '#{version}'", frozen: true })
|
20
16
|
end
|
21
|
-
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
expect(server_has_cookbook?(name, version)).to be_true
|
26
|
-
end
|
19
|
+
Given(/^the Chef Server has an environment named "(.*?)"$/) do |name|
|
20
|
+
chef_environment(name, { 'description' => 'This is an environment' })
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
Given(/^the Chef Server does not have an environment named "(.*?)"$/) do |name|
|
24
|
+
if chef_server.data_store.exists?(['environments', name])
|
25
|
+
chef_server.data_store.delete(['environments', name])
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
35
|
-
Then
|
36
|
-
|
37
|
-
|
38
|
-
expect(
|
29
|
+
Then /^the Chef Server should have the cookbooks:$/ do |cookbooks|
|
30
|
+
list = chef_cookbooks
|
31
|
+
cookbooks.raw.each do |name, version|
|
32
|
+
expect(list.keys).to include(name)
|
33
|
+
expect(list[name]).to include(version) unless version.nil?
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
Then /^the Chef Server should not have the cookbooks:$/ do |cookbooks|
|
38
|
+
list = chef_cookbooks
|
39
|
+
cookbooks.raw.each do |name, version|
|
40
|
+
unless version.nil?
|
41
|
+
expect(list.keys).to_not include(name)
|
42
|
+
else
|
43
|
+
expect(list[name] || []).to_not include(version)
|
44
|
+
end
|
45
|
+
end
|
47
46
|
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
Then(/^the version locks in the "(.*?)" environment should be:$/) do |name, locks|
|
49
|
+
list = chef_environment_locks(name)
|
50
|
+
locks.raw.each do |cookbook, version|
|
51
|
+
expect(list[cookbook]).to eq(version)
|
52
52
|
end
|
53
53
|
end
|
@@ -27,6 +27,9 @@ Then /^a Berkshelf config file should exist and contain:$/ do |table|
|
|
27
27
|
check_file_presence([Berkshelf.config.path], true)
|
28
28
|
|
29
29
|
table.raw.each do |key, value|
|
30
|
+
if value == "BOOLEAN[true]"
|
31
|
+
value = true
|
32
|
+
end
|
30
33
|
expect(Berkshelf.config[key]).to eq(value)
|
31
34
|
end
|
32
35
|
end
|
@@ -208,6 +208,16 @@ Then /^I should have a new cookbook skeleton "(.*?)" with no Vagrant support$/ d
|
|
208
208
|
}
|
209
209
|
end
|
210
210
|
|
211
|
+
Then(/^I should have a new cookbook skeleton "(.*?)" with no Test Kitchen support$/) do |name|
|
212
|
+
expect(Pathname.new(current_dir).join(name)).to have_structure {
|
213
|
+
file "Gemfile" do
|
214
|
+
does_not_contain "gem 'test-kitchen'"
|
215
|
+
end
|
216
|
+
no_file ".kitchen.yml"
|
217
|
+
no_file ".kitchen.yml.local"
|
218
|
+
}
|
219
|
+
end
|
220
|
+
|
211
221
|
Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
|
212
222
|
check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
|
213
223
|
end
|
@@ -14,13 +14,6 @@ class Hash
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
Then /^the file "(.*?)" should contain JSON:$/ do |file, data|
|
18
|
-
target = JSON.pretty_generate(JSON.parse(data).sort_by_key)
|
19
|
-
actual = JSON.pretty_generate(JSON.parse(File.read(File.join(current_dir, file))).sort_by_key)
|
20
|
-
|
21
|
-
expect(actual).to eq(target)
|
22
|
-
end
|
23
|
-
|
24
17
|
Then /^the output should contain JSON:$/ do |data|
|
25
18
|
target = JSON.pretty_generate(JSON.parse(data).sort_by_key)
|
26
19
|
actual = JSON.pretty_generate(JSON.parse(all_output).sort_by_key)
|
@@ -2,3 +2,56 @@ Then(/^the output should warn about the old lockfile format$/) do
|
|
2
2
|
message = Berkshelf::Lockfile.class_eval('LockfileLegacy.send(:warning_message)')
|
3
3
|
expect(all_output).to include(message)
|
4
4
|
end
|
5
|
+
|
6
|
+
Given /^the Lockfile has:$/ do |table|
|
7
|
+
result = { 'dependencies' => {} }
|
8
|
+
|
9
|
+
table.raw.each do |name, locked_or_path, ref, rel|
|
10
|
+
result['dependencies'][name] = {}
|
11
|
+
|
12
|
+
if locked_or_path =~ /(\d+\.){2}\d/
|
13
|
+
result['dependencies'][name]['locked_version'] = locked_or_path
|
14
|
+
else
|
15
|
+
result['dependencies'][name]['path'] = locked_or_path
|
16
|
+
end
|
17
|
+
|
18
|
+
unless ref.nil?
|
19
|
+
result['dependencies'][name]['rel'] = ref
|
20
|
+
end
|
21
|
+
|
22
|
+
unless rel.nil?
|
23
|
+
result['dependencies'][name]['rel'] = rel
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
File.open(File.join(current_dir, 'Berksfile.lock'), 'w') do |file|
|
28
|
+
file.write(JSON.pretty_generate(result) + "\n")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^the Lockfile should have:$/ do |table|
|
33
|
+
hash = JSON.parse(File.read(File.join(current_dir, 'Berksfile.lock')))
|
34
|
+
dependencies = hash['dependencies']
|
35
|
+
|
36
|
+
table.raw.each do |name, locked_or_path, ref, rel|
|
37
|
+
expect(dependencies).to have_key(name)
|
38
|
+
|
39
|
+
if locked_or_path =~ /(\d+\.){2}\d/
|
40
|
+
expect(dependencies[name]).to have_key('locked_version')
|
41
|
+
expect(dependencies[name]['locked_version']).to eq(locked_or_path)
|
42
|
+
else
|
43
|
+
expect(dependencies[name]).to have_key('path')
|
44
|
+
expect(dependencies[name]['path']).to eq(locked_or_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
unless ref.nil?
|
48
|
+
expect(dependencies[name]).to have_key('ref')
|
49
|
+
expect(dependencies[name]['ref']).to eq(ref)
|
50
|
+
end
|
51
|
+
|
52
|
+
unless rel.nil?
|
53
|
+
expect(dependencies[name]).to have_key('rel')
|
54
|
+
expect(dependencies[name]['rel']).to eq(rel)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -2,8 +2,8 @@ Given /^pending\s+"([^\"]+)"$/ do |msg|
|
|
2
2
|
pending
|
3
3
|
end
|
4
4
|
|
5
|
-
Then
|
6
|
-
run_simple(
|
7
|
-
|
8
|
-
expect(
|
5
|
+
Then /the output from \`(.+)\` should be the same as \`(.+)\`/ do |actual, expected|
|
6
|
+
run_simple(actual)
|
7
|
+
run_simple(expected)
|
8
|
+
expect(output_from(actual)).to eq(output_from(expected))
|
9
9
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,13 +1,69 @@
|
|
1
|
-
|
1
|
+
<%= name %> cookbook
|
2
|
+
<%= '='*"#{name} cookbook".length %>
|
3
|
+
TODO: Enter the cookbook description here.
|
2
4
|
|
3
|
-
|
5
|
+
e.g.
|
6
|
+
This cookbook makes your favorite breakfast sandwich.
|
4
7
|
|
5
|
-
|
8
|
+
Requirements
|
9
|
+
------------
|
10
|
+
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
|
6
11
|
|
7
|
-
|
12
|
+
e.g.
|
13
|
+
#### packages
|
14
|
+
- `toaster` - <%= name %> needs toaster to brown your bagel.
|
8
15
|
|
9
|
-
|
16
|
+
Attributes
|
17
|
+
----------
|
18
|
+
TODO: List you cookbook attributes here.
|
10
19
|
|
11
|
-
|
20
|
+
e.g.
|
21
|
+
#### <%= name %>::default
|
22
|
+
<table>
|
23
|
+
<tr>
|
24
|
+
<th>Key</th>
|
25
|
+
<th>Type</th>
|
26
|
+
<th>Description</th>
|
27
|
+
<th>Default</th>
|
28
|
+
</tr>
|
29
|
+
<tr>
|
30
|
+
<td><tt>['<%= name %>']['bacon']</tt></td>
|
31
|
+
<td>Boolean</td>
|
32
|
+
<td>whether to include bacon</td>
|
33
|
+
<td><tt>true</tt></td>
|
34
|
+
</tr>
|
35
|
+
</table>
|
12
36
|
|
37
|
+
Usage
|
38
|
+
-----
|
39
|
+
#### <%= name %>::default
|
40
|
+
TODO: Write usage instructions for each cookbook.
|
41
|
+
|
42
|
+
e.g.
|
43
|
+
Just include `<%= name %>` in your node's `run_list`:
|
44
|
+
|
45
|
+
```json
|
46
|
+
{
|
47
|
+
"name":"my_node",
|
48
|
+
"run_list": [
|
49
|
+
"recipe[<%= name %>]"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
54
|
+
Contributing
|
55
|
+
------------
|
56
|
+
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
|
57
|
+
|
58
|
+
e.g.
|
59
|
+
|
60
|
+
1. Fork the repository on Github
|
61
|
+
2. Create a named feature branch (like `add_component_x`)
|
62
|
+
3. Write you change
|
63
|
+
4. Write tests for your change (if applicable)
|
64
|
+
5. Run the tests, ensuring they all pass
|
65
|
+
6. Submit a Pull Request using Github
|
66
|
+
|
67
|
+
License and Authors
|
68
|
+
-------------------
|
13
69
|
Author:: <%= maintainer %> (<<%= maintainer_email %>>)
|
@@ -8,6 +8,17 @@ Vagrant.configure("2") do |config|
|
|
8
8
|
|
9
9
|
config.vm.hostname = "<%= "#{cookbook_name.gsub('_','-')}-berkshelf" %>"
|
10
10
|
|
11
|
+
# Set the version of chef to install using the vagrant-omnibus plugin
|
12
|
+
<% if berkshelf_config.vagrant.omnibus.enabled -%>
|
13
|
+
<% if berkshelf_config.vagrant.omnibus.version == "latest" -%>
|
14
|
+
config.omnibus.chef_version = :latest
|
15
|
+
<% else %>
|
16
|
+
config.omnibus.chef_version = "<%= berkshelf_config.vagrant.omnibus.version %>"
|
17
|
+
<% end -%>
|
18
|
+
<% else %>
|
19
|
+
#config.omnibus.chef_version = :latest
|
20
|
+
<% end -%>
|
21
|
+
|
11
22
|
# Every Vagrant virtual environment requires a box to build off of.
|
12
23
|
config.vm.box = "<%= berkshelf_config.vagrant.vm.box %>"
|
13
24
|
|
@@ -96,10 +107,10 @@ Vagrant.configure("2") do |config|
|
|
96
107
|
<% elsif berkshelf_config.vagrant.vm.provision == "chef_solo" -%>
|
97
108
|
config.vm.provision :chef_solo do |chef|
|
98
109
|
chef.json = {
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
110
|
+
mysql: {
|
111
|
+
server_root_password: 'rootpass',
|
112
|
+
server_debian_password: 'debpass',
|
113
|
+
server_repl_password: 'replpass'
|
103
114
|
}
|
104
115
|
}
|
105
116
|
|
data/lib/berkshelf.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'buff/extensions'
|
2
2
|
require 'archive/tar/minitar'
|
3
|
-
require 'celluloid'
|
4
3
|
require 'digest/md5'
|
5
4
|
require 'forwardable'
|
6
5
|
require 'hashie'
|
@@ -42,7 +41,7 @@ module Berkshelf
|
|
42
41
|
@ui ||= Thor::Base.shell.new
|
43
42
|
end
|
44
43
|
|
45
|
-
# Returns the filepath to the location
|
44
|
+
# Returns the filepath to the location Berkshelf will use for
|
46
45
|
# storage; temp files will go here, Cookbooks will be downloaded
|
47
46
|
# to or uploaded from here. By default this is '~/.berkshelf' but
|
48
47
|
# can be overridden by specifying a value for the ENV variable
|
@@ -143,7 +142,6 @@ require_relative 'berkshelf/api_client'
|
|
143
142
|
require_relative 'berkshelf/base_generator'
|
144
143
|
require_relative 'berkshelf/berksfile'
|
145
144
|
require_relative 'berkshelf/cached_cookbook'
|
146
|
-
require_relative 'berkshelf/chef'
|
147
145
|
require_relative 'berkshelf/cli'
|
148
146
|
require_relative 'berkshelf/community_rest'
|
149
147
|
require_relative 'berkshelf/cookbook_generator'
|
@@ -165,5 +163,5 @@ require_relative 'berkshelf/source_uri'
|
|
165
163
|
require_relative 'berkshelf/ui'
|
166
164
|
require_relative 'berkshelf/version'
|
167
165
|
|
168
|
-
Ridley.logger =
|
166
|
+
Ridley.logger = Berkshelf.logger = Logger.new(STDOUT)
|
169
167
|
Berkshelf.logger.level = Logger::WARN
|
data/lib/berkshelf/api_client.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'addressable/uri'
|
2
|
-
|
3
1
|
module Berkshelf
|
4
2
|
# Used to communicate with a remotely hosted [Berkshelf API Server](https://github.com/riotgames/berkshelf-api).
|
5
3
|
#
|
6
4
|
# @example
|
7
|
-
# client = Berkshelf::APIClient.new("
|
5
|
+
# client = Berkshelf::APIClient.new("https://api.berkshelf.com")
|
8
6
|
# client.universe #=> [...]
|
9
7
|
class APIClient < Faraday::Connection
|
10
8
|
require_relative 'api_client/remote_cookbook'
|
11
9
|
|
12
|
-
# @return [
|
10
|
+
# @return [String]
|
13
11
|
attr_reader :url
|
14
12
|
|
15
13
|
# @return [Integer]
|
@@ -28,11 +26,11 @@ module Berkshelf
|
|
28
26
|
# how long to wait (in seconds) between each retry
|
29
27
|
def initialize(url, options = {})
|
30
28
|
options = options.reverse_merge(retries: 5, retry_interval: 0.5)
|
31
|
-
@url =
|
29
|
+
@url = url
|
32
30
|
@retries = options[:retries]
|
33
31
|
@retry_interval = options[:retry_interval]
|
34
32
|
|
35
|
-
builder
|
33
|
+
options[:builder] ||= Faraday::Builder.new do |b|
|
36
34
|
b.response :parse_json
|
37
35
|
b.response :gzip
|
38
36
|
b.request :retry,
|
@@ -43,7 +41,7 @@ module Berkshelf
|
|
43
41
|
b.adapter :net_http
|
44
42
|
end
|
45
43
|
|
46
|
-
super(self.url,
|
44
|
+
super(self.url, options)
|
47
45
|
end
|
48
46
|
|
49
47
|
# Retrieves the entire universe of known cookbooks from the API source
|