berkshelf 5.2.0 → 8.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +19 -47
- data/Rakefile +14 -4
- data/berkshelf.gemspec +61 -40
- data/bin/berks +2 -2
- data/lib/berkshelf/api-client.rb +1 -0
- data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
- data/lib/berkshelf/api_client/connection.rb +57 -0
- data/lib/berkshelf/api_client/errors.rb +10 -0
- data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
- data/lib/berkshelf/api_client/version.rb +5 -0
- data/lib/berkshelf/api_client.rb +24 -0
- data/lib/berkshelf/berksfile.rb +149 -122
- data/lib/berkshelf/cached_cookbook.rb +127 -24
- data/lib/berkshelf/chef_config_compat.rb +51 -0
- data/lib/berkshelf/chef_repo_universe.rb +47 -0
- data/lib/berkshelf/cli.rb +143 -174
- data/lib/berkshelf/commands/shelf.rb +20 -19
- data/lib/berkshelf/community_rest.rb +59 -94
- data/lib/berkshelf/config.rb +97 -127
- data/lib/berkshelf/cookbook_store.rb +7 -6
- data/lib/berkshelf/core_ext/file.rb +1 -1
- data/lib/berkshelf/core_ext/file_utils.rb +4 -4
- data/lib/berkshelf/core_ext.rb +1 -1
- data/lib/berkshelf/dependency.rb +25 -32
- data/lib/berkshelf/downloader.rb +66 -39
- data/lib/berkshelf/errors.rb +23 -17
- data/lib/berkshelf/file_syncer.rb +24 -47
- data/lib/berkshelf/formatters/human.rb +7 -5
- data/lib/berkshelf/formatters/json.rb +6 -6
- data/lib/berkshelf/installer.rb +120 -111
- data/lib/berkshelf/location.rb +14 -14
- data/lib/berkshelf/locations/base.rb +1 -1
- data/lib/berkshelf/locations/git.rb +16 -24
- data/lib/berkshelf/locations/github.rb +2 -2
- data/lib/berkshelf/locations/path.rb +2 -2
- data/lib/berkshelf/lockfile.rb +326 -328
- data/lib/berkshelf/logger.rb +64 -1
- data/lib/berkshelf/mixin/git.rb +6 -5
- data/lib/berkshelf/packager.rb +44 -10
- data/lib/berkshelf/resolver/graph.rb +1 -1
- data/lib/berkshelf/resolver.rb +4 -4
- data/lib/berkshelf/ridley_compat.rb +109 -0
- data/lib/berkshelf/shell.rb +2 -1
- data/lib/berkshelf/shell_out.rb +18 -0
- data/lib/berkshelf/source.rb +77 -33
- data/lib/berkshelf/source_uri.rb +4 -4
- data/lib/berkshelf/ssl_policies.rb +38 -0
- data/lib/berkshelf/thor.rb +1 -1
- data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
- data/lib/berkshelf/thor_ext.rb +1 -1
- data/lib/berkshelf/uploader.rb +106 -70
- data/lib/berkshelf/validator.rb +13 -5
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf/visualizer.rb +16 -11
- data/lib/berkshelf.rb +106 -81
- data/spec/config/knife.rb +4 -4
- data/spec/data/trusted_certs/example.crt +22 -0
- data/spec/fixtures/Berksfile +3 -3
- data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
- data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
- data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
- data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
- data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
- data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
- data/spec/spec_helper.rb +56 -64
- data/spec/support/chef_api.rb +15 -16
- data/spec/support/chef_server.rb +71 -69
- data/spec/support/git.rb +59 -58
- data/spec/support/kitchen.rb +0 -14
- data/spec/support/matchers/file_system_matchers.rb +4 -5
- data/spec/support/matchers/filepath_matchers.rb +2 -2
- data/spec/support/path_helpers.rb +17 -17
- data/spec/support/shared_examples/formatter.rb +1 -1
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
- data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
- data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
- data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
- data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
- data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
- data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
- data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
- data/spec/unit/berkshelf/cli_spec.rb +7 -8
- data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
- data/spec/unit/berkshelf/config_spec.rb +51 -22
- data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
- data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
- data/spec/unit/berkshelf/dependency_spec.rb +48 -48
- data/spec/unit/berkshelf/downloader_spec.rb +191 -34
- data/spec/unit/berkshelf/errors_spec.rb +3 -3
- data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
- data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
- data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
- data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
- data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
- data/spec/unit/berkshelf/installer_spec.rb +8 -8
- data/spec/unit/berkshelf/location_spec.rb +11 -11
- data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
- data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
- data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
- data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
- data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
- data/spec/unit/berkshelf/logger_spec.rb +3 -3
- data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
- data/spec/unit/berkshelf/packager_spec.rb +2 -2
- data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
- data/spec/unit/berkshelf/resolver_spec.rb +17 -17
- data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
- data/spec/unit/berkshelf/shell_spec.rb +34 -34
- data/spec/unit/berkshelf/source_spec.rb +186 -20
- data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
- data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
- data/spec/unit/berkshelf/uploader_spec.rb +146 -64
- data/spec/unit/berkshelf/validator_spec.rb +23 -16
- data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
- data/spec/unit/berkshelf_spec.rb +18 -18
- metadata +138 -289
- data/.gitignore +0 -29
- data/.travis.yml +0 -64
- data/CHANGELOG.legacy.md +0 -307
- data/CHANGELOG.md +0 -1358
- data/CONTRIBUTING.md +0 -64
- data/Gemfile.lock +0 -399
- data/Guardfile +0 -23
- data/PLUGINS.md +0 -25
- data/README.md +0 -70
- data/Thorfile +0 -61
- data/appveyor.yml +0 -31
- data/docs/berkshelf_for_newcomers.md +0 -65
- data/features/berksfile.feature +0 -46
- data/features/commands/apply.feature +0 -41
- data/features/commands/contingent.feature +0 -48
- data/features/commands/cookbook.feature +0 -35
- data/features/commands/info.feature +0 -99
- data/features/commands/init.feature +0 -27
- data/features/commands/install.feature +0 -636
- data/features/commands/list.feature +0 -78
- data/features/commands/outdated.feature +0 -130
- data/features/commands/package.feature +0 -17
- data/features/commands/search.feature +0 -17
- data/features/commands/shelf/list.feature +0 -32
- data/features/commands/shelf/show.feature +0 -143
- data/features/commands/shelf/uninstall.feature +0 -96
- data/features/commands/show.feature +0 -83
- data/features/commands/update.feature +0 -142
- data/features/commands/upload.feature +0 -426
- data/features/commands/vendor.feature +0 -111
- data/features/commands/verify.feature +0 -29
- data/features/commands/viz.feature +0 -66
- data/features/community_site.feature +0 -37
- data/features/config.feature +0 -111
- data/features/help.feature +0 -11
- data/features/json_formatter.feature +0 -161
- data/features/lifecycle.feature +0 -378
- data/features/lockfile.feature +0 -378
- data/features/step_definitions/berksfile_steps.rb +0 -39
- data/features/step_definitions/chef/config_steps.rb +0 -12
- data/features/step_definitions/chef_server_steps.rb +0 -60
- data/features/step_definitions/cli_steps.rb +0 -18
- data/features/step_definitions/config_steps.rb +0 -46
- data/features/step_definitions/environment_steps.rb +0 -7
- data/features/step_definitions/filesystem_steps.rb +0 -269
- data/features/step_definitions/gem_steps.rb +0 -13
- data/features/step_definitions/json_steps.rb +0 -23
- data/features/step_definitions/utility_steps.rb +0 -11
- data/features/support/aruba.rb +0 -12
- data/features/support/env.rb +0 -82
- data/generator_files/Berksfile.erb +0 -11
- data/generator_files/CHANGELOG.md.erb +0 -3
- data/generator_files/Gemfile.erb +0 -8
- data/generator_files/README.md.erb +0 -42
- data/generator_files/Thorfile.erb +0 -11
- data/generator_files/Vagrantfile.erb +0 -117
- data/generator_files/chefignore +0 -94
- data/generator_files/default_recipe.erb +0 -6
- data/generator_files/default_test.rb.erb +0 -11
- data/generator_files/gitignore.erb +0 -23
- data/generator_files/helpers.rb.erb +0 -7
- data/generator_files/licenses/apachev2.erb +0 -13
- data/generator_files/licenses/gplv2.erb +0 -15
- data/generator_files/licenses/gplv3.erb +0 -14
- data/generator_files/licenses/mit.erb +0 -20
- data/generator_files/licenses/reserved.erb +0 -3
- data/generator_files/metadata.rb.erb +0 -11
- data/lib/berkshelf/base_generator.rb +0 -43
- data/lib/berkshelf/commands/test_command.rb +0 -13
- data/lib/berkshelf/cookbook_generator.rb +0 -133
- data/lib/berkshelf/init_generator.rb +0 -195
- data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
- data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
- data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
@@ -5,7 +5,7 @@ module Berkshelf
|
|
5
5
|
#
|
6
6
|
# @return [Pathname]
|
7
7
|
def berkshelf_path
|
8
|
-
tmp_path.join(
|
8
|
+
tmp_path.join("berkshelf").expand_path
|
9
9
|
end
|
10
10
|
|
11
11
|
# The Berkshelf cookbook store
|
@@ -19,28 +19,28 @@ module Berkshelf
|
|
19
19
|
#
|
20
20
|
# @return [Pathname]
|
21
21
|
def tmp_path
|
22
|
-
Berkshelf.root.join(
|
22
|
+
Berkshelf.root.join("spec/tmp")
|
23
23
|
end
|
24
24
|
|
25
25
|
# The path to the spec fixtures
|
26
26
|
#
|
27
27
|
# @return [Pathname]
|
28
28
|
def fixtures_path
|
29
|
-
Berkshelf.root.join(
|
29
|
+
Berkshelf.root.join("spec/fixtures")
|
30
30
|
end
|
31
31
|
|
32
32
|
# The path to the Chef config fixture
|
33
33
|
#
|
34
34
|
# @return [String]
|
35
35
|
def chef_config_path
|
36
|
-
Berkshelf.root.join(
|
36
|
+
Berkshelf.root.join("spec/config/knife.rb").to_s
|
37
37
|
end
|
38
38
|
|
39
39
|
# The actual Chef config object
|
40
40
|
#
|
41
41
|
# @return [Bershelf::Chef::Config]
|
42
42
|
def chef_config
|
43
|
-
|
43
|
+
Berkshelf::ChefConfigCompat.from_file(chef_config_path)
|
44
44
|
end
|
45
45
|
|
46
46
|
def clean_tmp_path
|
@@ -50,20 +50,20 @@ module Berkshelf
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
# This is the magical "reset" function that gives us a clean working
|
54
|
+
# directory on each run.
|
55
|
+
#
|
56
|
+
# @return [nil]
|
57
|
+
def reload_configs
|
58
|
+
Berkshelf.chef_config = chef_config
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
# This fucking sucks...
|
61
|
+
# load 'berkshelf/chef/config.rb'
|
62
|
+
load "berkshelf/config.rb"
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
Berkshelf.config = Berkshelf::Config.new
|
65
|
+
nil
|
66
|
+
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Berkshelf::Berksfile do
|
4
4
|
describe "ClassMethods" do
|
5
|
-
describe
|
5
|
+
describe "::from_file" do
|
6
6
|
let(:content) do
|
7
7
|
<<-EOF.strip
|
8
8
|
cookbook 'ntp', '<= 1.0.0'
|
@@ -12,13 +12,13 @@ describe Berkshelf::Berksfile do
|
|
12
12
|
solver :foo, :required
|
13
13
|
EOF
|
14
14
|
end
|
15
|
-
let(:berksfile) { tmp_path.join(
|
15
|
+
let(:berksfile) { tmp_path.join("Berksfile") }
|
16
16
|
|
17
|
-
before { File.open(berksfile,
|
17
|
+
before { File.open(berksfile, "w+") { |f| f.write(content) } }
|
18
18
|
subject(:from_file) { described_class.from_file(berksfile) }
|
19
19
|
|
20
20
|
it "reads the content of the Berksfile and binds them to a new instance" do
|
21
|
-
%w
|
21
|
+
%w{ntp mysql nginx ssh_known_hosts2}.each do |name|
|
22
22
|
expect(subject).to have_dependency(name)
|
23
23
|
end
|
24
24
|
end
|
@@ -27,62 +27,62 @@ describe Berkshelf::Berksfile do
|
|
27
27
|
expect(subject).to be_a(described_class)
|
28
28
|
end
|
29
29
|
|
30
|
-
context
|
31
|
-
let(:bad_path) { tmp_path.join(
|
30
|
+
context "when Berksfile does not exist at given path" do
|
31
|
+
let(:bad_path) { tmp_path.join("thisdoesnotexist") }
|
32
32
|
|
33
|
-
it
|
34
|
-
expect
|
33
|
+
it "raises BerksfileNotFound" do
|
34
|
+
expect do
|
35
35
|
Berkshelf::Berksfile.from_file(bad_path)
|
36
|
-
|
36
|
+
end.to raise_error(Berkshelf::BerksfileNotFound)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
let(:dependency_one) { double(
|
43
|
-
let(:dependency_two) { double(
|
42
|
+
let(:dependency_one) { double("dependency_one", name: "nginx") }
|
43
|
+
let(:dependency_two) { double("dependency_two", name: "mysql") }
|
44
44
|
|
45
45
|
subject do
|
46
|
-
berksfile_path = tmp_path.join(
|
46
|
+
berksfile_path = tmp_path.join("Berksfile").to_s
|
47
47
|
FileUtils.touch(berksfile_path)
|
48
48
|
Berkshelf::Berksfile.new(berksfile_path)
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
52
|
-
let(:name) {
|
53
|
-
let(:constraint) { double(
|
51
|
+
describe "#cookbook" do
|
52
|
+
let(:name) { "artifact" }
|
53
|
+
let(:constraint) { double("constraint") }
|
54
54
|
let(:default_options) { { group: [] } }
|
55
55
|
|
56
|
-
it
|
56
|
+
it "sends the add_dependency message with the name, constraint, and options to the instance of the includer" do
|
57
57
|
expect(subject).to receive(:add_dependency).with(name, constraint, default_options)
|
58
58
|
subject.cookbook(name, constraint, default_options)
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
62
|
-
expect(subject).to receive(:add_dependency)do |arg_name, arg_constraint, arg_options|
|
61
|
+
it "merges the default options into specified options" do
|
62
|
+
expect(subject).to receive(:add_dependency) do |arg_name, arg_constraint, arg_options|
|
63
63
|
expect(arg_name).to eq(name)
|
64
64
|
expect(arg_constraint).to eq(constraint)
|
65
65
|
expect(arg_options[:path]).to match(%r{/Users/reset})
|
66
66
|
expect(arg_options[:group]).to eq([])
|
67
67
|
end
|
68
68
|
|
69
|
-
subject.cookbook(name, constraint, path:
|
69
|
+
subject.cookbook(name, constraint, path: "/Users/reset")
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
72
|
+
it "converts a single specified group option into an array of groups" do
|
73
73
|
expect(subject).to receive(:add_dependency).with(name, constraint, group: [:production])
|
74
74
|
subject.cookbook(name, constraint, group: :production)
|
75
75
|
end
|
76
76
|
|
77
|
-
context
|
78
|
-
it
|
77
|
+
context "when no constraint specified" do
|
78
|
+
it "sends the add_dependency message with a nil value for constraint" do
|
79
79
|
expect(subject).to receive(:add_dependency).with(name, nil, default_options)
|
80
80
|
subject.cookbook(name, default_options)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
context
|
85
|
-
it
|
84
|
+
context "when no options specified" do
|
85
|
+
it "sends the add_dependency message with an empty Hash for the value of options" do
|
86
86
|
expect(subject).to receive(:add_dependency).with(name, constraint, default_options)
|
87
87
|
subject.cookbook(name, constraint)
|
88
88
|
end
|
@@ -93,11 +93,11 @@ describe Berkshelf::Berksfile do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe
|
97
|
-
let(:name) {
|
98
|
-
let(:group) {
|
96
|
+
describe "#group" do
|
97
|
+
let(:name) { "artifact" }
|
98
|
+
let(:group) { "production" }
|
99
99
|
|
100
|
-
it
|
100
|
+
it "sends the add_dependency message with an array of groups determined by the parameter to the group block" do
|
101
101
|
expect(subject).to receive(:add_dependency).with(name, nil, group: [group])
|
102
102
|
|
103
103
|
subject.group(group) do
|
@@ -110,14 +110,14 @@ describe Berkshelf::Berksfile do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
describe
|
114
|
-
let(:path) { fixtures_path.join(
|
115
|
-
subject { Berkshelf::Berksfile.new(path.join(
|
113
|
+
describe "#metadata" do
|
114
|
+
let(:path) { fixtures_path.join("cookbooks/example_cookbook") }
|
115
|
+
subject { Berkshelf::Berksfile.new(path.join("Berksfile")) }
|
116
116
|
|
117
117
|
before { Dir.chdir(path) }
|
118
118
|
|
119
|
-
it
|
120
|
-
expect(subject).to receive(:add_dependency).with(
|
119
|
+
it "sends the add_dependency message with an explicit version constraint and the path to the cookbook" do
|
120
|
+
expect(subject).to receive(:add_dependency).with("example_cookbook", nil, path: path.to_s, metadata: true)
|
121
121
|
subject.metadata
|
122
122
|
end
|
123
123
|
|
@@ -171,9 +171,9 @@ describe Berkshelf::Berksfile do
|
|
171
171
|
describe "#sources" do
|
172
172
|
context "when there are no sources" do
|
173
173
|
it "raises an exception" do
|
174
|
-
expect
|
174
|
+
expect do
|
175
175
|
subject.sources
|
176
|
-
|
176
|
+
end.to raise_error(Berkshelf::NoAPISourcesDefined)
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -192,41 +192,21 @@ describe Berkshelf::Berksfile do
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
describe "#
|
196
|
-
it "raises a Berkshelf::Deprecated error" do
|
197
|
-
expect { subject.site }.to raise_error(Berkshelf::DeprecatedError)
|
198
|
-
end
|
199
|
-
|
200
|
-
it "is a DSL method" do
|
201
|
-
expect(subject).to have_exposed_method(:site)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#chef_api" do
|
206
|
-
it "raises a Berkshelf::Deprecated error" do
|
207
|
-
expect { subject.chef_api }.to raise_error(Berkshelf::DeprecatedError)
|
208
|
-
end
|
209
|
-
|
210
|
-
it "is a DSL method" do
|
211
|
-
expect(subject).to have_exposed_method(:chef_api)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
describe '#extension' do
|
195
|
+
describe "#extension" do
|
216
196
|
it "is a DSL method" do
|
217
197
|
expect(subject).to have_exposed_method(:extension)
|
218
198
|
end
|
219
199
|
end
|
220
200
|
|
221
|
-
describe
|
201
|
+
describe "#dependencies" do
|
222
202
|
let(:groups) do
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
203
|
+
%i{
|
204
|
+
nautilus
|
205
|
+
skarner
|
206
|
+
}
|
227
207
|
end
|
228
208
|
|
229
|
-
it
|
209
|
+
it "returns all Berkshelf::Dependencys added to the instance of Berksfile" do
|
230
210
|
subject.add_dependency(dependency_one.name)
|
231
211
|
subject.add_dependency(dependency_two.name)
|
232
212
|
|
@@ -236,15 +216,15 @@ describe Berkshelf::Berksfile do
|
|
236
216
|
end
|
237
217
|
end
|
238
218
|
|
239
|
-
describe
|
240
|
-
it
|
241
|
-
subject.add_dependency(
|
219
|
+
describe "#cookbooks" do
|
220
|
+
it "raises an exception if a cookbook is not installed" do
|
221
|
+
subject.add_dependency("bacon", nil)
|
242
222
|
expect { subject.cookbooks }.to raise_error(Berkshelf::DependencyNotFound)
|
243
223
|
end
|
244
224
|
|
245
|
-
it
|
246
|
-
subject.add_dependency(
|
247
|
-
subject.add_dependency(
|
225
|
+
it "retrieves the locked (cached) cookbook for each dependency" do
|
226
|
+
subject.add_dependency("bacon", nil)
|
227
|
+
subject.add_dependency("ham", nil)
|
248
228
|
allow(subject).to receive(:retrive_locked)
|
249
229
|
|
250
230
|
expect(subject).to receive(:retrieve_locked).twice
|
@@ -252,30 +232,30 @@ describe Berkshelf::Berksfile do
|
|
252
232
|
end
|
253
233
|
end
|
254
234
|
|
255
|
-
describe
|
235
|
+
describe "#groups" do
|
256
236
|
before do
|
257
237
|
allow(subject).to receive(:dependencies) { [dependency_one, dependency_two] }
|
258
|
-
allow(dependency_one).to receive(:groups) {
|
259
|
-
allow(dependency_two).to receive(:groups) {
|
238
|
+
allow(dependency_one).to receive(:groups) { %i{nautilus skarner} }
|
239
|
+
allow(dependency_two).to receive(:groups) { %i{nautilus riven} }
|
260
240
|
end
|
261
241
|
|
262
|
-
it
|
242
|
+
it "returns a hash containing keys for every group a dependency is a member of" do
|
263
243
|
expect(subject.groups.keys.size).to eq(3)
|
264
244
|
expect(subject.groups).to have_key(:nautilus)
|
265
245
|
expect(subject.groups).to have_key(:skarner)
|
266
246
|
expect(subject.groups).to have_key(:riven)
|
267
247
|
end
|
268
248
|
|
269
|
-
it
|
249
|
+
it "returns an Array of Berkshelf::Dependencys who are members of the group for value" do
|
270
250
|
expect(subject.groups[:nautilus].size).to eq(2)
|
271
251
|
expect(subject.groups[:riven].size).to eq(1)
|
272
252
|
end
|
273
253
|
end
|
274
254
|
|
275
|
-
describe
|
276
|
-
let(:name) {
|
277
|
-
let(:constraint) {
|
278
|
-
let(:options) {
|
255
|
+
describe "#add_dependency" do
|
256
|
+
let(:name) { "cookbook_one" }
|
257
|
+
let(:constraint) { "= 1.2.0" }
|
258
|
+
let(:options) { {} }
|
279
259
|
|
280
260
|
before(:each) do
|
281
261
|
subject.add_dependency(name, constraint, options)
|
@@ -283,7 +263,7 @@ describe Berkshelf::Berksfile do
|
|
283
263
|
|
284
264
|
let(:dependency) { subject.dependencies.first }
|
285
265
|
|
286
|
-
it
|
266
|
+
it "adds new dependency to the list of dependencies" do
|
287
267
|
expect(subject.dependencies.size).to eq(1)
|
288
268
|
end
|
289
269
|
|
@@ -299,10 +279,10 @@ describe Berkshelf::Berksfile do
|
|
299
279
|
expect(dependency.version_constraint.to_s).to eq(constraint)
|
300
280
|
end
|
301
281
|
|
302
|
-
it
|
303
|
-
expect
|
282
|
+
it "raises DuplicateDependencyDefined if multiple dependencies of the same name are found" do
|
283
|
+
expect do
|
304
284
|
subject.add_dependency(name)
|
305
|
-
|
285
|
+
end.to raise_error(Berkshelf::DuplicateDependencyDefined)
|
306
286
|
end
|
307
287
|
|
308
288
|
it "has a nil location if no location options are provided" do
|
@@ -326,7 +306,7 @@ describe Berkshelf::Berksfile do
|
|
326
306
|
end
|
327
307
|
|
328
308
|
context "when given the :path option" do
|
329
|
-
let(:options) { { path: fixtures_path.join(
|
309
|
+
let(:options) { { path: fixtures_path.join("cookbooks", "example_cookbook") } }
|
330
310
|
|
331
311
|
it "has a PathLocation location" do
|
332
312
|
expect(dependency.location).to be_a(Berkshelf::PathLocation)
|
@@ -334,23 +314,23 @@ describe Berkshelf::Berksfile do
|
|
334
314
|
end
|
335
315
|
end
|
336
316
|
|
337
|
-
describe
|
338
|
-
let(:lockfile) { double(
|
339
|
-
let(:dependency) { double(
|
340
|
-
let(:locked) { double(
|
341
|
-
let(:cached) { double(
|
317
|
+
describe "#retrieve_locked" do
|
318
|
+
let(:lockfile) { double("lockfile") }
|
319
|
+
let(:dependency) { double("dependency", name: "bacon") }
|
320
|
+
let(:locked) { double("locked", cached_cookbook: cached, locked_version: "1.0.0") }
|
321
|
+
let(:cached) { double("cached") }
|
342
322
|
|
343
323
|
before do
|
344
324
|
allow(subject).to receive(:lockfile).and_return(lockfile)
|
345
325
|
end
|
346
326
|
|
347
|
-
it
|
327
|
+
it "delegates to the lockfile" do
|
348
328
|
expect(lockfile).to receive(:retrieve).with(dependency)
|
349
329
|
subject.retrieve_locked(dependency)
|
350
330
|
end
|
351
331
|
end
|
352
332
|
|
353
|
-
describe
|
333
|
+
describe "#upload" do
|
354
334
|
let(:uploader) { double(Berkshelf::Uploader, run: nil) }
|
355
335
|
|
356
336
|
before do
|
@@ -361,22 +341,22 @@ describe Berkshelf::Berksfile do
|
|
361
341
|
allow(Berkshelf::Uploader).to receive(:new).and_return(uploader)
|
362
342
|
end
|
363
343
|
|
364
|
-
it
|
344
|
+
it "validates the lockfile is present" do
|
365
345
|
expect(subject).to receive(:validate_lockfile_present!).once
|
366
346
|
subject.upload
|
367
347
|
end
|
368
348
|
|
369
|
-
it
|
349
|
+
it "validates the lockfile is trusted" do
|
370
350
|
expect(subject).to receive(:validate_lockfile_trusted!).once
|
371
351
|
subject.upload
|
372
352
|
end
|
373
353
|
|
374
|
-
it
|
354
|
+
it "validates the dependencies are installed" do
|
375
355
|
expect(subject).to receive(:validate_dependencies_installed!).once
|
376
356
|
subject.upload
|
377
357
|
end
|
378
358
|
|
379
|
-
it
|
359
|
+
it "creates a new Uploader" do
|
380
360
|
expect(Berkshelf::Uploader).to receive(:new).with(subject)
|
381
361
|
expect(uploader).to receive(:run)
|
382
362
|
|
@@ -384,31 +364,30 @@ describe Berkshelf::Berksfile do
|
|
384
364
|
end
|
385
365
|
end
|
386
366
|
|
387
|
-
describe
|
388
|
-
let(:cached_cookbook) {
|
389
|
-
let(:installer) {
|
390
|
-
let(:raw_metadata_files) { [File
|
367
|
+
describe "#vendor" do
|
368
|
+
let(:cached_cookbook) { instance_double(Berkshelf::CachedCookbook, cookbook_name: "my_cookbook", path: "/my_cookbook/path", compile_metadata: true, reload: nil) }
|
369
|
+
let(:installer) { instance_double(Berkshelf::Installer, run: [cached_cookbook]) }
|
370
|
+
let(:raw_metadata_files) { [File.join(cached_cookbook.cookbook_name, "metadata.rb")] }
|
391
371
|
|
392
|
-
let(:destination) {
|
393
|
-
let(:options)
|
372
|
+
let(:destination) { "/a/destination/path" }
|
373
|
+
let(:options) { { exclude: Berkshelf::Berksfile::EXCLUDED_VCS_FILES_WHEN_VENDORING, delete: nil } }
|
394
374
|
|
395
375
|
before do
|
396
376
|
allow(Berkshelf::Installer).to receive(:new).and_return(installer)
|
397
377
|
end
|
398
378
|
|
399
|
-
it
|
379
|
+
it "invokes FileSyncer with correct arguments" do
|
400
380
|
expect(Berkshelf::FileSyncer).to receive(:sync).with(/vendor/, destination, options)
|
401
381
|
|
402
382
|
subject.vendor(destination)
|
403
383
|
end
|
404
384
|
|
405
|
-
it
|
406
|
-
expect(options[:exclude].any? { |exclude| File.fnmatch?(exclude,
|
407
|
-
expect(options[:exclude].any? { |exclude| File.fnmatch?(exclude, 'my_cookbook/metadata.rb', File::FNM_DOTMATCH) }).to be(true)
|
385
|
+
it "excludes the top-level metadata.rb file" do
|
386
|
+
expect(options[:exclude].any? { |exclude| File.fnmatch?(exclude, "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) }).to be(false)
|
408
387
|
end
|
409
388
|
end
|
410
389
|
|
411
|
-
describe
|
390
|
+
describe "#solver" do
|
412
391
|
|
413
392
|
let(:solver_precedence) { :please_dont_exist }
|
414
393
|
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Berkshelf::APIClient::ChefServerConnection do
|
4
|
+
let(:instance) do
|
5
|
+
described_class.new(
|
6
|
+
server_url: "https://chef.example.org/organizations/foobar",
|
7
|
+
timeout: 30,
|
8
|
+
open_timeout: 3,
|
9
|
+
ssl: {}
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#universe" do
|
14
|
+
before do
|
15
|
+
body_response = %q{{"ruby":{"1.2.3":{"endpoint_priority":0,"platforms":{},"dependencies":{"build-essential":">= 1.2.2"},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"},"2.0.0":{"endpoint_priority":0,"platforms":{},"dependencies":{"build-essential":">= 1.2.2"},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"}},"elixir":{"1.0.0":{"endpoint_priority":0,"platforms":{"CentOS":"= 6.0.0"},"dependencies":{},"location_type":"supermarket","location_path":"https://supermarket.getchef.com/"}}}}
|
16
|
+
|
17
|
+
stub_request(:get, "https://chef.example.org/organizations/foobar/universe")
|
18
|
+
.to_return(status: 200, body: body_response, headers: { "Content-Type" => "application/json; charset=utf-8" })
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { instance.universe }
|
22
|
+
|
23
|
+
it "returns an array of APIClient::RemoteCookbook" do
|
24
|
+
expect(subject).to be_a(Array)
|
25
|
+
|
26
|
+
subject.each do |remote|
|
27
|
+
expect(remote).to be_a(Berkshelf::APIClient::RemoteCookbook)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "contains a item for each dependency" do
|
32
|
+
expect(subject.size).to eq(3)
|
33
|
+
expect(subject[0].name).to eql("ruby")
|
34
|
+
expect(subject[0].version).to eql("1.2.3")
|
35
|
+
expect(subject[1].name).to eql("ruby")
|
36
|
+
expect(subject[1].version).to eql("2.0.0")
|
37
|
+
expect(subject[2].name).to eql("elixir")
|
38
|
+
expect(subject[2].version).to eql("1.0.0")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has the dependencies for each" do
|
42
|
+
expect(subject[0].dependencies).to include("build-essential" => ">= 1.2.2")
|
43
|
+
expect(subject[1].dependencies).to include("build-essential" => ">= 1.2.2")
|
44
|
+
expect(subject[2].dependencies).to be_empty
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has the platforms for each" do
|
48
|
+
expect(subject[0].platforms).to be_empty
|
49
|
+
expect(subject[1].platforms).to be_empty
|
50
|
+
expect(subject[2].platforms).to include("CentOS" => "= 6.0.0")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "has a location_path for each" do
|
54
|
+
subject.each do |remote|
|
55
|
+
expect(remote.location_path).to_not be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a location_type for each" do
|
60
|
+
subject.each do |remote|
|
61
|
+
expect(remote.location_type).to_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|