berkshelf 5.2.0 → 8.0.15

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.
Files changed (216) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +19 -47
  3. data/Rakefile +14 -4
  4. data/berkshelf.gemspec +61 -40
  5. data/bin/berks +2 -2
  6. data/lib/berkshelf/api-client.rb +1 -0
  7. data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
  8. data/lib/berkshelf/api_client/connection.rb +57 -0
  9. data/lib/berkshelf/api_client/errors.rb +10 -0
  10. data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
  11. data/lib/berkshelf/api_client/version.rb +5 -0
  12. data/lib/berkshelf/api_client.rb +24 -0
  13. data/lib/berkshelf/berksfile.rb +149 -122
  14. data/lib/berkshelf/cached_cookbook.rb +127 -24
  15. data/lib/berkshelf/chef_config_compat.rb +51 -0
  16. data/lib/berkshelf/chef_repo_universe.rb +47 -0
  17. data/lib/berkshelf/cli.rb +143 -174
  18. data/lib/berkshelf/commands/shelf.rb +20 -19
  19. data/lib/berkshelf/community_rest.rb +59 -94
  20. data/lib/berkshelf/config.rb +97 -127
  21. data/lib/berkshelf/cookbook_store.rb +7 -6
  22. data/lib/berkshelf/core_ext/file.rb +1 -1
  23. data/lib/berkshelf/core_ext/file_utils.rb +4 -4
  24. data/lib/berkshelf/core_ext.rb +1 -1
  25. data/lib/berkshelf/dependency.rb +25 -32
  26. data/lib/berkshelf/downloader.rb +66 -39
  27. data/lib/berkshelf/errors.rb +23 -17
  28. data/lib/berkshelf/file_syncer.rb +24 -47
  29. data/lib/berkshelf/formatters/human.rb +7 -5
  30. data/lib/berkshelf/formatters/json.rb +6 -6
  31. data/lib/berkshelf/installer.rb +120 -111
  32. data/lib/berkshelf/location.rb +14 -14
  33. data/lib/berkshelf/locations/base.rb +1 -1
  34. data/lib/berkshelf/locations/git.rb +16 -24
  35. data/lib/berkshelf/locations/github.rb +2 -2
  36. data/lib/berkshelf/locations/path.rb +2 -2
  37. data/lib/berkshelf/lockfile.rb +326 -328
  38. data/lib/berkshelf/logger.rb +64 -1
  39. data/lib/berkshelf/mixin/git.rb +6 -5
  40. data/lib/berkshelf/packager.rb +44 -10
  41. data/lib/berkshelf/resolver/graph.rb +1 -1
  42. data/lib/berkshelf/resolver.rb +4 -4
  43. data/lib/berkshelf/ridley_compat.rb +109 -0
  44. data/lib/berkshelf/shell.rb +2 -1
  45. data/lib/berkshelf/shell_out.rb +18 -0
  46. data/lib/berkshelf/source.rb +77 -33
  47. data/lib/berkshelf/source_uri.rb +4 -4
  48. data/lib/berkshelf/ssl_policies.rb +38 -0
  49. data/lib/berkshelf/thor.rb +1 -1
  50. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  51. data/lib/berkshelf/thor_ext.rb +1 -1
  52. data/lib/berkshelf/uploader.rb +106 -70
  53. data/lib/berkshelf/validator.rb +13 -5
  54. data/lib/berkshelf/version.rb +1 -1
  55. data/lib/berkshelf/visualizer.rb +16 -11
  56. data/lib/berkshelf.rb +106 -81
  57. data/spec/config/knife.rb +4 -4
  58. data/spec/data/trusted_certs/example.crt +22 -0
  59. data/spec/fixtures/Berksfile +3 -3
  60. data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
  61. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
  62. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
  63. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  64. data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
  65. data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
  66. data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
  67. data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
  68. data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
  69. data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
  70. data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
  71. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  72. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  73. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  74. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  75. data/spec/spec_helper.rb +56 -64
  76. data/spec/support/chef_api.rb +15 -16
  77. data/spec/support/chef_server.rb +71 -69
  78. data/spec/support/git.rb +59 -58
  79. data/spec/support/kitchen.rb +0 -14
  80. data/spec/support/matchers/file_system_matchers.rb +4 -5
  81. data/spec/support/matchers/filepath_matchers.rb +2 -2
  82. data/spec/support/path_helpers.rb +17 -17
  83. data/spec/support/shared_examples/formatter.rb +1 -1
  84. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
  85. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
  86. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
  87. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
  88. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
  89. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
  90. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
  91. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
  92. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
  93. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
  94. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  95. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  96. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
  97. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  98. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
  99. data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
  100. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  101. data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
  102. data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  103. data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
  104. data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
  105. data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
  106. data/spec/unit/berkshelf/cli_spec.rb +7 -8
  107. data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
  108. data/spec/unit/berkshelf/config_spec.rb +51 -22
  109. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  110. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
  111. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  112. data/spec/unit/berkshelf/dependency_spec.rb +48 -48
  113. data/spec/unit/berkshelf/downloader_spec.rb +191 -34
  114. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  115. data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
  116. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  117. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  118. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  119. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  120. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  121. data/spec/unit/berkshelf/location_spec.rb +11 -11
  122. data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
  123. data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
  124. data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
  125. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  126. data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
  127. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  128. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  129. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  130. data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
  131. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  132. data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
  133. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  134. data/spec/unit/berkshelf/source_spec.rb +186 -20
  135. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  136. data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
  137. data/spec/unit/berkshelf/uploader_spec.rb +146 -64
  138. data/spec/unit/berkshelf/validator_spec.rb +23 -16
  139. data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
  140. data/spec/unit/berkshelf_spec.rb +18 -18
  141. metadata +138 -289
  142. data/.gitignore +0 -29
  143. data/.travis.yml +0 -64
  144. data/CHANGELOG.legacy.md +0 -307
  145. data/CHANGELOG.md +0 -1358
  146. data/CONTRIBUTING.md +0 -64
  147. data/Gemfile.lock +0 -399
  148. data/Guardfile +0 -23
  149. data/PLUGINS.md +0 -25
  150. data/README.md +0 -70
  151. data/Thorfile +0 -61
  152. data/appveyor.yml +0 -31
  153. data/docs/berkshelf_for_newcomers.md +0 -65
  154. data/features/berksfile.feature +0 -46
  155. data/features/commands/apply.feature +0 -41
  156. data/features/commands/contingent.feature +0 -48
  157. data/features/commands/cookbook.feature +0 -35
  158. data/features/commands/info.feature +0 -99
  159. data/features/commands/init.feature +0 -27
  160. data/features/commands/install.feature +0 -636
  161. data/features/commands/list.feature +0 -78
  162. data/features/commands/outdated.feature +0 -130
  163. data/features/commands/package.feature +0 -17
  164. data/features/commands/search.feature +0 -17
  165. data/features/commands/shelf/list.feature +0 -32
  166. data/features/commands/shelf/show.feature +0 -143
  167. data/features/commands/shelf/uninstall.feature +0 -96
  168. data/features/commands/show.feature +0 -83
  169. data/features/commands/update.feature +0 -142
  170. data/features/commands/upload.feature +0 -426
  171. data/features/commands/vendor.feature +0 -111
  172. data/features/commands/verify.feature +0 -29
  173. data/features/commands/viz.feature +0 -66
  174. data/features/community_site.feature +0 -37
  175. data/features/config.feature +0 -111
  176. data/features/help.feature +0 -11
  177. data/features/json_formatter.feature +0 -161
  178. data/features/lifecycle.feature +0 -378
  179. data/features/lockfile.feature +0 -378
  180. data/features/step_definitions/berksfile_steps.rb +0 -39
  181. data/features/step_definitions/chef/config_steps.rb +0 -12
  182. data/features/step_definitions/chef_server_steps.rb +0 -60
  183. data/features/step_definitions/cli_steps.rb +0 -18
  184. data/features/step_definitions/config_steps.rb +0 -46
  185. data/features/step_definitions/environment_steps.rb +0 -7
  186. data/features/step_definitions/filesystem_steps.rb +0 -269
  187. data/features/step_definitions/gem_steps.rb +0 -13
  188. data/features/step_definitions/json_steps.rb +0 -23
  189. data/features/step_definitions/utility_steps.rb +0 -11
  190. data/features/support/aruba.rb +0 -12
  191. data/features/support/env.rb +0 -82
  192. data/generator_files/Berksfile.erb +0 -11
  193. data/generator_files/CHANGELOG.md.erb +0 -3
  194. data/generator_files/Gemfile.erb +0 -8
  195. data/generator_files/README.md.erb +0 -42
  196. data/generator_files/Thorfile.erb +0 -11
  197. data/generator_files/Vagrantfile.erb +0 -117
  198. data/generator_files/chefignore +0 -94
  199. data/generator_files/default_recipe.erb +0 -6
  200. data/generator_files/default_test.rb.erb +0 -11
  201. data/generator_files/gitignore.erb +0 -23
  202. data/generator_files/helpers.rb.erb +0 -7
  203. data/generator_files/licenses/apachev2.erb +0 -13
  204. data/generator_files/licenses/gplv2.erb +0 -15
  205. data/generator_files/licenses/gplv3.erb +0 -14
  206. data/generator_files/licenses/mit.erb +0 -20
  207. data/generator_files/licenses/reserved.erb +0 -3
  208. data/generator_files/metadata.rb.erb +0 -11
  209. data/lib/berkshelf/base_generator.rb +0 -43
  210. data/lib/berkshelf/commands/test_command.rb +0 -13
  211. data/lib/berkshelf/cookbook_generator.rb +0 -133
  212. data/lib/berkshelf/init_generator.rb +0 -195
  213. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
  214. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
  215. data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
  216. data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5089b7006471b9e1a535ab4fc5f3ee1b83ae6114
4
- data.tar.gz: 15c5ac0f94f60ea0d741975e13ed4af81fa5ef70
2
+ SHA256:
3
+ metadata.gz: 547ce4d95888e7fd0fcfb2b50c449cc78c67ffb4885b44d953e69383d5d5ed26
4
+ data.tar.gz: 472be5adafecb5a2741701dc0c083017126c2cd9fb91bc5692a4d3f80beb2db6
5
5
  SHA512:
6
- metadata.gz: a6a0945ca8000eb04ae6d381c04235ad9c9657635ba6eda6453134207421a8054df09407972988750ff89b5d93d183e2f2a966933eabc977471672ffd07ab530
7
- data.tar.gz: ae1cfadeee18dda60605775d86d31720524636eb4e600a13d1802a75e4fa955621ba37463af8dc5b41c9537b5028d2274eda88e3a4c398dfae75a59c71dfafe3
6
+ metadata.gz: b28e165ac351b1902ba1bc65f7715d5a1a709881f46c039f4186b7dd6e924a9412789332cae9c37db8e75caff2a503d4fa91637d872fc7f12b51fa6cc04dcea0
7
+ data.tar.gz: 78c7e37a5ebee0dbb8faa346cd5807f888fd16b8591688ee3248d04be4372035561ba65765700d6c39ab56d2d09f22acdc4d1aad24f416537babc5f042ae3caa
data/Gemfile CHANGED
@@ -1,56 +1,28 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :guard do
6
- gem 'coolline'
7
- gem 'guard'
8
- gem 'guard-cucumber'
9
- gem 'guard-rspec'
10
- gem 'guard-spork'
11
-
12
- require 'rbconfig'
13
-
14
- if RbConfig::CONFIG['target_os'] =~ /darwin/i
15
- gem 'growl', require: false
16
- gem 'rb-fsevent', require: false
17
-
18
- if `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8'
19
- gem 'terminal-notifier-guard', '~> 1.5.3', require: false
20
- end rescue Errno::ENOENT
21
-
22
- elsif RbConfig::CONFIG['target_os'] =~ /linux/i
23
- gem 'libnotify', '~> 0.8.0', require: false
24
- gem 'rb-inotify', require: false
25
-
26
- elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
27
- gem 'rb-notifu', '>= 0.0.4', require: false
28
- gem 'wdm', require: false
29
- gem 'win32console', require: false
30
- end
5
+ group :build do
6
+ gem "rake", ">= 10.1"
31
7
  end
32
8
 
33
9
  group :development do
34
- # these all deliberately float because berkshelf has a Gemfile.lock that
35
- # equality pins them. temporarily pin as necessary for API breaks.
36
- gem 'aruba', '>= 0.10.0'
37
- gem 'chef-zero', '>= 4.0'
38
- gem 'dep_selector', '>= 1.0'
39
- gem 'fuubar', '>= 2.0'
40
- gem 'rake', '>= 10.1'
41
- gem 'rspec', '>= 3.0'
42
- gem 'spork', '>= 0.9'
43
- gem 'test-kitchen', '>= 1.2'
44
- gem 'webmock', '>= 1.11'
45
- gem 'yard', '>= 0.8'
46
- gem 'http', '>= 0.9.8'
47
- gem 'activesupport', '~> 4.0' # pinning for ruby 2.1.x
10
+ gem "aruba", "~> 0.10" # Stay below 1 until aruba/in_process monkeypatching stops
11
+ gem "debug"
12
+ gem "cucumber", "< 4.0" # until we identify what is generating the ~@no_run tag in CI
13
+ gem "cucumber-expressions", "= 5.0.13"
14
+ gem "chef-zero", ">= 4.0"
15
+ gem "dep_selector", ">= 1.0"
16
+ gem "fuubar", ">= 2.0"
17
+ gem "rspec", ">= 3.0"
18
+ gem "rspec-its", ">= 1.2"
19
+ gem "webmock", ">= 1.11"
20
+ gem "http", ">= 0.9.8"
21
+ gem "chefstyle"
48
22
  end
49
23
 
50
- group :changelog do
51
- gem 'github_changelog_generator', "1.11.3"
52
- end
24
+ instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
53
25
 
54
- group :test do
55
- gem "berkshelf-api", git: "https://github.com/berkshelf/berkshelf-api.git", ref: "9fb3d95779c4ff72b0074072105caaf70b978bf0"
56
- end
26
+ # If you want to load debugging tools into the bundle exec sandbox,
27
+ # add these additional dependencies into Gemfile.local
28
+ eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
data/Rakefile CHANGED
@@ -8,14 +8,14 @@ rescue LoadError
8
8
  task :spec
9
9
  end
10
10
 
11
- WINDOWS_PLATFORM = /mswin|win32|mingw/ unless defined? WINDOWS_PLATFORM
11
+ WINDOWS_PLATFORM = /mswin|win32|mingw/.freeze unless defined? WINDOWS_PLATFORM
12
12
 
13
13
  begin
14
14
  require "cucumber"
15
15
  require "cucumber/rake/task"
16
16
  Cucumber::Rake::Task.new(:features) do |t|
17
- if RUBY_PLATFORM =~ WINDOWS_PLATFORM
18
- t.cucumber_opts = "--tags ~@not-windows"
17
+ if RUBY_PLATFORM =~ WINDOWS_PLATFORM || RUBY_PLATFORM =~ /darwin/
18
+ t.cucumber_opts = "--tags 'not @not-windows'"
19
19
  end
20
20
  end
21
21
  rescue LoadError
@@ -35,9 +35,19 @@ begin
35
35
  rescue LoadError
36
36
  end
37
37
 
38
- task default: [:spec, :features]
38
+ task default: %i{spec features}
39
39
  task :ci do
40
40
  ENV["CI"] = "true"
41
41
  Rake::Task[:spec].invoke
42
42
  Rake::Task[:features].invoke
43
43
  end
44
+
45
+ begin
46
+ require "chefstyle"
47
+ require "rubocop/rake_task"
48
+ RuboCop::RakeTask.new(:style) do |task|
49
+ task.options += ["--display-cop-names", "--no-color"]
50
+ end
51
+ rescue LoadError
52
+ puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking."
53
+ end
data/berkshelf.gemspec CHANGED
@@ -1,48 +1,69 @@
1
- # -*- encoding: utf-8; mode: ruby -*-
2
- require File.expand_path('../lib/berkshelf/version', __FILE__)
1
+ require File.expand_path("lib/berkshelf/version", __dir__)
3
2
 
4
3
  Gem::Specification.new do |s|
5
- s.authors = [
6
- 'Jamie Winsor',
7
- 'Josiah Kiehl',
8
- 'Michael Ivey',
9
- 'Justin Campbell',
10
- 'Seth Vargo'
4
+ s.authors = [
5
+ "Jamie Winsor",
6
+ "Josiah Kiehl",
7
+ "Michael Ivey",
8
+ "Justin Campbell",
9
+ "Seth Vargo",
11
10
  ]
12
- s.email = [
13
- 'jamie@vialstudios.com',
14
- 'jkiehl@riotgames.com',
15
- 'michael.ivey@riotgames.com',
16
- 'justin@justincampbell.me',
17
- 'sethvargo@gmail.com'
11
+ s.email = [
12
+ "jamie@vialstudios.com",
13
+ "jkiehl@riotgames.com",
14
+ "michael.ivey@riotgames.com",
15
+ "justin@justincampbell.me",
16
+ "sethvargo@gmail.com",
18
17
  ]
19
18
 
20
- s.description = %q{Manages a Cookbook's, or an Application's, Cookbook dependencies}
19
+ s.description = %q{Manages a Chef cookbook's dependencies}
21
20
  s.summary = s.description
22
- s.homepage = 'http://berkshelf.com'
23
- s.license = 'Apache 2.0'
24
- s.files = `git ls-files`.split($\)
25
- s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
26
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
27
- s.name = 'berkshelf'
28
- s.require_paths = ['lib']
21
+ s.homepage = "https://docs.chef.io/berkshelf.html"
22
+ s.license = "Apache-2.0"
23
+ s.files = %w{LICENSE Gemfile Rakefile} + Dir.glob("*.gemspec") + Dir.glob("{lib,spec, features}/**/*")
24
+ s.executables = Dir.glob("bin/**/*").map { |f| File.basename(f) }
25
+ s.name = "berkshelf"
26
+ s.require_paths = ["lib"]
29
27
  s.version = Berkshelf::VERSION
30
- s.required_ruby_version = '>= 2.2.0'
31
- s.required_rubygems_version = '>= 2.0.0'
32
-
33
- s.add_dependency 'addressable', '~> 2.3', '>= 2.3.4'
34
- s.add_dependency 'berkshelf-api-client', '>= 2.0.2', '< 4.0'
35
- s.add_dependency 'buff-config', '~> 2.0'
36
- s.add_dependency 'buff-extensions', '~> 2.0'
37
- s.add_dependency 'buff-shell_out', '~> 1.0'
38
- s.add_dependency 'cleanroom', '~> 1.0'
39
- s.add_dependency 'faraday', '~> 0.9'
40
- s.add_dependency 'httpclient', '~> 2.7'
41
- s.add_dependency 'minitar', '~> 0.5', '>= 0.5.4'
42
- s.add_dependency 'retryable', '~> 2.0'
43
- s.add_dependency 'ridley', '~> 5.0'
44
- s.add_dependency 'solve', '> 2.0', '< 4.0'
45
- s.add_dependency 'thor', '~> 0.19'
46
- s.add_dependency 'octokit', '~> 4.0'
47
- s.add_dependency 'mixlib-archive', '~> 0.1'
28
+ s.required_ruby_version = ">= 2.7.0"
29
+ s.required_rubygems_version = ">= 2.0.0"
30
+ s.metadata = {
31
+ "bug_tracker_uri" => "https://github.com/chef/berkshelf/issues",
32
+ "source_code_uri" => "https://github.com/chef/berkshelf",
33
+ "changelog_uri" => "https://github.com/chef/berkshelf/blob/main/CHANGELOG.md",
34
+ }
35
+
36
+ ruby_version = Gem::Version.new(RUBY_VERSION)
37
+
38
+ s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
39
+
40
+ s.add_dependency "chef-cleanroom", "~> 1.0"
41
+
42
+ if ruby_version >= Gem::Version.new("3.1.0")
43
+ s.add_dependency "minitar", "~> 1.0"
44
+ s.add_dependency "chef", ">= 18.0.0"
45
+ else
46
+ s.add_dependency "minitar", "~> 0.12"
47
+
48
+ if ruby_version >= Gem::Version.new("3.0.0")
49
+ s.add_dependency "chef", "~> 17.0" # needed for --skip-syntax-check
50
+ else
51
+ s.add_dependency "chef", ">= 15.7.32"
52
+ end
53
+ end
54
+
55
+ s.add_dependency "retryable", ">= 2.0", "< 4.0"
56
+ s.add_dependency "solve", "~> 4.0"
57
+
58
+ s.add_dependency "thor", ">= 0.20", "< 1.3.0"
59
+ s.add_dependency "octokit", ">= 4.0", "< 6.0"
60
+
61
+ s.add_dependency "mixlib-archive", ">= 1.1.4", "< 2.0" # needed for ruby 3.0 / Dir.chdir removal
62
+ s.add_dependency "concurrent-ruby", "~> 1.0"
63
+
64
+ s.add_dependency "ffi", "~> 1.9", "< 1.16.0" #
65
+
66
+ s.add_dependency "chef-config"
67
+ # this is required for Mixlib::Config#from_json
68
+ s.add_dependency "mixlib-config", ">= 2.2.5"
48
69
  end
data/bin/berks CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $:.push File.expand_path('../../lib', __FILE__)
3
- require 'berkshelf/cli'
2
+ $:.push File.expand_path("../lib", __dir__)
3
+ require "berkshelf/cli"
4
4
 
5
5
  Berkshelf::Cli::Runner.new(ARGV.dup).execute!
@@ -0,0 +1 @@
1
+ require_relative "api_client"
@@ -0,0 +1,29 @@
1
+ require_relative "../ridley_compat"
2
+
3
+ module Berkshelf
4
+ module APIClient
5
+ require_relative "errors"
6
+
7
+ class ChefServerConnection
8
+ def initialize(**args)
9
+ @client = Berkshelf::RidleyCompat.new(**args)
10
+ @url = args[:server_url]
11
+ end
12
+
13
+ def universe
14
+ response = @client.get("universe")
15
+
16
+ [].tap do |cookbooks|
17
+ response.each do |name, versions|
18
+ versions.each do |version, attributes|
19
+ attributes[:location_path] = @url
20
+ cookbooks << RemoteCookbook.new(name, version, attributes)
21
+ end
22
+ end
23
+ end
24
+ rescue Ridley::Errors::HTTPNotFound
25
+ raise ServiceNotFound, "service not found at: #{@url}"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ require_relative "../ridley_compat"
2
+
3
+ module Berkshelf
4
+ module APIClient
5
+ require_relative "errors"
6
+
7
+ class Connection
8
+ # @return [String]
9
+ attr_reader :url
10
+
11
+ # @return [Integer]
12
+ # how many retries to attempt on HTTP requests
13
+ attr_reader :retries
14
+
15
+ # @return [Float]
16
+ # time to wait between retries
17
+ attr_reader :retry_interval
18
+
19
+ # @param [String, Addressable::URI] url
20
+ #
21
+ # @option options [Integer] :open_timeout (3)
22
+ # how long to wait (in seconds) for connection open to the API server
23
+ # @option options [Integer] :timeout (30)
24
+ # how long to wait (in seconds) before getting a response from the API server
25
+ # @option options [Integer] :retries (3)
26
+ # how many retries to perform before giving up
27
+ # @option options [Float] :retry_interval (0.5)
28
+ # how long to wait (in seconds) between each retry
29
+ def initialize(url, options = {})
30
+ # it looks like Faraday mutates the URI argument it is given, when we ripped Faraday out of this
31
+ # API it stopped doing that. this may or may not be a breaking change (it broke some fairly
32
+ # brittle berkshelf tests). if it causes too much berkshelf chaos we could revert by uncommenting
33
+ # the next line. as it is removing this behavior feels more like fixing a bug.
34
+ # @url = url.normalize! if url.is_a?(Addressable::URI)
35
+ options = { retries: 3, retry_interval: 0.5, open_timeout: 30, timeout: 30 }.merge(options)
36
+ options[:server_url] = url
37
+
38
+ @client = Berkshelf::RidleyCompatJSON.new(**options)
39
+ end
40
+
41
+ # Retrieves the entire universe of known cookbooks from the API source
42
+ #
43
+ # @raise [APIClient::TimeoutError]
44
+ #
45
+ # @return [Array<APIClient::RemoteCookbook>]
46
+ def universe
47
+ response = @client.get("universe")
48
+
49
+ [].tap do |cookbooks|
50
+ response.each do |name, versions|
51
+ versions.each { |version, attributes| cookbooks << RemoteCookbook.new(name, version, attributes) }
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,10 @@
1
+ module Berkshelf
2
+ class APIClientError < StandardError; end
3
+
4
+ module APIClient
5
+ class TimeoutError < APIClientError; end
6
+ class BadResponse < APIClientError; end
7
+ class ServiceUnavailable < APIClientError; end
8
+ class ServiceNotFound < APIClientError; end
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ require "json" unless defined?(JSON)
2
+ require "chef/mash"
3
+
4
+ module Berkshelf
5
+ module APIClient
6
+ # A representation of cookbook metadata indexed by a Berkshelf API Server. Returned
7
+ # by sending messages to a {Berkshelf::APIClient} and used to download cookbooks
8
+ # indexed by the Berkshelf API Server.
9
+ class RemoteCookbook
10
+ # @return [String]
11
+ attr_reader :name
12
+ # @return [String]
13
+ attr_reader :version
14
+
15
+ # @param [String] name
16
+ # @param [String] version
17
+ # @param [Hash] attributes
18
+ def initialize(name, version, attributes = {})
19
+ @name = name
20
+ @version = version
21
+ @attributes = ::Mash.new(attributes)
22
+ end
23
+
24
+ # @return [Hash]
25
+ def dependencies
26
+ @attributes[:dependencies]
27
+ end
28
+
29
+ # @return [Hash]
30
+ def platforms
31
+ @attributes[:platforms]
32
+ end
33
+
34
+ # @return [Symbol]
35
+ def location_type
36
+ @attributes[:location_type].to_sym
37
+ end
38
+
39
+ # @return [String]
40
+ def location_path
41
+ @attributes[:location_path]
42
+ end
43
+
44
+ def to_hash
45
+ {
46
+ name: name,
47
+ version: version,
48
+ }
49
+ end
50
+
51
+ def to_json(options = {})
52
+ ::JSON.pretty_generate(to_hash, options)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ module Berkshelf
2
+ module APIClient
3
+ VERSION = "4.0.1".freeze
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ module Berkshelf
2
+ # Used to communicate with a remotely hosted [Berkshelf API Server](https://github.com/berkshelf/berkshelf-api).
3
+ #
4
+ # @example
5
+ # client = Berkshelf::APIClient.new("https://api.berkshelf.com")
6
+ # client.universe #=> [...]
7
+ module APIClient
8
+ require_relative "api_client/version"
9
+ require_relative "api_client/errors"
10
+ require_relative "api_client/remote_cookbook"
11
+ require_relative "api_client/connection"
12
+ require_relative "api_client/chef_server_connection"
13
+
14
+ class << self
15
+ def new(*args)
16
+ Connection.new(*args)
17
+ end
18
+
19
+ def chef_server(**args)
20
+ ChefServerConnection.new(**args)
21
+ end
22
+ end
23
+ end
24
+ end