berkshelf 6.0.1 → 6.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -3
- data/Gemfile +1 -28
- data/Gemfile.lock +27 -94
- data/Rakefile +10 -0
- data/appveyor.yml +2 -2
- data/berkshelf.gemspec +2 -1
- data/features/commands/install.feature +21 -0
- data/features/step_definitions/berksfile_steps.rb +1 -1
- data/features/step_definitions/environment_steps.rb +1 -1
- data/features/step_definitions/json_steps.rb +2 -2
- data/features/support/env.rb +0 -2
- data/lib/berkshelf/berksfile.rb +1 -1
- data/lib/berkshelf/chef_repo_universe.rb +45 -0
- data/lib/berkshelf/cli.rb +1 -2
- data/lib/berkshelf/community_rest.rb +6 -37
- data/lib/berkshelf/config.rb +3 -0
- data/lib/berkshelf/downloader.rb +2 -2
- data/lib/berkshelf/formatters/human.rb +3 -1
- data/lib/berkshelf/installer.rb +14 -6
- data/lib/berkshelf/locations/git.rb +0 -2
- data/lib/berkshelf/mixin/git.rb +4 -3
- data/lib/berkshelf/shell_out.rb +17 -0
- data/lib/berkshelf/source.rb +30 -17
- data/lib/berkshelf/source_uri.rb +1 -1
- data/lib/berkshelf/ssl_policies.rb +1 -1
- data/lib/berkshelf/streaming_file_adapter.rb +22 -0
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf/visualizer.rb +3 -3
- data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
- data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
- data/spec/support/git.rb +18 -17
- data/spec/support/kitchen.rb +0 -14
- data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
- data/spec/unit/berkshelf/config_spec.rb +46 -0
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -8
- data/spec/unit/berkshelf/downloader_spec.rb +12 -9
- data/spec/unit/berkshelf/init_generator_spec.rb +0 -1
- data/spec/unit/berkshelf/locations/git_spec.rb +2 -2
- data/spec/unit/berkshelf/resolver/graph_spec.rb +3 -2
- data/spec/unit/berkshelf/source_spec.rb +55 -44
- data/spec/unit/berkshelf/ssl_policies_spec.rb +3 -2
- data/spec/unit/berkshelf/uploader_spec.rb +1 -0
- data/spec/unit/berkshelf/visualizer_spec.rb +1 -1
- metadata +30 -7
- data/Guardfile +0 -18
- data/lib/berkshelf/commands/test_command.rb +0 -13
data/lib/berkshelf/version.rb
CHANGED
data/lib/berkshelf/visualizer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "buff/shell_out"
|
2
1
|
require "set"
|
3
2
|
require "tempfile"
|
3
|
+
require "berkshelf/shell_out"
|
4
4
|
|
5
5
|
module Berkshelf
|
6
6
|
class Visualizer
|
@@ -18,7 +18,7 @@ module Berkshelf
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
include
|
21
|
+
include Berkshelf::ShellOut
|
22
22
|
|
23
23
|
def initialize
|
24
24
|
@nodes = {}
|
@@ -100,7 +100,7 @@ module Berkshelf
|
|
100
100
|
command = %{dot -T png #{tempfile.path} -o "#{outfile}"}
|
101
101
|
response = shell_out(command)
|
102
102
|
|
103
|
-
|
103
|
+
if response.error?
|
104
104
|
raise GraphvizCommandFailed.new(command, response.stderr)
|
105
105
|
end
|
106
106
|
|
data/spec/support/git.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module Berkshelf
|
2
2
|
module RSpec
|
3
3
|
module Git
|
4
|
-
require "buff/shell_out"
|
5
|
-
include Buff::ShellOut
|
6
|
-
|
7
4
|
require_relative "path_helpers"
|
8
5
|
include Berkshelf::RSpec::PathHelpers
|
9
6
|
|
@@ -25,20 +22,24 @@ module Berkshelf
|
|
25
22
|
shell_out "git add ."
|
26
23
|
shell_out "git commit -am \"A commit.\""
|
27
24
|
|
28
|
-
options[:tags]
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
if options[:tags]
|
26
|
+
options[:tags].each do |tag|
|
27
|
+
shell_out "echo \"#{tag}\" > content_file"
|
28
|
+
shell_out "git add content_file"
|
29
|
+
shell_out "git commit -am \"#{tag} content\""
|
30
|
+
shell_out "git tag \"#{tag}\""
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if options[:branches]
|
35
|
+
options[:branches].each do |branch|
|
36
|
+
shell_out "git checkout -b #{branch} master"
|
37
|
+
shell_out "echo \"#{branch}\" > content_file"
|
38
|
+
shell_out "git add content_file"
|
39
|
+
shell_out "git commit -am \"#{branch} content\""
|
40
|
+
shell_out "git checkout master"
|
41
|
+
end
|
42
|
+
end
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
data/spec/support/kitchen.rb
CHANGED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Berkshelf
|
2
|
-
module RSpec
|
3
|
-
module Kitchen
|
4
|
-
require "kitchen/generator/init"
|
5
|
-
|
6
|
-
def stub_kitchen!
|
7
|
-
generator = double("kitchen-generator", invoke_all: nil)
|
8
|
-
allow(::Kitchen::Generator::Init).to receive(:new)
|
9
|
-
.with(any_args())
|
10
|
-
.and_return(generator)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Berkshelf
|
4
|
+
describe ChefRepoUniverse do
|
5
|
+
let(:fixture) { nil }
|
6
|
+
let(:fixture_path) { File.expand_path("../../../fixtures/#{fixture}", __FILE__) }
|
7
|
+
subject { described_class.new("file://#{fixture_path}", path: fixture_path).universe }
|
8
|
+
|
9
|
+
context "with cookbooks in ./" do
|
10
|
+
let(:fixture) { "cookbook-path" }
|
11
|
+
|
12
|
+
it "returns the correct universe" do
|
13
|
+
expect(subject.size).to eq 1
|
14
|
+
expect(subject[0].name).to eq "jenkins-config"
|
15
|
+
expect(subject[0].version).to eq "0.1.0"
|
16
|
+
expect(subject[0].dependencies).to eq "jenkins" => "~> 2.0"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with cookbooks in cookbooks/" do
|
21
|
+
let(:fixture) { "complex-cookbook-path" }
|
22
|
+
|
23
|
+
it "returns the correct universe" do
|
24
|
+
expect(subject.size).to eq 3
|
25
|
+
expect(subject[0].name).to eq "app"
|
26
|
+
expect(subject[0].version).to eq "1.2.3"
|
27
|
+
expect(subject[0].dependencies).to eq({})
|
28
|
+
expect(subject[1].name).to eq "jenkins"
|
29
|
+
expect(subject[1].version).to eq "2.0.1"
|
30
|
+
expect(subject[1].dependencies).to eq({})
|
31
|
+
expect(subject[2].name).to eq "jenkins-config"
|
32
|
+
expect(subject[2].version).to eq "0.1.0"
|
33
|
+
expect(subject[2].dependencies).to eq "jenkins" => "~> 2.0"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -21,6 +21,52 @@ describe Berkshelf::Config do
|
|
21
21
|
expect(Berkshelf::Config.instance.api.timeout).to eq("30")
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
context "a Chef config to read defaults from" do
|
26
|
+
let(:chef_config) do
|
27
|
+
double(
|
28
|
+
Ridley::Chef::Config,
|
29
|
+
chef_server_url: "https://chef.example.com",
|
30
|
+
validation_client_name: "validator",
|
31
|
+
validation_key: "validator.pem",
|
32
|
+
client_key: "client-key",
|
33
|
+
node_name: "fake-client",
|
34
|
+
trusted_certs_dir: "/tmp/fakecerts",
|
35
|
+
artifactory_api_key: "secret",
|
36
|
+
cookbook_copyright: "user",
|
37
|
+
cookbook_email: "user@example.com",
|
38
|
+
cookbook_license: "apachev2"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
allow(Berkshelf).to receive(:chef_config).and_return(chef_config)
|
44
|
+
end
|
45
|
+
|
46
|
+
{
|
47
|
+
chef_server_url: "https://chef.example.com",
|
48
|
+
validation_client_name: "validator",
|
49
|
+
validation_key_path: "validator.pem",
|
50
|
+
client_key: "client-key",
|
51
|
+
node_name: "fake-client",
|
52
|
+
trusted_certs_dir: "/tmp/fakecerts",
|
53
|
+
artifactory_api_key: "secret",
|
54
|
+
}.each do |attr, default|
|
55
|
+
it "should have a default chef.#{attr}" do
|
56
|
+
expect(Berkshelf::Config.instance.chef.send(attr)).to eq(default)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
{
|
61
|
+
copyright: "user",
|
62
|
+
email: "user@example.com",
|
63
|
+
license: "apachev2",
|
64
|
+
}.each do |attr, default|
|
65
|
+
it "should have a default cookbook.#{attr}" do
|
66
|
+
expect(Berkshelf::Config.instance.cookbook.send(attr)).to eq(default)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
24
70
|
end
|
25
71
|
|
26
72
|
describe "::path" do
|
@@ -9,13 +9,6 @@ describe Berkshelf::CookbookGenerator do
|
|
9
9
|
let(:target) { tmp_path.join(name) }
|
10
10
|
let(:kitchen_generator) { double("kitchen-generator", invoke_all: nil) }
|
11
11
|
|
12
|
-
before do
|
13
|
-
allow(Kitchen::Generator::Init)
|
14
|
-
.to receive(:new)
|
15
|
-
.with(any_args())
|
16
|
-
.and_return(kitchen_generator)
|
17
|
-
end
|
18
|
-
|
19
12
|
context "with default options" do
|
20
13
|
before do
|
21
14
|
capture(:stdout) do
|
@@ -82,7 +75,6 @@ describe Berkshelf::CookbookGenerator do
|
|
82
75
|
|
83
76
|
context "given a 'maintainer_email' option" do
|
84
77
|
before do
|
85
|
-
allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
|
86
78
|
capture(:stdout) do
|
87
79
|
Berkshelf::CookbookGenerator.new([target, name], maintainer_email: "jamie@vialstudios.com").invoke_all
|
88
80
|
end
|
@@ -39,20 +39,22 @@ module Berkshelf
|
|
39
39
|
|
40
40
|
it "supports the 'opscode' location type" do
|
41
41
|
allow(source).to receive(:type) { :supermarket }
|
42
|
+
allow(source).to receive(:options) { { ssl: {} } }
|
42
43
|
allow(remote_cookbook).to receive(:location_type) { :opscode }
|
43
44
|
allow(remote_cookbook).to receive(:location_path) { "http://api.opscode.com" }
|
44
45
|
rest = double("community-rest")
|
45
|
-
expect(CommunityREST).to receive(:new).with("http://api.opscode.com", {}) { rest }
|
46
|
+
expect(CommunityREST).to receive(:new).with("http://api.opscode.com", { ssl: {} }) { rest }
|
46
47
|
expect(rest).to receive(:download).with(name, version)
|
47
48
|
subject.try_download(source, name, version)
|
48
49
|
end
|
49
50
|
|
50
51
|
it "supports the 'supermarket' location type" do
|
51
52
|
allow(source).to receive(:type) { :supermarket }
|
53
|
+
allow(source).to receive(:options) { { ssl: {} } }
|
52
54
|
allow(remote_cookbook).to receive(:location_type) { :supermarket }
|
53
55
|
allow(remote_cookbook).to receive(:location_path) { "http://api.supermarket.com" }
|
54
56
|
rest = double("community-rest")
|
55
|
-
expect(CommunityREST).to receive(:new).with("http://api.supermarket.com", {}) { rest }
|
57
|
+
expect(CommunityREST).to receive(:new).with("http://api.supermarket.com", { ssl: {} }) { rest }
|
56
58
|
expect(rest).to receive(:download).with(name, version)
|
57
59
|
subject.try_download(source, name, version)
|
58
60
|
end
|
@@ -60,22 +62,22 @@ module Berkshelf
|
|
60
62
|
context "with an artifactory source" do
|
61
63
|
it "supports the 'opscode' location type" do
|
62
64
|
allow(source).to receive(:type) { :artifactory }
|
63
|
-
allow(source).to receive(:options) { {api_key:
|
65
|
+
allow(source).to receive(:options) { { api_key: "secret", ssl: {} } }
|
64
66
|
allow(remote_cookbook).to receive(:location_type) { :opscode }
|
65
67
|
allow(remote_cookbook).to receive(:location_path) { "http://artifactory/" }
|
66
68
|
rest = double("community-rest")
|
67
|
-
expect(CommunityREST).to receive(:new).with("http://artifactory/", {headers: {
|
69
|
+
expect(CommunityREST).to receive(:new).with("http://artifactory/", { ssl: {}, headers: { "X-Jfrog-Art-Api" => "secret" } }) { rest }
|
68
70
|
expect(rest).to receive(:download).with(name, version)
|
69
71
|
subject.try_download(source, name, version)
|
70
72
|
end
|
71
73
|
|
72
74
|
it "supports the 'supermarket' location type" do
|
73
75
|
allow(source).to receive(:type) { :artifactory }
|
74
|
-
allow(source).to receive(:options) { {api_key:
|
76
|
+
allow(source).to receive(:options) { { api_key: "secret", ssl: {} } }
|
75
77
|
allow(remote_cookbook).to receive(:location_type) { :supermarket }
|
76
78
|
allow(remote_cookbook).to receive(:location_path) { "http://artifactory/" }
|
77
79
|
rest = double("community-rest")
|
78
|
-
expect(CommunityREST).to receive(:new).with("http://artifactory/", {headers: {
|
80
|
+
expect(CommunityREST).to receive(:new).with("http://artifactory/", { ssl: {}, headers: { "X-Jfrog-Art-Api" => "secret" } }) { rest }
|
79
81
|
expect(rest).to receive(:download).with(name, version)
|
80
82
|
subject.try_download(source, name, version)
|
81
83
|
end
|
@@ -95,6 +97,7 @@ module Berkshelf
|
|
95
97
|
chef_server_url: chef_server_url,
|
96
98
|
validation_client_name: "validator",
|
97
99
|
validation_key: "validator.pem",
|
100
|
+
artifactory_api_key: "secret",
|
98
101
|
cookbook_copyright: "user",
|
99
102
|
cookbook_email: "user@example.com",
|
100
103
|
cookbook_license: "apachev2",
|
@@ -117,7 +120,7 @@ module Berkshelf
|
|
117
120
|
allow(subject).to receive(:ssl_policy).and_return(ssl_policy)
|
118
121
|
allow(remote_cookbook).to receive(:location_type) { :chef_server }
|
119
122
|
allow(remote_cookbook).to receive(:location_path) { chef_server_url }
|
120
|
-
allow(source).to receive(:options) { {read_timeout: 30, open_timeout: 3, ssl: {verify: true, cert_store: cert_store}} }
|
123
|
+
allow(source).to receive(:options) { { read_timeout: 30, open_timeout: 3, ssl: { verify: true, cert_store: cert_store } } }
|
121
124
|
end
|
122
125
|
|
123
126
|
it "uses the berkshelf config and provides a custom cert_store" do
|
@@ -136,7 +139,7 @@ module Berkshelf
|
|
136
139
|
|
137
140
|
context "with a source option for client_name" do
|
138
141
|
before do
|
139
|
-
allow(source).to receive(:options) { {client_name: "other-client", read_timeout: 30, open_timeout: 3, ssl: {verify: true, cert_store: cert_store}} }
|
142
|
+
allow(source).to receive(:options) { { client_name: "other-client", read_timeout: 30, open_timeout: 3, ssl: { verify: true, cert_store: cert_store } } }
|
140
143
|
end
|
141
144
|
it "uses the override" do
|
142
145
|
credentials = {
|
@@ -155,7 +158,7 @@ module Berkshelf
|
|
155
158
|
|
156
159
|
context "with a source option for client_key" do
|
157
160
|
before do
|
158
|
-
allow(source).to receive(:options) { {client_key: "other-key", read_timeout: 30, open_timeout: 3, ssl: {verify: true, cert_store: cert_store}} }
|
161
|
+
allow(source).to receive(:options) { { client_key: "other-key", read_timeout: 30, open_timeout: 3, ssl: { verify: true, cert_store: cert_store } } }
|
159
162
|
end
|
160
163
|
it "uses the override" do
|
161
164
|
credentials = {
|
@@ -6,7 +6,6 @@ describe Berkshelf::InitGenerator do
|
|
6
6
|
let(:kitchen_generator) { double("kitchen-generator", invoke_all: nil) }
|
7
7
|
|
8
8
|
before do
|
9
|
-
allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
|
10
9
|
FileUtils.mkdir_p(target)
|
11
10
|
File.open(File.join(target, "metadata.rb"), "w") do |f|
|
12
11
|
f.write("name 'some_cookbook'")
|
@@ -240,8 +240,8 @@ module Berkshelf
|
|
240
240
|
end
|
241
241
|
|
242
242
|
it "raises an error if the command fails" do
|
243
|
-
shell_out = double("shell_out",
|
244
|
-
allow(
|
243
|
+
shell_out = double("shell_out", error?: true, stderr: nil)
|
244
|
+
allow(subject).to receive(:shell_out).and_return(shell_out)
|
245
245
|
expect { subject.git("foo") }.to raise_error(GitCommandError)
|
246
246
|
end
|
247
247
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Berkshelf::Resolver::Graph, :not_supported_on_windows do
|
4
|
+
let(:berksfile) { double("Berksfile", filepath: "/test/Berksfile") }
|
4
5
|
subject { described_class.new }
|
5
6
|
|
6
7
|
describe "#populate" do
|
7
|
-
let(:sources) { Berkshelf::Source.new("http://localhost:26210") }
|
8
|
+
let(:sources) { Berkshelf::Source.new(berksfile, "http://localhost:26210") }
|
8
9
|
|
9
10
|
before do
|
10
11
|
berks_dependency("ruby", "1.0.0", dependencies: { "elixir" => ">= 0.1.0" })
|
@@ -24,7 +25,7 @@ describe Berkshelf::Resolver::Graph, :not_supported_on_windows do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
describe "#universe" do
|
27
|
-
let(:sources) { Berkshelf::Source.new("http://localhost:26210") }
|
28
|
+
let(:sources) { Berkshelf::Source.new(berksfile, "http://localhost:26210") }
|
28
29
|
|
29
30
|
before do
|
30
31
|
berks_dependency("ruby", "1.0.0")
|
@@ -2,9 +2,10 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Berkshelf
|
4
4
|
describe Source do
|
5
|
+
let(:berksfile) { double("Berksfile", filepath: "/test/Berksfile") }
|
5
6
|
let(:arguments) { [] }
|
6
7
|
let(:config) { Config.new }
|
7
|
-
subject(:instance) { described_class.new(*arguments) }
|
8
|
+
subject(:instance) { described_class.new(berksfile, *arguments) }
|
8
9
|
before do
|
9
10
|
allow(Berkshelf::Config).to receive(:instance).and_return(config)
|
10
11
|
end
|
@@ -13,12 +14,12 @@ module Berkshelf
|
|
13
14
|
subject { instance.type }
|
14
15
|
|
15
16
|
context "with a string argument" do
|
16
|
-
let(:arguments) { [
|
17
|
+
let(:arguments) { ["https://example.com"] }
|
17
18
|
it { is_expected.to eq :supermarket }
|
18
19
|
end
|
19
20
|
|
20
21
|
context "with a string argument and options" do
|
21
|
-
let(:arguments) { [
|
22
|
+
let(:arguments) { ["https://example.com", { key: "value" }] }
|
22
23
|
it { is_expected.to eq :supermarket }
|
23
24
|
end
|
24
25
|
|
@@ -28,22 +29,22 @@ module Berkshelf
|
|
28
29
|
end
|
29
30
|
|
30
31
|
context "with a symbol argument and options" do
|
31
|
-
let(:arguments) { [:chef_server, {key:
|
32
|
+
let(:arguments) { [:chef_server, { key: "value" }] }
|
32
33
|
it { is_expected.to eq :chef_server }
|
33
34
|
end
|
34
35
|
|
35
36
|
context "with a hash argument" do
|
36
|
-
let(:arguments) { [{artifactory:
|
37
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
|
37
38
|
it { is_expected.to eq :artifactory }
|
38
39
|
end
|
39
40
|
|
40
41
|
context "with a hash argument and connected options" do
|
41
|
-
let(:arguments) { [{artifactory:
|
42
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual", key: "value" }] }
|
42
43
|
it { is_expected.to eq :artifactory }
|
43
44
|
end
|
44
45
|
|
45
46
|
context "with a hash argument and disconnected options" do
|
46
|
-
let(:arguments) { [{artifactory:
|
47
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
|
47
48
|
it { is_expected.to eq :artifactory }
|
48
49
|
end
|
49
50
|
end
|
@@ -52,53 +53,58 @@ module Berkshelf
|
|
52
53
|
subject { instance.uri.to_s }
|
53
54
|
|
54
55
|
context "with a string argument" do
|
55
|
-
let(:arguments) { [
|
56
|
-
it { is_expected.to eq
|
56
|
+
let(:arguments) { ["https://example.com"] }
|
57
|
+
it { is_expected.to eq "https://example.com" }
|
57
58
|
end
|
58
59
|
|
59
60
|
context "with a string argument and options" do
|
60
|
-
let(:arguments) { [
|
61
|
-
it { is_expected.to eq
|
61
|
+
let(:arguments) { ["https://example.com", { key: "value" }] }
|
62
|
+
it { is_expected.to eq "https://example.com" }
|
62
63
|
end
|
63
64
|
|
64
65
|
context "with a symbol argument" do
|
65
66
|
let(:arguments) { [:chef_server] }
|
66
|
-
before { config.chef.chef_server_url =
|
67
|
-
it { is_expected.to eq
|
67
|
+
before { config.chef.chef_server_url = "https://chefserver/" }
|
68
|
+
it { is_expected.to eq "https://chefserver/" }
|
68
69
|
end
|
69
70
|
|
70
71
|
context "with a symbol argument and options" do
|
71
|
-
let(:arguments) { [:chef_server, {key:
|
72
|
-
before { config.chef.chef_server_url =
|
73
|
-
it { is_expected.to eq
|
72
|
+
let(:arguments) { [:chef_server, { key: "value" }] }
|
73
|
+
before { config.chef.chef_server_url = "https://chefserver/" }
|
74
|
+
it { is_expected.to eq "https://chefserver/" }
|
74
75
|
end
|
75
76
|
|
76
77
|
context "with a hash argument" do
|
77
|
-
let(:arguments) { [{artifactory:
|
78
|
-
it { is_expected.to eq
|
78
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
|
79
|
+
it { is_expected.to eq "https://example.com/api/chef/chef-virtual" }
|
79
80
|
end
|
80
81
|
|
81
82
|
context "with a hash argument and connected options" do
|
82
|
-
let(:arguments) { [{artifactory:
|
83
|
-
it { is_expected.to eq
|
83
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual", key: "value" }] }
|
84
|
+
it { is_expected.to eq "https://example.com/api/chef/chef-virtual" }
|
84
85
|
end
|
85
86
|
|
86
87
|
context "with a hash argument and disconnected options" do
|
87
|
-
let(:arguments) { [{artifactory:
|
88
|
-
it { is_expected.to eq
|
88
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
|
89
|
+
it { is_expected.to eq "https://example.com/api/chef/chef-virtual" }
|
89
90
|
end
|
90
91
|
|
91
92
|
context "with an invalid URI" do
|
92
|
-
let(:arguments) { [
|
93
|
+
let(:arguments) { ["ftp://example.com"] }
|
93
94
|
it { expect { subject }.to raise_error InvalidSourceURI }
|
94
95
|
end
|
96
|
+
|
97
|
+
context "with a chef_repo source" do
|
98
|
+
let(:arguments) { [{ chef_repo: "." }] }
|
99
|
+
it { is_expected.to eq(windows? ? "file://C/test" : "file:///test") }
|
100
|
+
end
|
95
101
|
end
|
96
102
|
|
97
103
|
describe "#options" do
|
98
104
|
subject { instance.options }
|
99
105
|
|
100
106
|
context "with a string argument" do
|
101
|
-
let(:arguments) { [
|
107
|
+
let(:arguments) { ["https://example.com"] }
|
102
108
|
|
103
109
|
it { is_expected.to be_a(Hash) }
|
104
110
|
# Check all baseline values.
|
@@ -113,8 +119,8 @@ module Berkshelf
|
|
113
119
|
end
|
114
120
|
|
115
121
|
context "with a string argument and options" do
|
116
|
-
let(:arguments) { [
|
117
|
-
its([:key]) { is_expected.to eq
|
122
|
+
let(:arguments) { ["https://example.com", { key: "value" }] }
|
123
|
+
its([:key]) { is_expected.to eq "value" }
|
118
124
|
end
|
119
125
|
|
120
126
|
context "with a symbol argument" do
|
@@ -123,43 +129,48 @@ module Berkshelf
|
|
123
129
|
end
|
124
130
|
|
125
131
|
context "with a symbol argument and options" do
|
126
|
-
let(:arguments) { [:chef_server, {key:
|
127
|
-
its([:key]) { is_expected.to eq
|
132
|
+
let(:arguments) { [:chef_server, { key: "value" }] }
|
133
|
+
its([:key]) { is_expected.to eq "value" }
|
128
134
|
end
|
129
135
|
|
130
136
|
context "with a hash argument" do
|
131
|
-
let(:arguments) { [{artifactory:
|
137
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
|
132
138
|
it { is_expected.to be_a(Hash) }
|
133
139
|
end
|
134
140
|
|
135
141
|
context "with a hash argument and connected options" do
|
136
|
-
let(:arguments) { [{artifactory:
|
137
|
-
its([:key]) { is_expected.to eq
|
142
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual", key: "value" }] }
|
143
|
+
its([:key]) { is_expected.to eq "value" }
|
138
144
|
end
|
139
145
|
|
140
146
|
context "with a hash argument and disconnected options" do
|
141
|
-
let(:arguments) { [{artifactory:
|
142
|
-
its([:key]) { is_expected.to eq
|
147
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }, { key: "value" }] }
|
148
|
+
its([:key]) { is_expected.to eq "value" }
|
143
149
|
end
|
144
150
|
|
145
151
|
context "with an artifactory source and the API key in the Chef config" do
|
146
|
-
let(:arguments) { [{artifactory:
|
147
|
-
before { config.chef.artifactory_api_key =
|
148
|
-
its([:api_key]) { is_expected.to eq
|
152
|
+
let(:arguments) { [{ artifactory: "https://example.com/api/chef/chef-virtual" }] }
|
153
|
+
before { config.chef.artifactory_api_key = "secret" }
|
154
|
+
its([:api_key]) { is_expected.to eq "secret" }
|
155
|
+
end
|
156
|
+
|
157
|
+
context "with a chef_repo source" do
|
158
|
+
let(:arguments) { [{ chef_repo: "." }] }
|
159
|
+
its([:path]) { is_expected.to eq(windows? ? "C:/test" : "/test") }
|
149
160
|
end
|
150
161
|
end
|
151
162
|
|
152
163
|
describe "#==" do
|
153
164
|
it "is the same if the uri matches" do
|
154
|
-
first = described_class.new("http://localhost:8080")
|
155
|
-
other = described_class.new("http://localhost:8080")
|
165
|
+
first = described_class.new(berksfile, "http://localhost:8080")
|
166
|
+
other = described_class.new(berksfile, "http://localhost:8080")
|
156
167
|
|
157
168
|
expect(first).to eq(other)
|
158
169
|
end
|
159
170
|
|
160
171
|
it "is not the same if the uri is different" do
|
161
|
-
first = described_class.new("http://localhost:8089")
|
162
|
-
other = described_class.new("http://localhost:8080")
|
172
|
+
first = described_class.new(berksfile, "http://localhost:8089")
|
173
|
+
other = described_class.new(berksfile, "http://localhost:8080")
|
163
174
|
|
164
175
|
expect(first).to_not eq(other)
|
165
176
|
end
|
@@ -167,17 +178,17 @@ module Berkshelf
|
|
167
178
|
|
168
179
|
describe ".default?" do
|
169
180
|
it "returns true when the source is the default" do
|
170
|
-
instance = described_class.new(Berksfile::DEFAULT_API_URL)
|
181
|
+
instance = described_class.new(berksfile, Berksfile::DEFAULT_API_URL)
|
171
182
|
expect(instance).to be_default
|
172
183
|
end
|
173
184
|
|
174
185
|
it "returns true when the scheme is different" do
|
175
|
-
instance = described_class.new("http://supermarket.chef.io")
|
186
|
+
instance = described_class.new(berksfile, "http://supermarket.chef.io")
|
176
187
|
expect(instance).to be_default
|
177
188
|
end
|
178
189
|
|
179
190
|
it "returns false when the source is not the default" do
|
180
|
-
instance = described_class.new("http://localhost:8080")
|
191
|
+
instance = described_class.new(berksfile, "http://localhost:8080")
|
181
192
|
expect(instance).to_not be_default
|
182
193
|
end
|
183
194
|
end
|
@@ -194,7 +205,7 @@ module Berkshelf
|
|
194
205
|
end
|
195
206
|
|
196
207
|
it "returns the latest version" do
|
197
|
-
instance = described_class.new(Berksfile::DEFAULT_API_URL)
|
208
|
+
instance = described_class.new(berksfile, Berksfile::DEFAULT_API_URL)
|
198
209
|
expect(instance.search("cb1")).to eq [cookbooks[1]]
|
199
210
|
end
|
200
211
|
end
|