berkshelf 7.0.0 → 7.0.1
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/Gemfile.lock +8 -7
- data/features/commands/vendor.feature +2 -0
- data/lib/berkshelf/api_client/chef_server_connection.rb +19 -17
- data/lib/berkshelf/api_client/connection.rb +49 -47
- data/lib/berkshelf/api_client/remote_cookbook.rb +50 -48
- data/lib/berkshelf/berksfile.rb +2 -4
- data/lib/berkshelf/cached_cookbook.rb +1 -1
- data/lib/berkshelf/config.rb +1 -20
- data/lib/berkshelf/version.rb +1 -1
- data/spec/support/chef_server.rb +70 -68
- data/spec/unit/berkshelf/config_spec.rb +10 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1e2e961ef268a5163cfb0c489645bda19ad19f48d0f49654ca73f8a99a8046e
|
4
|
+
data.tar.gz: d09b8fa457809fb644500d4d5084f95003c8056789281e4fd7aae86f931d841c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b933cdb39e71477f6159fd452c29b58042d5b2f6885f3d858767a5e7ef885eb12243a503c52e12e3253c93f8883a1335fd2ea7cd3eb87f00744b241e5bb643
|
7
|
+
data.tar.gz: 0c0261b36f52abdbee539f814c4491dab3246f509e9fe02f599272a50ed45788a92629feb6c2d1241459e5693635b41e42c6dc41e42ae4032e3b94e9f2ca5ae2
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/chef/chef
|
3
|
-
revision:
|
3
|
+
revision: 39ff59de987a11efa8d4c9f803c79343b27c4b4a
|
4
4
|
branch: master
|
5
5
|
specs:
|
6
|
-
chef (14.0.
|
6
|
+
chef (14.0.215)
|
7
7
|
addressable
|
8
8
|
bundler (>= 1.10)
|
9
|
-
chef-config (= 14.0.
|
9
|
+
chef-config (= 14.0.215)
|
10
10
|
chef-zero (>= 13.0)
|
11
11
|
diff-lcs (~> 1.2, >= 1.2.4)
|
12
12
|
erubis (~> 2.7)
|
13
|
+
ffi (< 1.9.22)
|
13
14
|
ffi-yajl (~> 2.2)
|
14
15
|
highline (~> 1.6, >= 1.6.9)
|
15
16
|
iniparse (~> 1.4)
|
@@ -33,7 +34,7 @@ GIT
|
|
33
34
|
specinfra (~> 2.10)
|
34
35
|
syslog-logger (~> 1.6)
|
35
36
|
uuidtools (~> 2.1.5)
|
36
|
-
chef-config (14.0.
|
37
|
+
chef-config (14.0.215)
|
37
38
|
addressable
|
38
39
|
fuzzyurl
|
39
40
|
mixlib-config (~> 2.0)
|
@@ -43,7 +44,7 @@ GIT
|
|
43
44
|
PATH
|
44
45
|
remote: .
|
45
46
|
specs:
|
46
|
-
berkshelf (7.0.
|
47
|
+
berkshelf (7.0.1)
|
47
48
|
chef (>= 13.6.52)
|
48
49
|
chef-config
|
49
50
|
cleanroom (~> 1.0)
|
@@ -120,7 +121,7 @@ GEM
|
|
120
121
|
multipart-post (>= 1.2, < 3)
|
121
122
|
faraday-http-cache (2.0.0)
|
122
123
|
faraday (~> 0.8)
|
123
|
-
ffi (1.9.
|
124
|
+
ffi (1.9.21)
|
124
125
|
ffi-yajl (2.3.1)
|
125
126
|
libyajl2 (~> 1.2)
|
126
127
|
fuubar (2.3.1)
|
@@ -156,7 +157,7 @@ GEM
|
|
156
157
|
libyajl2 (1.2.0)
|
157
158
|
minitar (0.6.1)
|
158
159
|
minitest (5.11.3)
|
159
|
-
mixlib-archive (0.4.
|
160
|
+
mixlib-archive (0.4.2)
|
160
161
|
mixlib-log
|
161
162
|
mixlib-authentication (2.0.0)
|
162
163
|
mixlib-cli (1.7.0)
|
@@ -150,3 +150,5 @@ Feature: Vendoring cookbooks to a directory
|
|
150
150
|
Then the directory "vendor/bacon" should contain version "1.0.0" of the "bacon" cookbook
|
151
151
|
And a file named "vendor/bacon/metadata.json" should exist
|
152
152
|
And a file named "vendor/bacon/metadata.rb" should exist
|
153
|
+
And a file named "bacon/metadata.rb" should exist
|
154
|
+
And a file named "bacon/metadata.json" should not exist
|
@@ -1,28 +1,30 @@
|
|
1
1
|
require "berkshelf/ridley_compat"
|
2
2
|
|
3
|
-
module Berkshelf
|
4
|
-
|
3
|
+
module Berkshelf
|
4
|
+
module APIClient
|
5
|
+
require_relative "errors"
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
class ChefServerConnection
|
8
|
+
attr_reader :client
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def initialize(*args)
|
11
|
+
@client = Berkshelf::RidleyCompat.new(*args)
|
12
|
+
@url = args[0][:server_url]
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def universe
|
16
|
+
response = client.get("universe")
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
[].tap do |cookbooks|
|
19
|
+
response.each do |name, versions|
|
20
|
+
versions.each do |version, attributes|
|
21
|
+
attributes[:location_path] = @url
|
22
|
+
cookbooks << RemoteCookbook.new(name, version, attributes) end
|
23
|
+
end
|
22
24
|
end
|
25
|
+
rescue Ridley::Errors::HTTPNotFound
|
26
|
+
raise ServiceNotFound, "service not found at: #{@url}"
|
23
27
|
end
|
24
|
-
rescue Ridley::Errors::HTTPNotFound
|
25
|
-
raise ServiceNotFound, "service not found at: #{@url}"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -1,53 +1,55 @@
|
|
1
1
|
require "berkshelf/ridley_compat"
|
2
2
|
|
3
|
-
module Berkshelf
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
3
|
+
module Berkshelf
|
4
|
+
module APIClient
|
5
|
+
require_relative "errors"
|
6
|
+
|
7
|
+
class Connection
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :url
|
10
|
+
|
11
|
+
# @return [Integer]
|
12
|
+
# how many retries to attempt on HTTP requests
|
13
|
+
attr_reader :retries
|
14
|
+
|
15
|
+
# @return [Float]
|
16
|
+
# time to wait between retries
|
17
|
+
attr_reader :retry_interval
|
18
|
+
|
19
|
+
# @param [String, Addressable::URI] url
|
20
|
+
#
|
21
|
+
# @option options [Integer] :open_timeout (3)
|
22
|
+
# how long to wait (in seconds) for connection open to the API server
|
23
|
+
# @option options [Integer] :timeout (30)
|
24
|
+
# how long to wait (in seconds) before getting a response from the API server
|
25
|
+
# @option options [Integer] :retries (3)
|
26
|
+
# how many retries to perform before giving up
|
27
|
+
# @option options [Float] :retry_interval (0.5)
|
28
|
+
# how long to wait (in seconds) between each retry
|
29
|
+
def initialize(url, options = {})
|
30
|
+
# it looks like Faraday mutates the URI argument it is given, when we ripped Faraday out of this
|
31
|
+
# API it stopped doing that. this may or may not be a breaking change (it broke some fairly
|
32
|
+
# brittle berkshelf tests). if it causes too much berkshelf chaos we could revert by uncommenting
|
33
|
+
# the next line. as it is removing this behavior feels more like fixing a bug.
|
34
|
+
#@url = url.normalize! if url.is_a?(Addressable::URI)
|
35
|
+
options = { retries: 3, retry_interval: 0.5, open_timeout: 30, timeout: 30 }.merge(options)
|
36
|
+
options[:server_url] = url
|
37
|
+
|
38
|
+
@client = Berkshelf::RidleyCompatJSON.new(**options)
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
# Retrieves the entire universe of known cookbooks from the API source
|
42
|
+
#
|
43
|
+
# @raise [APIClient::TimeoutError]
|
44
|
+
#
|
45
|
+
# @return [Array<APIClient::RemoteCookbook>]
|
46
|
+
def universe
|
47
|
+
response = @client.get("universe")
|
48
|
+
|
49
|
+
[].tap do |cookbooks|
|
50
|
+
response.each do |name, versions|
|
51
|
+
versions.each { |version, attributes| cookbooks << RemoteCookbook.new(name, version, attributes) }
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -1,54 +1,56 @@
|
|
1
1
|
require "json"
|
2
2
|
require "chef/mash"
|
3
3
|
|
4
|
-
module Berkshelf
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
4
|
+
module Berkshelf
|
5
|
+
module APIClient
|
6
|
+
# A representation of cookbook metadata indexed by a Berkshelf API Server. Returned
|
7
|
+
# by sending messages to a {Berkshelf::APIClient} and used to download cookbooks
|
8
|
+
# indexed by the Berkshelf API Server.
|
9
|
+
class RemoteCookbook
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :name
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :version
|
14
|
+
|
15
|
+
# @param [String] name
|
16
|
+
# @param [String] version
|
17
|
+
# @param [Hash] attributes
|
18
|
+
def initialize(name, version, attributes = {})
|
19
|
+
@name = name
|
20
|
+
@version = version
|
21
|
+
@attributes = ::Mash.new(attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Hash]
|
25
|
+
def dependencies
|
26
|
+
@attributes[:dependencies]
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Hash]
|
30
|
+
def platforms
|
31
|
+
@attributes[:platforms]
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Symbol]
|
35
|
+
def location_type
|
36
|
+
@attributes[:location_type].to_sym
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [String]
|
40
|
+
def location_path
|
41
|
+
@attributes[:location_path]
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_hash
|
45
|
+
{
|
46
|
+
name: name,
|
47
|
+
version: version,
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json(options = {})
|
52
|
+
::JSON.pretty_generate(to_hash, options)
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -636,10 +636,6 @@ module Berkshelf
|
|
636
636
|
cached_cookbooks.each do |cookbook|
|
637
637
|
Berkshelf.formatter.vendor(cookbook, destination)
|
638
638
|
|
639
|
-
# compile the metadata early before we do the file list
|
640
|
-
cookbook.compile_metadata
|
641
|
-
cookbook.reload
|
642
|
-
|
643
639
|
cookbook_destination = File.join(scratch, cookbook.cookbook_name)
|
644
640
|
FileUtils.mkdir_p(cookbook_destination)
|
645
641
|
|
@@ -666,6 +662,8 @@ module Berkshelf
|
|
666
662
|
FileUtils.mkdir_p( File.join(cookbook_destination, File.dirname(rpath)) )
|
667
663
|
FileUtils.cp( File.join(cookbook.path.to_s, rpath), File.join(cookbook_destination, rpath) )
|
668
664
|
end
|
665
|
+
|
666
|
+
cookbook.compile_metadata(cookbook_destination)
|
669
667
|
end
|
670
668
|
|
671
669
|
# Don't vendor the raw metadata (metadata.rb). The raw metadata is
|
data/lib/berkshelf/config.rb
CHANGED
@@ -40,23 +40,12 @@ module Berkshelf
|
|
40
40
|
@instance = nil
|
41
41
|
end
|
42
42
|
|
43
|
-
# @return [String, nil]
|
44
|
-
# the contents of the file
|
45
|
-
def file
|
46
|
-
File.read(path) if File.exist?(path)
|
47
|
-
end
|
48
|
-
|
49
43
|
# Instantiate and return or just return the currently instantiated Berkshelf
|
50
44
|
# configuration
|
51
45
|
#
|
52
46
|
# @return [Config]
|
53
47
|
def instance
|
54
|
-
@instance ||=
|
55
|
-
if file
|
56
|
-
from_json file
|
57
|
-
else
|
58
|
-
new
|
59
|
-
end
|
48
|
+
@instance ||= new(path)
|
60
49
|
coerce_ssl
|
61
50
|
end
|
62
51
|
|
@@ -82,14 +71,6 @@ module Berkshelf
|
|
82
71
|
def from_file(path)
|
83
72
|
new(path)
|
84
73
|
end
|
85
|
-
|
86
|
-
def from_json(json)
|
87
|
-
new.from_json(json)
|
88
|
-
end
|
89
|
-
|
90
|
-
def from_hash(hash)
|
91
|
-
new.from_hash(hash)
|
92
|
-
end
|
93
74
|
end
|
94
75
|
|
95
76
|
attr_accessor :path
|
data/lib/berkshelf/version.rb
CHANGED
data/spec/support/chef_server.rb
CHANGED
@@ -1,99 +1,101 @@
|
|
1
1
|
require "chef_zero/server"
|
2
2
|
require "json"
|
3
3
|
|
4
|
-
module Berkshelf
|
5
|
-
module
|
6
|
-
|
4
|
+
module Berkshelf
|
5
|
+
module RSpec
|
6
|
+
module ChefServer
|
7
|
+
PORT = 4000
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
class << self
|
10
|
+
attr_reader :server
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def clear_request_log
|
13
|
+
@request_log = Array.new
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def request_log
|
17
|
+
@request_log ||= Array.new
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def server_url
|
21
|
+
@server && @server.url
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
def start(options = {})
|
25
|
+
return @server if @server
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
options = { port: PORT }.merge(options)
|
28
|
+
options[:generate_real_keys] = false
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
@server = ChefZero::Server.new(options)
|
31
|
+
@server.start_background
|
32
|
+
@server.on_response do |request, response|
|
33
|
+
request_log << [ request, response ]
|
34
|
+
end
|
35
|
+
clear_request_log
|
36
|
+
|
37
|
+
@server
|
33
38
|
end
|
34
|
-
clear_request_log
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
def stop
|
41
|
+
@server.stop if running?
|
42
|
+
end
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
def running?
|
45
|
+
@server && @server.running?
|
46
|
+
end
|
42
47
|
|
43
|
-
|
44
|
-
|
48
|
+
def reset!
|
49
|
+
@server && @server.clear_data
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
|
-
def
|
48
|
-
|
53
|
+
def chef_server
|
54
|
+
ChefServer.server
|
49
55
|
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def chef_server
|
53
|
-
ChefServer.server
|
54
|
-
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def chef_client(name, hash = {})
|
58
|
+
load_data(:clients, name, hash)
|
59
|
+
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
def chef_cookbook(name, hash = {})
|
62
|
+
chef_server.load_data({ "cookbooks" => { name => hash } })
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
def chef_cookbooks
|
66
|
+
chef_server.data_store.list(%w{organizations chef cookbooks}).inject({}) do |hash, name|
|
67
|
+
hash[name] = chef_server.data_store.list(["organizations", "chef", "cookbooks", name])
|
68
|
+
hash
|
69
|
+
end
|
68
70
|
end
|
69
|
-
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
def chef_data_bag(name, hash = {})
|
73
|
+
chef_server.load_data({ "data" => { name => hash } })
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
def chef_environment(name, hash = {})
|
77
|
+
load_data(:environments, name, hash)
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
def chef_environment_locks(name)
|
81
|
+
JSON.parse(chef_server.data_store.get(["organizations", "chef", "environments", name]))["cookbook_versions"]
|
82
|
+
rescue ChefZero::DataStore::DataNotFoundError
|
83
|
+
{}
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
def chef_node(name, hash = {})
|
87
|
+
load_data(:nodes, name, hash)
|
88
|
+
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
def chef_role(name, hash = {})
|
91
|
+
load_data(:roles, name, hash)
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
+
private
|
94
95
|
|
95
|
-
|
96
|
-
|
96
|
+
def load_data(key, name, hash)
|
97
|
+
chef_server.load_data({ key.to_s => { name => JSON.generate(hash) } })
|
98
|
+
end
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
@@ -1,16 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Berkshelf::Config do
|
4
|
-
describe "::file" do
|
5
|
-
context "when the file does not exist" do
|
6
|
-
before { allow(File).to receive(:exist?).and_return(false) }
|
7
|
-
|
8
|
-
it "is nil" do
|
9
|
-
expect(Berkshelf::Config.file).to be_nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
4
|
describe "::instance" do
|
15
5
|
it "should be a Berkshelf::Config" do
|
16
6
|
expect(Berkshelf::Config.instance).to be_an_instance_of(Berkshelf::Config)
|
@@ -74,10 +64,6 @@ describe Berkshelf::Config do
|
|
74
64
|
expect(Berkshelf::Config.path).to be_a(String)
|
75
65
|
end
|
76
66
|
|
77
|
-
before do
|
78
|
-
allow(File).to receive(:exist?).and_return(false)
|
79
|
-
end
|
80
|
-
|
81
67
|
after do
|
82
68
|
Berkshelf::Config.instance_variable_set(:@path, nil)
|
83
69
|
end
|
@@ -92,6 +78,16 @@ describe Berkshelf::Config do
|
|
92
78
|
expect(Berkshelf::Config.path).to match(%r{/tmp/config.json})
|
93
79
|
end
|
94
80
|
end
|
81
|
+
|
82
|
+
it "reads json from a path" do
|
83
|
+
Tempfile.open(["berkstest", ".json"]) do |t|
|
84
|
+
t.write JSON.generate({ "ssl" => { "verify" => false } })
|
85
|
+
t.close
|
86
|
+
expect(Berkshelf::Config).to receive(:local_location).at_least(:once).and_return(t.path)
|
87
|
+
Berkshelf::Config.reload
|
88
|
+
expect( Berkshelf::Config.instance[:ssl][:verify] ).to be false
|
89
|
+
end
|
90
|
+
end
|
95
91
|
end
|
96
92
|
|
97
93
|
describe "::set_path" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-
|
15
|
+
date: 2018-05-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mixlib-shellout
|