berkshelf 0.4.0 → 0.5.0.rc1
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.
- data/berkshelf.gemspec +8 -3
- data/bin/berks +1 -1
- data/features/groups_install.feature +67 -0
- data/features/install.feature +1 -71
- data/features/json_formatter.feature +0 -17
- data/features/step_definitions/filesystem_steps.rb +1 -3
- data/features/update.feature +3 -6
- data/features/vendor_install.feature +20 -0
- data/generator_files/Vagrantfile.erb +25 -3
- data/lib/berkshelf.rb +27 -17
- data/lib/berkshelf/base_generator.rb +5 -0
- data/lib/berkshelf/berksfile.rb +82 -77
- data/lib/berkshelf/cli.rb +37 -26
- data/lib/berkshelf/cookbook_source.rb +14 -4
- data/lib/berkshelf/errors.rb +4 -1
- data/lib/berkshelf/formatters.rb +69 -5
- data/lib/berkshelf/formatters/human_readable.rb +26 -8
- data/lib/berkshelf/formatters/json.rb +51 -23
- data/lib/berkshelf/init_generator.rb +4 -4
- data/lib/berkshelf/location.rb +29 -6
- data/lib/berkshelf/locations/chef_api_location.rb +23 -5
- data/lib/berkshelf/locations/git_location.rb +13 -6
- data/lib/berkshelf/locations/path_location.rb +8 -4
- data/lib/berkshelf/locations/site_location.rb +9 -3
- data/lib/berkshelf/ui.rb +34 -0
- data/lib/berkshelf/uploader.rb +37 -103
- data/lib/berkshelf/vagrant.rb +65 -0
- data/lib/berkshelf/vagrant/action/clean.rb +24 -0
- data/lib/berkshelf/vagrant/action/install.rb +47 -0
- data/lib/berkshelf/vagrant/action/set_ui.rb +17 -0
- data/lib/berkshelf/vagrant/action/upload.rb +40 -0
- data/lib/berkshelf/vagrant/config.rb +70 -0
- data/lib/berkshelf/vagrant/middleware.rb +52 -0
- data/lib/berkshelf/version.rb +1 -1
- data/lib/thor/monkies.rb +3 -0
- data/lib/thor/monkies/hash_with_indifferent_access.rb +13 -0
- data/lib/vagrant_init.rb +2 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/chef_api.rb +6 -1
- data/spec/unit/berkshelf/berksfile_spec.rb +93 -55
- data/spec/unit/berkshelf/formatters_spec.rb +99 -1
- data/spec/unit/berkshelf/init_generator_spec.rb +1 -1
- data/spec/unit/berkshelf/location_spec.rb +44 -7
- data/spec/unit/berkshelf/lockfile_spec.rb +2 -2
- data/spec/unit/berkshelf/uploader_spec.rb +2 -20
- data/spec/unit/berkshelf_spec.rb +2 -2
- metadata +100 -14
- data/features/without.feature +0 -26
- data/lib/berkshelf/core_ext/fileutils.rb +0 -90
- data/lib/berkshelf/core_ext/kernel.rb +0 -33
- data/spec/unit/berkshelf/core_ext/fileutils_spec.rb +0 -20
data/features/without.feature
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
Feature: --without block
|
2
|
-
As a user
|
3
|
-
I want to be able to exclude blocks in my Berksfile
|
4
|
-
So I can have cookbooks organized for use in different situations in a single Berksfile
|
5
|
-
|
6
|
-
@slow_process
|
7
|
-
Scenario: Exclude a block
|
8
|
-
Given I write to "Berksfile" with:
|
9
|
-
"""
|
10
|
-
group :notme do
|
11
|
-
cookbook "nginx", "= 0.101.2"
|
12
|
-
end
|
13
|
-
|
14
|
-
cookbook "mysql", "= 1.2.4"
|
15
|
-
|
16
|
-
group :takeme do
|
17
|
-
cookbook "ntp", "= 1.1.8"
|
18
|
-
end
|
19
|
-
"""
|
20
|
-
When I run the install command with flags:
|
21
|
-
| --without notme |
|
22
|
-
Then the cookbook store should have the cookbooks:
|
23
|
-
| mysql | 1.2.4 |
|
24
|
-
| ntp | 1.1.8 |
|
25
|
-
And the cookbook store should not have the cookbooks:
|
26
|
-
| nginx | 0.101.2 |
|
@@ -1,90 +0,0 @@
|
|
1
|
-
module FileUtils
|
2
|
-
# @note taken from proposed FileUtils feature:
|
3
|
-
# @note {http://redmine.ruby-lang.org/issues/show/4189}
|
4
|
-
# @note {https://github.com/ruby/ruby/pull/4}
|
5
|
-
#
|
6
|
-
# Options: noop verbose dereference_root force
|
7
|
-
#
|
8
|
-
# Hard link +src+ to +dest+. If +src+ is a directory, this method links
|
9
|
-
# all its contents recursively. If +dest+ is a directory, links
|
10
|
-
# +src+ to +dest/src+.
|
11
|
-
#
|
12
|
-
# +src+ can be a list of files.
|
13
|
-
#
|
14
|
-
# # Installing ruby library "mylib" under the site_ruby
|
15
|
-
# FileUtils.rm_r site_ruby + '/mylib', :force
|
16
|
-
# FileUtils.ln_r 'lib/', site_ruby + '/mylib'
|
17
|
-
#
|
18
|
-
# # Examples of copying several files to target directory.
|
19
|
-
# FileUtils.ln_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
20
|
-
# FileUtils.ln_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
|
21
|
-
#
|
22
|
-
# # If you want to copy all contents of a directory instead of the
|
23
|
-
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
24
|
-
# # use following code.
|
25
|
-
# FileUtils.ln_r 'src/.', 'dest' # cp_r('src', 'dest') makes src/dest,
|
26
|
-
# # but this doesn't.
|
27
|
-
def ln_r(src, dest, options = {})
|
28
|
-
fu_check_options options, OPT_TABLE['ln_r']
|
29
|
-
fu_output_message "ln -r#{options[:force] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
30
|
-
return if options[:noop]
|
31
|
-
options = options.dup
|
32
|
-
options[:dereference_root] = true unless options.key?(:dereference_root)
|
33
|
-
fu_each_src_dest(src, dest) do |s, d|
|
34
|
-
link_entry s, d, options[:dereference_root], options[:force]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
module_function :ln_r
|
38
|
-
|
39
|
-
OPT_TABLE['ln_r'] = [:noop, :verbose, :dereference_root, :force]
|
40
|
-
|
41
|
-
#
|
42
|
-
# Hard links a file system entry +src+ to +dest+.
|
43
|
-
# If +src+ is a directory, this method links its contents recursively.
|
44
|
-
#
|
45
|
-
# Both of +src+ and +dest+ must be a path name.
|
46
|
-
# +src+ must exist, +dest+ must not exist.
|
47
|
-
#
|
48
|
-
# If +dereference_root+ is true, this method dereference tree root.
|
49
|
-
#
|
50
|
-
# If +force+ is true, this method removes each destination file before copy.
|
51
|
-
#
|
52
|
-
def link_entry(src, dest, dereference_root = false, force = false)
|
53
|
-
Entry_.new(src, nil, dereference_root).traverse do |ent|
|
54
|
-
destent = Entry_.new(dest, ent.rel, false)
|
55
|
-
File.unlink destent.path if force && File.file?(destent.path)
|
56
|
-
ent.link destent.path
|
57
|
-
end
|
58
|
-
end
|
59
|
-
module_function :link_entry
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
class Entry_ #:nodoc:
|
64
|
-
def link(dest)
|
65
|
-
case
|
66
|
-
when broken_symlink?
|
67
|
-
warn "#{path} is a broken symlink. No link created."
|
68
|
-
when directory?
|
69
|
-
if !File.exist?(dest) and descendant_diretory?(dest, path)
|
70
|
-
raise ArgumentError, "cannot link directory %s to itself %s" % [path, dest]
|
71
|
-
end
|
72
|
-
begin
|
73
|
-
Dir.mkdir dest
|
74
|
-
rescue
|
75
|
-
raise unless File.directory?(dest)
|
76
|
-
end
|
77
|
-
else
|
78
|
-
File.link path(), dest
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Check if the file at path is a broken symlink
|
83
|
-
#
|
84
|
-
# @return [Boolean]
|
85
|
-
def broken_symlink?
|
86
|
-
File.symlink?(path) && !File.exists?(File.readlink(path))
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# From ActiveSupport: https://github.com/rails/rails/blob/c2c8ef57d6f00d1c22743dc43746f95704d67a95/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L39
|
2
|
-
|
3
|
-
require 'rbconfig'
|
4
|
-
|
5
|
-
module Kernel
|
6
|
-
# Silences any stream for the duration of the block.
|
7
|
-
#
|
8
|
-
# silence_stream(STDOUT) do
|
9
|
-
# puts 'This will never be seen'
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# puts 'But this will'
|
13
|
-
def silence_stream(stream)
|
14
|
-
old_stream = stream.dup
|
15
|
-
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
16
|
-
stream.sync = true
|
17
|
-
yield
|
18
|
-
ensure
|
19
|
-
stream.reopen(old_stream)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Silences both STDOUT and STDERR, even for subprocesses.
|
23
|
-
#
|
24
|
-
# quietly { system 'bundle install' }
|
25
|
-
#
|
26
|
-
def quietly
|
27
|
-
silence_stream(STDOUT) do
|
28
|
-
silence_stream(STDERR) do
|
29
|
-
yield
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Berkshelf
|
4
|
-
describe FileUtils do
|
5
|
-
describe '#ln_r' do
|
6
|
-
it "should skip broken symlinks during traversal" do
|
7
|
-
Dir.mktmpdir do |dir|
|
8
|
-
path = Pathname.new(File.join(dir, 'ln_r_test'))
|
9
|
-
Dir.mkdir(path)
|
10
|
-
Dir.chdir(path) do
|
11
|
-
File.open('original', 'w') {}
|
12
|
-
File.symlink('original', 'link_to_original')
|
13
|
-
FileUtils.rm('original')
|
14
|
-
end
|
15
|
-
-> { FileUtils.ln_r(path, File.join(dir, 'link_to_dir')) }.should_not raise_error
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|