berkshelf 3.2.0 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be55c4c1bb887daab19c58ef3a4f2f905af29033
4
- data.tar.gz: f0d4402fa9850c728b51ba239fec76de438fef1f
3
+ metadata.gz: bf7c3d3ea8e0b023a45bc50f25be258b223b309d
4
+ data.tar.gz: 3ec8c78126055e0185a1ebdf580d09876d420f3a
5
5
  SHA512:
6
- metadata.gz: fe6cbe54f7acb7d5cdae6cced81df057585c0b8efba3fe532d7fd72ef7f28449f1a05a7859c977acf39f01090a0ec34da5ff3416ced45a9dd8df552aa7c126d7
7
- data.tar.gz: 5d92e870bcac605248af9bfc0d7c5c8b827d63ea11014c7a95ff66177fcb6d67ec056f94d2605d22064a38f251ffa725799ecaf3ff202b7611dcaf3a15b2e955
6
+ metadata.gz: c086ee08241ace4cc037cb88d86bd76afb102f5a8fb8edfa9af20616e236a2ef6899a08f787c407cee1a282cf026c994c0860a6e7187b375384c082979597aff
7
+ data.tar.gz: 19e8906d4b3971d28f1505dc2296fc1de85a7fb2013c5f47145c397d2fe5950f4b0cb021c6c5deffb8e017c36404e7a8daad3c99410d32371c4c8c5fe990e291
@@ -1,5 +1,11 @@
1
1
  > This is a high level digest of changes. For the complete CHANGELOG diff two tags in the project's [commit history](https://github.com/berkshelf/berkshelf/commits/master).
2
2
 
3
+ # 3.2.1
4
+
5
+ * Bug Fixes
6
+ * Fix issue with copying raw metadata when vendoring / packaging.
7
+ * Berkshelf should cleanup any temporary directories it creates. There is still work to be done in any of Berkshelf's dependencies.
8
+
3
9
  # 3.2.0
4
10
 
5
11
  * Improvements
@@ -8,7 +8,6 @@ require 'ridley'
8
8
  require 'semverse'
9
9
  require 'solve'
10
10
  require 'thor'
11
- require 'tmpdir'
12
11
  require 'uri'
13
12
  require 'celluloid'
14
13
 
@@ -105,20 +104,6 @@ module Berkshelf
105
104
  end
106
105
  end
107
106
 
108
- # @return [String]
109
- def tmp_dir
110
- File.join(berkshelf_path, 'tmp')
111
- end
112
-
113
- # Creates a temporary directory within the Berkshelf path
114
- #
115
- # @return [String]
116
- # path to the created temporary directory
117
- def mktmpdir
118
- FileUtils.mkdir_p(tmp_dir)
119
- Dir.mktmpdir(nil, tmp_dir)
120
- end
121
-
122
107
  # @return [Berkshelf::CookbookStore]
123
108
  def cookbook_store
124
109
  CookbookStore.instance
@@ -574,48 +574,49 @@ module Berkshelf
574
574
  # @return [String, nil]
575
575
  # the expanded path cookbooks were vendored to or nil if nothing was vendored
576
576
  def vendor(destination)
577
- scratch = Berkshelf.mktmpdir
578
- chefignore = nil
579
- cached_cookbooks = install
577
+ Dir.mktmpdir do |scratch|
578
+ chefignore = nil
579
+ cached_cookbooks = install
580
580
 
581
- return nil if cached_cookbooks.empty?
581
+ return nil if cached_cookbooks.empty?
582
582
 
583
- cached_cookbooks.each do |cookbook|
584
- Berkshelf.formatter.vendor(cookbook, destination)
585
- cookbook_destination = File.join(scratch, cookbook.cookbook_name)
586
- FileUtils.mkdir_p(cookbook_destination)
583
+ cached_cookbooks.each do |cookbook|
584
+ Berkshelf.formatter.vendor(cookbook, destination)
585
+ cookbook_destination = File.join(scratch, cookbook.cookbook_name)
586
+ FileUtils.mkdir_p(cookbook_destination)
587
587
 
588
- # Dir.glob does not support backslash as a File separator
589
- src = cookbook.path.to_s.gsub('\\', '/')
590
- files = FileSyncer.glob(File.join(src, '*'))
588
+ # Dir.glob does not support backslash as a File separator
589
+ src = cookbook.path.to_s.gsub('\\', '/')
590
+ files = FileSyncer.glob(File.join(src, '*'))
591
591
 
592
- chefignore = Ridley::Chef::Chefignore.new(cookbook.path.to_s) rescue nil
593
- chefignore.apply!(files) if chefignore
592
+ chefignore = Ridley::Chef::Chefignore.new(cookbook.path.to_s) rescue nil
593
+ chefignore.apply!(files) if chefignore
594
594
 
595
- unless cookbook.compiled_metadata?
596
- cookbook.compile_metadata(cookbook_destination)
595
+ unless cookbook.compiled_metadata?
596
+ cookbook.compile_metadata(cookbook_destination)
597
+ end
598
+
599
+ FileUtils.cp_r(files, cookbook_destination)
597
600
  end
598
601
 
599
- FileUtils.cp_r(files, cookbook_destination)
602
+ # Don't vendor the raw metadata (metadata.rb). The raw metadata is
603
+ # unecessary for the client, and this is required until compiled metadata
604
+ # (metadata.json) takes precedence over raw metadata in the Chef-Client.
605
+ #
606
+ # We can change back to including the raw metadata in the future after
607
+ # this has been fixed or just remove these comments. There is no
608
+ # circumstance that I can currently think of where raw metadata should
609
+ # ever be read by the client.
610
+ #
611
+ # - Jamie
612
+ #
613
+ # See the following tickets for more information:
614
+ #
615
+ # * https://tickets.opscode.com/browse/CHEF-4811
616
+ # * https://tickets.opscode.com/browse/CHEF-4810
617
+ FileSyncer.sync(scratch, destination, exclude: ['**/metadata.rb'])
600
618
  end
601
619
 
602
- # Don't vendor the raw metadata (metadata.rb). The raw metadata is
603
- # unecessary for the client, and this is required until compiled metadata
604
- # (metadata.json) takes precedence over raw metadata in the Chef-Client.
605
- #
606
- # We can change back to including the raw metadata in the future after
607
- # this has been fixed or just remove these comments. There is no
608
- # circumstance that I can currently think of where raw metadata should
609
- # ever be read by the client.
610
- #
611
- # - Jamie
612
- #
613
- # See the following tickets for more information:
614
- #
615
- # * https://tickets.opscode.com/browse/CHEF-4811
616
- # * https://tickets.opscode.com/browse/CHEF-4810
617
- FileSyncer.sync(scratch, destination, exclude: ["**/*/metadata.rb"])
618
-
619
620
  destination
620
621
  end
621
622
 
@@ -10,7 +10,7 @@ module Berkshelf
10
10
  # file path to extract the contents of the target to
11
11
  #
12
12
  # @return [String]
13
- def unpack(target, destination = Dir.mktmpdir)
13
+ def unpack(target, destination)
14
14
  if is_gzip_file(target)
15
15
  Archive::Tar::Minitar.unpack(Zlib::GzipReader.new(File.open(target, 'rb')), destination)
16
16
  elsif is_tar_file(target)
@@ -18,6 +18,7 @@ module Berkshelf
18
18
  else
19
19
  raise Berkshelf::UnknownCompressionType.new(target)
20
20
  end
21
+
21
22
  FileUtils.rm_rf Dir.glob("#{destination}/**/PaxHeader")
22
23
  destination
23
24
  end
@@ -100,7 +101,8 @@ module Berkshelf
100
101
  # cookbook filepath, or nil if archive does not contain a cookbook
101
102
  def download(name, version)
102
103
  archive = stream(find(name, version)[:file])
103
- extracted = self.class.unpack(archive.path)
104
+ scratch = Dir.mktmpdir
105
+ extracted = self.class.unpack(archive.path, scratch)
104
106
 
105
107
  if File.cookbook?(extracted)
106
108
  extracted
@@ -15,7 +15,10 @@ module Berkshelf
15
15
  @berksfile = berksfile
16
16
  end
17
17
 
18
- # Download the given Berkshelf::Dependency.
18
+ # Download the given Berkshelf::Dependency. If the optional block is given,
19
+ # the temporary path to the cookbook is yielded and automatically deleted
20
+ # when the block returns. If no block is given, it is the responsibility of
21
+ # the caller to remove the tmpdir.
19
22
  #
20
23
  # @param [String] name
21
24
  # @param [String] version
@@ -25,12 +28,18 @@ module Berkshelf
25
28
  # @raise [CookbookNotFound]
26
29
  #
27
30
  # @return [String]
28
- def download(*args)
31
+ def download(*args, &block)
29
32
  options = args.last.is_a?(Hash) ? args.pop : Hash.new
30
33
  dependency, version = args
31
34
 
32
35
  sources.each do |source|
33
36
  if result = try_download(source, dependency, version)
37
+ if block_given?
38
+ value = yield result
39
+ FileUtils.rm_rf(result)
40
+ return value
41
+ end
42
+
34
43
  return result
35
44
  end
36
45
  end
@@ -102,8 +102,9 @@ module Berkshelf
102
102
 
103
103
  Berkshelf.formatter.install(source, cookbook)
104
104
 
105
- stash = downloader.download(name, version)
106
- CookbookStore.import(name, version, stash)
105
+ downloader.download(name, version) do |stash|
106
+ CookbookStore.import(name, version, stash)
107
+ end
107
108
  end
108
109
  end
109
110
  end
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "3.2.0"
2
+ VERSION = "3.2.1"
3
3
  end
@@ -78,6 +78,7 @@ describe Berkshelf::CommunityREST do
78
78
  before do
79
79
  allow(subject).to receive(:stream).with(any_args()).and_return(archive)
80
80
  allow(Berkshelf::CommunityREST).to receive(:unpack)
81
+ .and_return('/some/path')
81
82
  end
82
83
 
83
84
  it 'unpacks the archive' do
@@ -87,7 +88,10 @@ describe Berkshelf::CommunityREST do
87
88
  headers: { 'Content-Type' => 'application/json' },
88
89
  )
89
90
 
90
- expect(Berkshelf::CommunityREST).to receive(:unpack).with('/foo/bar').once.and_return('/foo/nginx')
91
+ expect(Berkshelf::CommunityREST).to receive(:unpack)
92
+ .with('/foo/bar', String)
93
+ .and_return('/foo/nginx')
94
+ .once
91
95
  expect(archive).to receive(:unlink).once
92
96
 
93
97
  subject.download('bacon', '1.0.0')
@@ -1,17 +1,30 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Berkshelf::CookbookGenerator do
4
- let(:name) { 'sparkle_motion' }
4
+ let(:name) { 'sparkle_motion' }
5
+ let(:license) { 'reserved' }
6
+ let(:maintainer) { 'Berkshelf Core' }
7
+ let(:maintainer_email) { 'core@berkshelf.com' }
8
+
5
9
  let(:target) { tmp_path.join(name) }
6
10
  let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
7
11
 
8
12
  before do
9
- allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
13
+ allow(Kitchen::Generator::Init)
14
+ .to receive(:new)
15
+ .with(any_args())
16
+ .and_return(kitchen_generator)
10
17
  end
11
18
 
12
19
  context 'with default options' do
13
20
  before do
14
- capture(:stdout) { Berkshelf::CookbookGenerator.new([target, name]).invoke_all }
21
+ capture(:stdout) do
22
+ Berkshelf::CookbookGenerator.new([target, name],
23
+ license: license,
24
+ maintainer: maintainer,
25
+ maintainer_email: maintainer_email,
26
+ ).invoke_all
27
+ end
15
28
  end
16
29
 
17
30
  it "generates a new cookbook" do
@@ -26,7 +39,7 @@ describe Berkshelf::CookbookGenerator do
26
39
  file 'default.rb' do
27
40
  contains '# Cookbook Name:: sparkle_motion'
28
41
  contains '# Recipe:: default'
29
- contains "# Copyright (C) #{Time.now.year} YOUR_NAME"
42
+ contains "# Copyright (C) #{Time.now.year} Berkshelf Core"
30
43
  contains '# All rights reserved - Do Not Redistribute'
31
44
  end
32
45
  end
@@ -35,7 +48,7 @@ describe Berkshelf::CookbookGenerator do
35
48
  directory 'default'
36
49
  end
37
50
  file 'LICENSE' do
38
- contains "Copyright (C) #{Time.now.year} YOUR_NAME"
51
+ contains "Copyright (C) #{Time.now.year} Berkshelf Core"
39
52
  contains 'All rights reserved - Do Not Redistribute'
40
53
  end
41
54
  file 'README.md' do
@@ -44,7 +57,7 @@ describe Berkshelf::CookbookGenerator do
44
57
  contains " <td><tt>['sparkle_motion']['bacon']</tt></td>"
45
58
  contains "Include `sparkle_motion` in your node's `run_list`:"
46
59
  contains ' "recipe[sparkle_motion::default]"'
47
- contains 'Author:: YOUR_NAME (<YOUR_EMAIL>)'
60
+ contains 'Author:: Berkshelf Core (<core@berkshelf.com>)'
48
61
  end
49
62
  file 'CHANGELOG.md' do
50
63
  contains '# 0.1.0'
@@ -52,8 +65,8 @@ describe Berkshelf::CookbookGenerator do
52
65
  end
53
66
  file 'metadata.rb' do
54
67
  contains "name 'sparkle_motion'"
55
- contains "maintainer 'YOUR_NAME'"
56
- contains "maintainer_email 'YOUR_EMAIL'"
68
+ contains "maintainer 'Berkshelf Core'"
69
+ contains "maintainer_email 'core@berkshelf.com'"
57
70
  contains "license 'All rights reserved'"
58
71
  contains "description 'Installs/Configures sparkle_motion'"
59
72
  end
@@ -180,6 +180,19 @@ module Berkshelf
180
180
  expect("#{destination}/.file_g").to be_a_file
181
181
  end
182
182
 
183
+ it 'does not copy files and folder matching a pattern with a wildcard' do
184
+ described_class.sync(source, destination, exclude: '**/file_e')
185
+
186
+ expect("#{destination}/file_a").to be_a_file
187
+ expect("#{destination}/file_b").to be_a_file
188
+ expect("#{destination}/file_c").to be_a_file
189
+ expect("#{destination}/folder/file_d").to be_a_file
190
+ expect("#{destination}/folder/file_e").to_not be_a_file
191
+ expect("#{destination}/.dot_folder").to be_a_directory
192
+ expect("#{destination}/.dot_folder/file_f").to be_a_file
193
+ expect("#{destination}/.file_g").to be_a_file
194
+ end
195
+
183
196
  it 'removes existing files and folders in destination' do
184
197
  FileUtils.mkdir_p("#{destination}/existing_folder")
185
198
  FileUtils.touch("#{destination}/existing_file")
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: 3.2.0
4
+ version: 3.2.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: 2014-10-29 00:00:00.000000000 Z
15
+ date: 2014-11-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable