cookbook-omnifetch 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cookbook-omnifetch.rb +4 -0
- data/lib/cookbook-omnifetch/chef_server.rb +12 -1
- data/lib/cookbook-omnifetch/chef_server_artifact.rb +13 -2
- data/lib/cookbook-omnifetch/integration.rb +5 -0
- data/lib/cookbook-omnifetch/version.rb +1 -1
- data/spec/unit/chef_server_artifact_spec.rb +39 -3
- data/spec/unit/chef_server_spec.rb +37 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43c39456987fef3b32d9b037565804e5293bd8ed
|
4
|
+
data.tar.gz: 776b3865d04123606bdafb1f4f7c7412b993724b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dea15259b08c5de8a97f111c103f9f8a54d6ad6499806c4659b9870f6b73fb587a57b1297d1fb52faa146904b643e698f18572c393f7fd2c334b3f71484d9b2
|
7
|
+
data.tar.gz: 1005b451253f385241b319c7601f7bb2594502c712d7583f0c92761836acdda45dde4a027aafd303d6a730fa344ece4fb8276bcad1fbec58d6b2d07bda6d5e14
|
data/lib/cookbook-omnifetch.rb
CHANGED
@@ -124,6 +124,10 @@ module CookbookOmnifetch
|
|
124
124
|
integration.chef_server_download_concurrency
|
125
125
|
end
|
126
126
|
|
127
|
+
def self.default_chef_server_http_client
|
128
|
+
integration.default_chef_server_http_client
|
129
|
+
end
|
130
|
+
|
127
131
|
# Returns true or false if the given path contains a Chef Cookbook
|
128
132
|
#
|
129
133
|
# @param [#to_s] path
|
@@ -10,7 +10,7 @@ module CookbookOmnifetch
|
|
10
10
|
def initialize(dependency, options = {})
|
11
11
|
super
|
12
12
|
@cookbook_version = options[:version]
|
13
|
-
@http_client = options[:http_client]
|
13
|
+
@http_client = options[:http_client] || default_chef_server_http_client
|
14
14
|
@uri ||= options[:chef_server]
|
15
15
|
end
|
16
16
|
|
@@ -57,5 +57,16 @@ module CookbookOmnifetch
|
|
57
57
|
"#{dependency.name}-#{cookbook_version}"
|
58
58
|
end
|
59
59
|
|
60
|
+
# @see BaseLocation#cached_cookbook
|
61
|
+
def cached_cookbook
|
62
|
+
@cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path(install_path)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def default_chef_server_http_client
|
68
|
+
CookbookOmnifetch.default_chef_server_http_client
|
69
|
+
end
|
70
|
+
|
60
71
|
end
|
61
72
|
end
|
@@ -17,7 +17,7 @@ module CookbookOmnifetch
|
|
17
17
|
def initialize(dependency, options = {})
|
18
18
|
super
|
19
19
|
@cookbook_identifier = options[:identifier]
|
20
|
-
@http_client = options[:http_client]
|
20
|
+
@http_client = options[:http_client] || default_chef_server_http_client
|
21
21
|
@uri ||= options[:chef_server_artifact]
|
22
22
|
end
|
23
23
|
|
@@ -61,12 +61,23 @@ module CookbookOmnifetch
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def lock_data
|
64
|
-
{ "
|
64
|
+
{ "chef_server_artifact" => uri, "identifier" => cookbook_identifier }
|
65
65
|
end
|
66
66
|
|
67
67
|
def cache_key
|
68
68
|
"#{dependency.name}-#{cookbook_identifier}"
|
69
69
|
end
|
70
70
|
|
71
|
+
# @see BaseLocation#cached_cookbook
|
72
|
+
def cached_cookbook
|
73
|
+
@cached_cookbook ||= CookbookOmnifetch.cached_cookbook_class.from_path(install_path)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def default_chef_server_http_client
|
79
|
+
CookbookOmnifetch.default_chef_server_http_client
|
80
|
+
end
|
81
|
+
|
71
82
|
end
|
72
83
|
end
|
@@ -39,6 +39,11 @@ module CookbookOmnifetch
|
|
39
39
|
# commentary in cookbook_omnifetch.rb
|
40
40
|
configurable :chef_server_download_concurrency
|
41
41
|
|
42
|
+
# HTTP client object that will be used for source option `http_client` by
|
43
|
+
# `ChefServerLocation` and `ChefServerArtifactLocation` if not explicitly
|
44
|
+
# passed
|
45
|
+
configurable :default_chef_server_http_client
|
46
|
+
|
42
47
|
def initialize
|
43
48
|
self.class.configurables.each do |configurable|
|
44
49
|
instance_variable_set("@#{configurable}".to_sym, NullValue.new)
|
@@ -21,6 +21,8 @@ RSpec.describe CookbookOmnifetch::ChefServerArtifactLocation do
|
|
21
21
|
|
22
22
|
let(:expected_cache_key) { "example-467dc855408ce8b74f991c5dc2fd72a6aa369b60" }
|
23
23
|
|
24
|
+
let(:expected_install_path) { File.join(storage_path, expected_cache_key) }
|
25
|
+
|
24
26
|
subject(:chef_server_artifact_location) { described_class.new(dependency, options) }
|
25
27
|
|
26
28
|
before do
|
@@ -40,7 +42,7 @@ RSpec.describe CookbookOmnifetch::ChefServerArtifactLocation do
|
|
40
42
|
expect(installer).to be_a(CookbookOmnifetch::MetadataBasedInstaller)
|
41
43
|
expect(installer.http_client).to eq(http_client)
|
42
44
|
expect(installer.url_path).to eq("/cookbook_artifacts/example/467dc855408ce8b74f991c5dc2fd72a6aa369b60")
|
43
|
-
expect(installer.install_path.to_s).to eq(
|
45
|
+
expect(installer.install_path.to_s).to eq(expected_install_path)
|
44
46
|
end
|
45
47
|
|
46
48
|
it "has a cache key containing the site URI and version" do
|
@@ -53,12 +55,46 @@ RSpec.describe CookbookOmnifetch::ChefServerArtifactLocation do
|
|
53
55
|
|
54
56
|
it "provides lock data as a Hash" do
|
55
57
|
expected_data = {
|
56
|
-
"
|
57
|
-
"
|
58
|
+
"chef_server_artifact" => url,
|
59
|
+
"identifier" => cookbook_identifier,
|
58
60
|
}
|
59
61
|
expect(chef_server_artifact_location.lock_data).to eq(expected_data)
|
60
62
|
end
|
61
63
|
|
64
|
+
it "returns a cached cookbook object" do
|
65
|
+
expect(MockCachedCookbook).to receive(:from_path).with(Pathname.new(expected_install_path))
|
66
|
+
chef_server_artifact_location.cached_cookbook
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when using the default chef server HTTP client" do
|
70
|
+
|
71
|
+
let(:options) { { chef_server_artifact: url, identifier: cookbook_identifier } }
|
72
|
+
|
73
|
+
let(:default_http_client) { double("Http Client") }
|
74
|
+
|
75
|
+
before do
|
76
|
+
CookbookOmnifetch.integration.default_chef_server_http_client = default_http_client
|
77
|
+
end
|
78
|
+
|
79
|
+
after do
|
80
|
+
CookbookOmnifetch.integration.default_chef_server_http_client = nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it "uses the default http client for requests" do
|
84
|
+
expect(chef_server_artifact_location.http_client).to eq(default_http_client)
|
85
|
+
end
|
86
|
+
|
87
|
+
context "and an http client is explicitly passed" do
|
88
|
+
|
89
|
+
let(:options) { { chef_server: url, identifier: cookbook_identifier, http_client: http_client } }
|
90
|
+
|
91
|
+
it "uses the explicitly passed client instead of the default" do
|
92
|
+
expect(chef_server_artifact_location.http_client).to eq(http_client)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
62
98
|
describe "when installing" do
|
63
99
|
|
64
100
|
let(:installer) { instance_double("CookbookOmnifetch::MetadataBasedInstaller") }
|
@@ -19,6 +19,8 @@ RSpec.describe CookbookOmnifetch::ChefServerLocation do
|
|
19
19
|
|
20
20
|
let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
|
21
21
|
|
22
|
+
let(:expected_install_path) { File.join(storage_path, "example-0.5.0") }
|
23
|
+
|
22
24
|
subject(:chef_server_location) { described_class.new(dependency, options) }
|
23
25
|
|
24
26
|
before do
|
@@ -38,7 +40,7 @@ RSpec.describe CookbookOmnifetch::ChefServerLocation do
|
|
38
40
|
expect(installer).to be_a(CookbookOmnifetch::MetadataBasedInstaller)
|
39
41
|
expect(installer.http_client).to eq(http_client)
|
40
42
|
expect(installer.url_path).to eq("/cookbooks/example/0.5.0")
|
41
|
-
expect(installer.install_path.to_s).to eq(
|
43
|
+
expect(installer.install_path.to_s).to eq(expected_install_path)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "has a cache key containing the site URI and version" do
|
@@ -57,6 +59,40 @@ RSpec.describe CookbookOmnifetch::ChefServerLocation do
|
|
57
59
|
expect(chef_server_location.lock_data).to eq(expected_data)
|
58
60
|
end
|
59
61
|
|
62
|
+
it "returns a cached cookbook object" do
|
63
|
+
expect(MockCachedCookbook).to receive(:from_path).with(Pathname.new(expected_install_path))
|
64
|
+
chef_server_location.cached_cookbook
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when using the default chef server HTTP client" do
|
68
|
+
|
69
|
+
let(:options) { { chef_server_artifact: url, version: cookbook_version } }
|
70
|
+
|
71
|
+
let(:default_http_client) { double("Http Client") }
|
72
|
+
|
73
|
+
before do
|
74
|
+
CookbookOmnifetch.integration.default_chef_server_http_client = default_http_client
|
75
|
+
end
|
76
|
+
|
77
|
+
after do
|
78
|
+
CookbookOmnifetch.integration.default_chef_server_http_client = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
it "uses the default http client for requests" do
|
82
|
+
expect(chef_server_location.http_client).to eq(default_http_client)
|
83
|
+
end
|
84
|
+
|
85
|
+
context "and an http client is explicitly passed" do
|
86
|
+
|
87
|
+
let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
|
88
|
+
|
89
|
+
it "uses the explicitly passed client instead of the default" do
|
90
|
+
expect(chef_server_location.http_client).to eq(http_client)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
60
96
|
describe "when installing" do
|
61
97
|
|
62
98
|
let(:installer) { instance_double("CookbookOmnifetch::MetadataBasedInstaller") }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookbook-omnifetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2017-11-
|
16
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: mixlib-archive
|