berkshelf 7.0.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1fa6835af52a54149248c29a9e110b26bb8c5d479aec8095cca8ab252d3a3cd
4
- data.tar.gz: c75eee318205302ff8c69b2c70afffe6d665bd40f7306c44965e45163b26cd3b
3
+ metadata.gz: a1e2e961ef268a5163cfb0c489645bda19ad19f48d0f49654ca73f8a99a8046e
4
+ data.tar.gz: d09b8fa457809fb644500d4d5084f95003c8056789281e4fd7aae86f931d841c
5
5
  SHA512:
6
- metadata.gz: 31044607572e40f4d07e803fe86221f7fef2bc65beceba38bf082f6e3328072d983c6cac3734f28647b3a55f8aa29c3775ff9e7ca96aab34e5135d0c1b9c06a6
7
- data.tar.gz: ac687fc8c1f793260768542c6b9f00100051fd10d2306848598babf593b058a53aef91f0365849ff32e83e3bbb6e939f16894fa4a868f37a6879f6b75c22cd4c
6
+ metadata.gz: 22b933cdb39e71477f6159fd452c29b58042d5b2f6885f3d858767a5e7ef885eb12243a503c52e12e3253c93f8883a1335fd2ea7cd3eb87f00744b241e5bb643
7
+ data.tar.gz: 0c0261b36f52abdbee539f814c4491dab3246f509e9fe02f599272a50ed45788a92629feb6c2d1241459e5693635b41e42c6dc41e42ae4032e3b94e9f2ca5ae2
@@ -1,15 +1,16 @@
1
1
  GIT
2
2
  remote: https://github.com/chef/chef
3
- revision: 5ef14cc77226fe16b734ec90aead1de5d49ca7fb
3
+ revision: 39ff59de987a11efa8d4c9f803c79343b27c4b4a
4
4
  branch: master
5
5
  specs:
6
- chef (14.0.210)
6
+ chef (14.0.215)
7
7
  addressable
8
8
  bundler (>= 1.10)
9
- chef-config (= 14.0.210)
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.210)
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.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.23)
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.1)
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::APIClient
4
- require_relative "errors"
3
+ module Berkshelf
4
+ module APIClient
5
+ require_relative "errors"
5
6
 
6
- class ChefServerConnection
7
- attr_reader :client
7
+ class ChefServerConnection
8
+ attr_reader :client
8
9
 
9
- def initialize(*args)
10
- @client = Berkshelf::RidleyCompat.new(*args)
11
- @url = args[0][:server_url]
12
- end
10
+ def initialize(*args)
11
+ @client = Berkshelf::RidleyCompat.new(*args)
12
+ @url = args[0][:server_url]
13
+ end
13
14
 
14
- def universe
15
- response = client.get("universe")
15
+ def universe
16
+ response = client.get("universe")
16
17
 
17
- [].tap do |cookbooks|
18
- response.each do |name, versions|
19
- versions.each do |version, attributes|
20
- attributes[:location_path] = @url
21
- cookbooks << RemoteCookbook.new(name, version, attributes) end
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::APIClient
4
- require_relative "errors"
5
-
6
- class Connection
7
- # @return [String]
8
- attr_reader :url
9
-
10
- # @return [Integer]
11
- # how many retries to attempt on HTTP requests
12
- attr_reader :retries
13
-
14
- # @return [Float]
15
- # time to wait between retries
16
- attr_reader :retry_interval
17
-
18
- # @param [String, Addressable::URI] url
19
- #
20
- # @option options [Integer] :open_timeout (3)
21
- # how long to wait (in seconds) for connection open to the API server
22
- # @option options [Integer] :timeout (30)
23
- # how long to wait (in seconds) before getting a response from the API server
24
- # @option options [Integer] :retries (3)
25
- # how many retries to perform before giving up
26
- # @option options [Float] :retry_interval (0.5)
27
- # how long to wait (in seconds) between each retry
28
- def initialize(url, options = {})
29
- # it looks like Faraday mutates the URI argument it is given, when we ripped Faraday out of this
30
- # API it stopped doing that. this may or may not be a breaking change (it broke some fairly
31
- # brittle berkshelf tests). if it causes too much berkshelf chaos we could revert by uncommenting
32
- # the next line. as it is removing this behavior feels more like fixing a bug.
33
- #@url = url.normalize! if url.is_a?(Addressable::URI)
34
- options = { retries: 3, retry_interval: 0.5, open_timeout: 30, timeout: 30 }.merge(options)
35
- options[:server_url] = url
36
-
37
- @client = Berkshelf::RidleyCompatJSON.new(**options)
38
- end
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
- # Retrieves the entire universe of known cookbooks from the API source
41
- #
42
- # @raise [APIClient::TimeoutError]
43
- #
44
- # @return [Array<APIClient::RemoteCookbook>]
45
- def universe
46
- response = @client.get("universe")
47
-
48
- [].tap do |cookbooks|
49
- response.each do |name, versions|
50
- versions.each { |version, attributes| cookbooks << RemoteCookbook.new(name, version, attributes) }
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::APIClient
5
- # A representation of cookbook metadata indexed by a Berkshelf API Server. Returned
6
- # by sending messages to a {Berkshelf::APIClient} and used to download cookbooks
7
- # indexed by the Berkshelf API Server.
8
- class RemoteCookbook
9
- # @return [String]
10
- attr_reader :name
11
- # @return [String]
12
- attr_reader :version
13
-
14
- # @param [String] name
15
- # @param [String] version
16
- # @param [Hash] attributes
17
- def initialize(name, version, attributes = {})
18
- @name = name
19
- @version = version
20
- @attributes = ::Mash.new(attributes)
21
- end
22
-
23
- # @return [Hash]
24
- def dependencies
25
- @attributes[:dependencies]
26
- end
27
-
28
- # @return [Hash]
29
- def platforms
30
- @attributes[:platforms]
31
- end
32
-
33
- # @return [Symbol]
34
- def location_type
35
- @attributes[:location_type].to_sym
36
- end
37
-
38
- # @return [String]
39
- def location_path
40
- @attributes[:location_path]
41
- end
42
-
43
- def to_hash
44
- {
45
- name: name,
46
- version: version,
47
- }
48
- end
49
-
50
- def to_json(options = {})
51
- ::JSON.pretty_generate(to_hash, options)
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
@@ -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
@@ -162,7 +162,7 @@ module Berkshelf
162
162
  true
163
163
  end
164
164
 
165
- def compile_metadata
165
+ def compile_metadata(path = self.path)
166
166
  json_file = "#{path}/metadata.json"
167
167
  rb_file = "#{path}/metadata.rb"
168
168
  return nil if File.exist?(json_file)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "7.0.0"
2
+ VERSION = "7.0.1"
3
3
  end
@@ -1,99 +1,101 @@
1
1
  require "chef_zero/server"
2
2
  require "json"
3
3
 
4
- module Berkshelf::RSpec
5
- module ChefServer
6
- PORT = 4000
4
+ module Berkshelf
5
+ module RSpec
6
+ module ChefServer
7
+ PORT = 4000
7
8
 
8
- class << self
9
- attr_reader :server
9
+ class << self
10
+ attr_reader :server
10
11
 
11
- def clear_request_log
12
- @request_log = Array.new
13
- end
12
+ def clear_request_log
13
+ @request_log = Array.new
14
+ end
14
15
 
15
- def request_log
16
- @request_log ||= Array.new
17
- end
16
+ def request_log
17
+ @request_log ||= Array.new
18
+ end
18
19
 
19
- def server_url
20
- @server && @server.url
21
- end
20
+ def server_url
21
+ @server && @server.url
22
+ end
22
23
 
23
- def start(options = {})
24
- return @server if @server
24
+ def start(options = {})
25
+ return @server if @server
25
26
 
26
- options = { port: PORT }.merge(options)
27
- options[:generate_real_keys] = false
27
+ options = { port: PORT }.merge(options)
28
+ options[:generate_real_keys] = false
28
29
 
29
- @server = ChefZero::Server.new(options)
30
- @server.start_background
31
- @server.on_response do |request, response|
32
- request_log << [ request, response ]
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
- @server
37
- end
40
+ def stop
41
+ @server.stop if running?
42
+ end
38
43
 
39
- def stop
40
- @server.stop if running?
41
- end
44
+ def running?
45
+ @server && @server.running?
46
+ end
42
47
 
43
- def running?
44
- @server && @server.running?
48
+ def reset!
49
+ @server && @server.clear_data
50
+ end
45
51
  end
46
52
 
47
- def reset!
48
- @server && @server.clear_data
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
- def chef_client(name, hash = {})
57
- load_data(:clients, name, hash)
58
- end
57
+ def chef_client(name, hash = {})
58
+ load_data(:clients, name, hash)
59
+ end
59
60
 
60
- def chef_cookbook(name, hash = {})
61
- chef_server.load_data({ "cookbooks" => { name => hash } })
62
- end
61
+ def chef_cookbook(name, hash = {})
62
+ chef_server.load_data({ "cookbooks" => { name => hash } })
63
+ end
63
64
 
64
- def chef_cookbooks
65
- chef_server.data_store.list(%w{organizations chef cookbooks}).inject({}) do |hash, name|
66
- hash[name] = chef_server.data_store.list(["organizations", "chef", "cookbooks", name])
67
- hash
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
- def chef_data_bag(name, hash = {})
72
- chef_server.load_data({ "data" => { name => hash } })
73
- end
72
+ def chef_data_bag(name, hash = {})
73
+ chef_server.load_data({ "data" => { name => hash } })
74
+ end
74
75
 
75
- def chef_environment(name, hash = {})
76
- load_data(:environments, name, hash)
77
- end
76
+ def chef_environment(name, hash = {})
77
+ load_data(:environments, name, hash)
78
+ end
78
79
 
79
- def chef_environment_locks(name)
80
- JSON.parse(chef_server.data_store.get(["organizations", "chef", "environments", name]))["cookbook_versions"]
81
- rescue ChefZero::DataStore::DataNotFoundError
82
- {}
83
- end
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
- def chef_node(name, hash = {})
86
- load_data(:nodes, name, hash)
87
- end
86
+ def chef_node(name, hash = {})
87
+ load_data(:nodes, name, hash)
88
+ end
88
89
 
89
- def chef_role(name, hash = {})
90
- load_data(:roles, name, hash)
91
- end
90
+ def chef_role(name, hash = {})
91
+ load_data(:roles, name, hash)
92
+ end
92
93
 
93
- private
94
+ private
94
95
 
95
- def load_data(key, name, hash)
96
- chef_server.load_data({ key.to_s => { name => JSON.generate(hash) } })
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.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-04-24 00:00:00.000000000 Z
15
+ date: 2018-05-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout