berkshelf 2.0.18 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/.ruby-version +1 -1
  2. data/.travis.yml +4 -1
  3. data/CHANGELOG.md +2 -26
  4. data/Gemfile +12 -2
  5. data/README.md +9 -1
  6. data/berkshelf.gemspec +9 -18
  7. data/bin/berks +3 -13
  8. data/features/apply_command.feature +11 -9
  9. data/features/berksfile.feature +8 -10
  10. data/features/config.feature +1 -2
  11. data/features/configure_command.feature +13 -14
  12. data/features/contingent_command.feature +13 -1
  13. data/features/cookbook_command.feature +2 -4
  14. data/features/groups_install.feature +10 -2
  15. data/features/help.feature +1 -1
  16. data/features/init_command.feature +5 -7
  17. data/features/install_command.feature +157 -228
  18. data/features/json_formatter.feature +27 -15
  19. data/features/licenses.feature +18 -12
  20. data/features/list_command.feature +6 -1
  21. data/features/lockfile.feature +116 -72
  22. data/features/outdated_command.feature +3 -47
  23. data/features/package_command.feature +10 -7
  24. data/features/shelf/show.feature +2 -2
  25. data/features/shelf/uninstall.feature +2 -2
  26. data/features/show_command.feature +10 -3
  27. data/features/step_definitions/chef/config_steps.rb +12 -0
  28. data/features/step_definitions/chef_server_steps.rb +16 -16
  29. data/features/step_definitions/cli_steps.rb +3 -79
  30. data/features/step_definitions/config_steps.rb +43 -0
  31. data/features/step_definitions/environment_steps.rb +7 -0
  32. data/features/step_definitions/filesystem_steps.rb +12 -57
  33. data/features/step_definitions/gem_steps.rb +1 -2
  34. data/features/step_definitions/json_steps.rb +3 -1
  35. data/features/step_definitions/lockfile_steps.rb +4 -0
  36. data/features/step_definitions/utility_steps.rb +0 -19
  37. data/features/support/aruba.rb +12 -0
  38. data/features/support/env.rb +52 -57
  39. data/features/update_command.feature +37 -23
  40. data/features/upload_command.feature +96 -160
  41. data/generator_files/Berksfile.erb +2 -1
  42. data/generator_files/Vagrantfile.erb +3 -0
  43. data/generator_files/default_test.rb.erb +1 -1
  44. data/generator_files/helpers.rb.erb +1 -1
  45. data/lib/berkshelf.rb +43 -24
  46. data/lib/berkshelf/api_client.rb +67 -0
  47. data/lib/berkshelf/api_client/remote_cookbook.rb +42 -0
  48. data/lib/berkshelf/berksfile.rb +232 -420
  49. data/lib/berkshelf/cached_cookbook.rb +22 -10
  50. data/lib/berkshelf/chef/config.rb +1 -0
  51. data/lib/berkshelf/cli.rb +66 -68
  52. data/lib/berkshelf/commands/shelf.rb +1 -1
  53. data/lib/berkshelf/community_rest.rb +10 -17
  54. data/lib/berkshelf/config.rb +23 -27
  55. data/lib/berkshelf/cookbook_generator.rb +3 -4
  56. data/lib/berkshelf/cookbook_store.rb +74 -17
  57. data/lib/berkshelf/core_ext/file.rb +2 -2
  58. data/lib/berkshelf/core_ext/pathname.rb +7 -5
  59. data/lib/berkshelf/{cookbook_source.rb → dependency.rb} +47 -67
  60. data/lib/berkshelf/downloader.rb +49 -106
  61. data/lib/berkshelf/errors.rb +64 -71
  62. data/lib/berkshelf/formatters.rb +11 -9
  63. data/lib/berkshelf/formatters/human_readable.rb +9 -9
  64. data/lib/berkshelf/formatters/json.rb +14 -4
  65. data/lib/berkshelf/init_generator.rb +3 -3
  66. data/lib/berkshelf/installer.rb +136 -0
  67. data/lib/berkshelf/location.rb +91 -131
  68. data/lib/berkshelf/locations/git_location.rb +9 -11
  69. data/lib/berkshelf/locations/github_location.rb +1 -1
  70. data/lib/berkshelf/locations/path_location.rb +10 -27
  71. data/lib/berkshelf/lockfile.rb +92 -70
  72. data/lib/berkshelf/logger.rb +4 -7
  73. data/lib/berkshelf/mixin/config.rb +21 -4
  74. data/lib/berkshelf/resolver.rb +60 -150
  75. data/lib/berkshelf/resolver/graph.rb +44 -0
  76. data/lib/berkshelf/source.rb +55 -0
  77. data/lib/berkshelf/source_uri.rb +38 -0
  78. data/lib/berkshelf/version.rb +1 -1
  79. data/spec/config/knife.rb +1 -1
  80. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +3694 -0
  81. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +1 -1
  82. data/spec/fixtures/lockfiles/default.lock +1 -1
  83. data/spec/spec_helper.rb +20 -121
  84. data/spec/support/chef_api.rb +3 -4
  85. data/spec/support/chef_server.rb +20 -11
  86. data/spec/support/git.rb +127 -0
  87. data/spec/support/kitchen.rb +12 -0
  88. data/spec/support/path_helpers.rb +69 -0
  89. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  90. data/spec/unit/berkshelf/api_client_spec.rb +57 -0
  91. data/spec/unit/berkshelf/berksfile_spec.rb +206 -324
  92. data/spec/unit/berkshelf/cached_cookbook_spec.rb +73 -38
  93. data/spec/unit/berkshelf/community_rest_spec.rb +30 -71
  94. data/spec/unit/berkshelf/config_spec.rb +3 -14
  95. data/spec/unit/berkshelf/cookbook_generator_spec.rb +1 -2
  96. data/spec/unit/berkshelf/cookbook_store_spec.rb +12 -7
  97. data/spec/unit/berkshelf/dependency_spec.rb +285 -0
  98. data/spec/unit/berkshelf/downloader_spec.rb +4 -183
  99. data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
  100. data/spec/unit/berkshelf/formatters_spec.rb +4 -2
  101. data/spec/unit/berkshelf/git_spec.rb +15 -15
  102. data/spec/unit/berkshelf/installer_spec.rb +39 -0
  103. data/spec/unit/berkshelf/location_spec.rb +87 -114
  104. data/spec/unit/berkshelf/locations/git_location_spec.rb +41 -53
  105. data/spec/unit/berkshelf/locations/path_location_spec.rb +13 -23
  106. data/spec/unit/berkshelf/lockfile_spec.rb +38 -40
  107. data/spec/unit/berkshelf/resolver/graph_spec.rb +44 -0
  108. data/spec/unit/berkshelf/resolver_spec.rb +34 -83
  109. data/spec/unit/berkshelf/source_spec.rb +23 -0
  110. data/spec/unit/berkshelf/source_uri_spec.rb +29 -0
  111. metadata +149 -188
  112. checksums.yaml +0 -7
  113. data/features/default_locations.feature +0 -127
  114. data/features/step_definitions/berksfile_steps.rb +0 -8
  115. data/features/step_definitions/configure_cli_steps.rb +0 -19
  116. data/features/vendor_install.feature +0 -19
  117. data/lib/berkshelf/core_ext/openuri.rb +0 -36
  118. data/lib/berkshelf/core_ext/rbzip2.rb +0 -8
  119. data/lib/berkshelf/locations/chef_api_location.rb +0 -228
  120. data/lib/berkshelf/locations/site_location.rb +0 -92
  121. data/lib/berkshelf/test.rb +0 -35
  122. data/spec/knife.rb.sample +0 -12
  123. data/spec/support/test_generators.rb +0 -27
  124. data/spec/unit/berkshelf/cli_spec.rb +0 -16
  125. data/spec/unit/berkshelf/cookbook_source_spec.rb +0 -358
  126. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +0 -46
  127. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -139
  128. data/spec/unit/berkshelf/locations/site_location_spec.rb +0 -19
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Pathname do
4
- describe "#cookbook?" do
5
- let(:cookbook_path) { tmp_path }
6
- let(:metadata_rb) { tmp_path.join("metadata.rb") }
7
- let(:metadata_json) { tmp_path.join("metadata.json") }
8
-
9
- subject { Pathname.new(cookbook_path) }
10
-
11
- context "when the path contains a metadata.json file" do
12
- before { FileUtils.touch(metadata_json) }
13
- its(:cookbook?) { should be_true }
14
- end
15
-
16
- context "when the path contains a metadata.rb file" do
17
- before { FileUtils.touch(metadata_rb) }
18
- its(:cookbook?) { should be_true }
19
- end
20
-
21
- context "when the path does not contain a metadata.json or metadata.rb file" do
22
- before { FileUtils.rm_f(metadata_rb) && FileUtils.rm_f(metadata_json) }
23
- its(:cookbook?) { should be_false }
24
- end
25
- end
26
-
27
- describe "#cookbook_root" do
28
- let(:root_path) { fixtures_path.join("cookbooks", "example_cookbook") }
29
- let(:cookbook_path) { root_path }
30
- subject { Pathname.new(cookbook_path) }
31
-
32
- context "when in the root of a cookbook" do
33
- its(:cookbook_root) { should eql(root_path) }
34
- end
35
-
36
- context "when in the structure of a cookbook" do
37
- let(:cookbook_path) { root_path.join("recipes") }
38
- its(:cookbook_root) { should eql(root_path) }
39
- end
40
-
41
- context "when not within the structure of a cookbook" do
42
- let(:cookbook_path) { "/" }
43
- its(:cookbook_root) { should be_nil }
44
- end
45
- end
46
- end
@@ -1,139 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::ChefAPILocation, :chef_server do
4
- let(:test_chef_api) { 'https://chefserver:8081' }
5
- let(:node_name) { 'reset' }
6
- let(:client_key) { fixtures_path.join('reset.pem').to_s }
7
-
8
- let(:valid_uri) { test_chef_api }
9
- let(:invalid_uri) { 'notauri' }
10
- let(:constraint) { double('constraint') }
11
-
12
- describe '.initialize' do
13
- subject do
14
- Berkshelf::ChefAPILocation.new('nginx',
15
- constraint,
16
- chef_api: test_chef_api,
17
- node_name: node_name,
18
- client_key: client_key
19
- )
20
- end
21
-
22
- it 'sets the uri attribute to the value of the chef_api option' do
23
- expect(subject.uri).to eq(test_chef_api)
24
- end
25
-
26
- it 'sets the node_name attribute to the value of the node_name option' do
27
- expect(subject.node_name).to eq(node_name)
28
- end
29
-
30
- it 'sets the client_key attribute to the value of the client_key option' do
31
- expect(subject.client_key).to eq(client_key)
32
- end
33
-
34
- context 'when an invalid Chef API URI is given' do
35
- it 'raises Berkshelf::InvalidChefAPILocation' do
36
- expect {
37
- Berkshelf::ChefAPILocation.new("nginx", constraint, chef_api: invalid_uri, node_name: node_name, client_key: client_key)
38
- }.to raise_error(Berkshelf::InvalidChefAPILocation, "'notauri' is not a valid Chef API URI.")
39
- end
40
- end
41
-
42
- context 'when no option for node_name is supplied' do
43
- it 'raises Berkshelf::InvalidChefAPILocation' do
44
- expect {
45
- Berkshelf::ChefAPILocation.new('nginx', constraint, chef_api: invalid_uri, client_key: client_key)
46
- }.to raise_error(Berkshelf::InvalidChefAPILocation)
47
- end
48
- end
49
-
50
- context 'when no option for client_key is supplied' do
51
- it 'raises Berkshelf::InvalidChefAPILocation' do
52
- expect {
53
- Berkshelf::ChefAPILocation.new('nginx', constraint, chef_api: invalid_uri, node_name: node_name)
54
- }.to raise_error(Berkshelf::InvalidChefAPILocation)
55
- end
56
- end
57
-
58
- context 'given the symbol :config for the value of chef_api:' do
59
- subject do
60
- Berkshelf::ChefAPILocation.new('nginx', constraint, chef_api: :config)
61
- end
62
-
63
- it 'uses the value of Berkshelf::Chef.instance.chef.chef_server_url for the uri attribute' do
64
- expect(subject.uri).to eq(Berkshelf::Config.instance.chef.chef_server_url)
65
- end
66
-
67
- it 'uses the value of Berkshelf::Chef.instance.chef.node_name for the node_name attribute' do
68
- expect(subject.node_name).to eq(Berkshelf::Config.instance.chef.node_name)
69
- end
70
-
71
- it 'uses the value of Berkshelf::Chef.instance.chef.client_key for the client_key attribute' do
72
- expect(subject.client_key).to eq(Berkshelf::Config.instance.chef.client_key)
73
- end
74
- end
75
- end
76
-
77
- describe '.validate_uri' do
78
- it 'returns false if the given URI is invalid' do
79
- expect(Berkshelf::ChefAPILocation.validate_uri(invalid_uri)).to be_false
80
- end
81
-
82
- it 'returns true if the given URI is valid' do
83
- expect(Berkshelf::ChefAPILocation.validate_uri(valid_uri)).to be_true
84
- end
85
- end
86
-
87
- describe '.validate_uri!' do
88
- it 'raises Berkshelf::InvalidChefAPILocation if the given URI is invalid' do
89
- expect {
90
- Berkshelf::ChefAPILocation.validate_uri!(invalid_uri)
91
- }.to raise_error(Berkshelf::InvalidChefAPILocation, "'notauri' is not a valid Chef API URI.")
92
- end
93
-
94
- it 'returns true if the given URI is valid' do
95
- expect(Berkshelf::ChefAPILocation.validate_uri!(valid_uri)).to be_true
96
- end
97
- end
98
-
99
-
100
-
101
- subject do
102
- Berkshelf::ChefAPILocation.new('nginx',
103
- nil,
104
- chef_api: test_chef_api,
105
- node_name: node_name,
106
- client_key: client_key
107
- )
108
- end
109
-
110
- describe '#target_cookbook' do
111
- let(:cookbook_version) { double('cookbook_version') }
112
-
113
- context 'when a version constraint is present' do
114
- let(:constraint) { double('constraint') }
115
-
116
- it 'returns the best solution for the constraint' do
117
- subject.stub(:version_constraint).and_return(constraint)
118
- subject.stub_chain(:conn, :cookbook, :satisfy).with(subject.name, constraint).and_return(cookbook_version)
119
-
120
- expect(subject.target_cookbook).to eq(cookbook_version)
121
- end
122
- end
123
-
124
- context 'when a version constraint is not present' do
125
- it 'returns the latest version of the cookbook' do
126
- subject.stub(:version_constraint).and_return(nil)
127
- subject.stub_chain(:conn, :cookbook, :latest_version).with(subject.name).and_return(cookbook_version)
128
-
129
- expect(subject.target_cookbook).to eq(cookbook_version)
130
- end
131
- end
132
- end
133
-
134
- describe '#to_s' do
135
- it 'returns a string containing the location key and the Chef API URI' do
136
- expect(subject.to_s).to eq("chef_api: '#{test_chef_api}'")
137
- end
138
- end
139
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::SiteLocation do
4
- describe '#download' do
5
- pending
6
- end
7
-
8
- describe '#target_version' do
9
- pending
10
- end
11
-
12
- describe '#to_hash' do
13
- pending
14
- end
15
-
16
- describe '#to_s' do
17
- pending
18
- end
19
- end