cookbook-omnifetch 0.4.0 → 0.5.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 +1 -1
- data/lib/cookbook-omnifetch/chef_server.rb +7 -2
- data/lib/cookbook-omnifetch/version.rb +1 -1
- data/spec/unit/chef_server_spec.rb +25 -2
- 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: cbe64ce071a948e6ca39a7108ddcda0f4553468d
|
4
|
+
data.tar.gz: 95cd67b5df43e5455b2043fb3580729536f0657b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7566665f88a9b007bdfe46cfddca79c5180020940653ce3876f1a1307c6dcb27a39d4afddd78eee0e71178d7572e6b941466c7b72430226967c9f5be3e3dece8
|
7
|
+
data.tar.gz: 2219631bec691166948b54add95c5b52164e1f1c6d8b974ab9dae9586616385f7fa420d49300cdbac8100e96582b49fb20531b533d82a83b01176c7bf1cf1f7c
|
data/lib/cookbook-omnifetch.rb
CHANGED
@@ -124,7 +124,7 @@ module CookbookOmnifetch
|
|
124
124
|
# @return [Class, nil]
|
125
125
|
def klass_from_options(options)
|
126
126
|
options.each do |key, _|
|
127
|
-
id = key.to_s.capitalize
|
127
|
+
id = key.to_s.split("_").map(&:capitalize).join
|
128
128
|
|
129
129
|
begin
|
130
130
|
return CookbookOmnifetch.const_get("#{id}Location")
|
@@ -30,15 +30,16 @@ module CookbookOmnifetch
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
class
|
33
|
+
class ChefServerLocation < BaseLocation
|
34
34
|
|
35
35
|
attr_reader :cookbook_version
|
36
|
+
attr_reader :uri
|
36
37
|
|
37
38
|
def initialize(dependency, options = {})
|
38
39
|
super
|
39
40
|
@cookbook_version = options[:version]
|
40
41
|
@http_client = options[:http_client]
|
41
|
-
@uri ||= options[:
|
42
|
+
@uri ||= options[:chef_server]
|
42
43
|
end
|
43
44
|
|
44
45
|
def repo_host
|
@@ -83,6 +84,10 @@ module CookbookOmnifetch
|
|
83
84
|
@install_path ||= CookbookOmnifetch.storage_path.join(cache_key)
|
84
85
|
end
|
85
86
|
|
87
|
+
def lock_data
|
88
|
+
{ "chef_server" => uri, "version" => cookbook_version }
|
89
|
+
end
|
90
|
+
|
86
91
|
def cache_key
|
87
92
|
"#{dependency.name}-#{cookbook_version}"
|
88
93
|
end
|
@@ -19,7 +19,7 @@ module CookbookOmnifetch
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
22
|
+
describe ChefServerLocation do
|
23
23
|
|
24
24
|
let(:http_client) { double("Http Client") }
|
25
25
|
|
@@ -38,10 +38,12 @@ module CookbookOmnifetch
|
|
38
38
|
let(:cookbook_name) { "example" }
|
39
39
|
let(:cookbook_version) { "0.5.0" }
|
40
40
|
|
41
|
+
let(:url) { "https://chef.example.com/organizations/example" }
|
42
|
+
|
41
43
|
let(:cookbook_fixture_path) { fixtures_path.join("cookbooks/example_cookbook") }
|
42
44
|
|
43
45
|
let(:remote_path) { File.join(test_root, "remote") }
|
44
|
-
let(:options) { { version: cookbook_version, http_client: http_client } }
|
46
|
+
let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
|
45
47
|
|
46
48
|
let(:cookbook_files) { %w{. .. metadata.rb recipes} }
|
47
49
|
subject(:chef_server_location) { described_class.new(dependency, options) }
|
@@ -58,6 +60,18 @@ module CookbookOmnifetch
|
|
58
60
|
FileUtils.rm_r(test_root)
|
59
61
|
end
|
60
62
|
|
63
|
+
it "has a URI" do
|
64
|
+
expect(chef_server_location.uri).to eq(url)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "has a cache key containing the site URI and version" do
|
68
|
+
expect(chef_server_location.cache_key).to eq("example-0.5.0")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "has an exact version" do
|
72
|
+
expect(chef_server_location.cookbook_version).to eq("0.5.0")
|
73
|
+
end
|
74
|
+
|
61
75
|
it "installs the cookbook to the desired install path" do
|
62
76
|
expect(http_client).to receive(:get).with("/cookbooks/example/0.5.0").and_return(METADATA)
|
63
77
|
expect(http_client).to receive(:streaming_request).twice do |url, &block|
|
@@ -71,5 +85,14 @@ module CookbookOmnifetch
|
|
71
85
|
expect(Dir).to exist(chef_server_location.install_path)
|
72
86
|
expect(Dir.entries(chef_server_location.install_path)).to match_array(cookbook_files)
|
73
87
|
end
|
88
|
+
|
89
|
+
it "provides lock data as a Hash" do
|
90
|
+
expected_data = {
|
91
|
+
"chef_server" => url,
|
92
|
+
"version" => "0.5.0",
|
93
|
+
}
|
94
|
+
expect(chef_server_location.lock_data).to eq(expected_data)
|
95
|
+
end
|
96
|
+
|
74
97
|
end
|
75
98
|
end
|
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.5.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-01-
|
16
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: mixlib-archive
|