berkshelf 3.0.0.beta2 → 3.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +0 -1
- data/Guardfile +0 -4
- data/README.md +1 -1
- data/Thorfile +2 -11
- data/berkshelf.gemspec +2 -5
- data/features/berksfile.feature +2 -10
- data/features/commands/apply.feature +31 -0
- data/features/{configure_command.feature → commands/configure.feature} +9 -11
- data/features/{contingent_command.feature → commands/contingent.feature} +10 -20
- data/features/{cookbook_command.feature → commands/cookbook.feature} +4 -11
- data/features/{init_command.feature → commands/init.feature} +10 -19
- data/features/{install_command.feature → commands/install.feature} +161 -82
- data/features/{list_command.feature → commands/list.feature} +4 -14
- data/features/{outdated_command.feature → commands/outdated.feature} +21 -63
- data/features/{package_command.feature → commands/package.feature} +11 -22
- data/features/{shelf → commands/shelf}/list.feature +3 -8
- data/features/{shelf → commands/shelf}/show.feature +5 -9
- data/features/{shelf → commands/shelf}/uninstall.feature +6 -10
- data/features/{show_command.feature → commands/show.feature} +13 -38
- data/features/commands/update.feature +48 -0
- data/features/commands/upload.feature +197 -0
- data/features/commands/vendor.feature +53 -0
- data/features/community_site.feature +39 -0
- data/features/config.feature +79 -9
- data/features/help.feature +10 -19
- data/features/json_formatter.feature +19 -44
- data/features/licenses.feature +27 -61
- data/features/lockfile.feature +120 -354
- data/features/resolver.feature +28 -0
- data/features/step_definitions/berksfile_steps.rb +39 -0
- data/features/step_definitions/chef/config_steps.rb +1 -1
- data/features/step_definitions/chef_server_steps.rb +27 -27
- data/features/step_definitions/config_steps.rb +3 -0
- data/features/step_definitions/filesystem_steps.rb +10 -0
- data/features/step_definitions/json_steps.rb +0 -7
- data/features/step_definitions/lockfile_steps.rb +53 -0
- data/features/step_definitions/utility_steps.rb +4 -4
- data/features/support/env.rb +1 -0
- data/generator_files/Berksfile.erb +1 -1
- data/generator_files/README.md.erb +62 -6
- data/generator_files/Vagrantfile.erb +15 -4
- data/lib/berkshelf.rb +2 -4
- data/lib/berkshelf/api_client.rb +5 -7
- data/lib/berkshelf/berksfile.rb +24 -20
- data/lib/berkshelf/cached_cookbook.rb +8 -1
- data/lib/berkshelf/cli.rb +5 -10
- data/lib/berkshelf/community_rest.rb +4 -5
- data/lib/berkshelf/config.rb +8 -2
- data/lib/berkshelf/cookbook_store.rb +9 -14
- data/lib/berkshelf/dependency.rb +16 -13
- data/lib/berkshelf/errors.rb +15 -1
- data/lib/berkshelf/formatters/json.rb +1 -1
- data/lib/berkshelf/init_generator.rb +17 -3
- data/lib/berkshelf/installer.rb +12 -1
- data/lib/berkshelf/logger.rb +7 -4
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/spec/spec_helper.rb +0 -9
- data/spec/support/chef_server.rb +24 -7
- data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +3 -3
- data/spec/unit/berkshelf/berksfile_spec.rb +35 -1
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +8 -0
- data/spec/unit/berkshelf/community_rest_spec.rb +76 -25
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +9 -3
- data/spec/unit/berkshelf/dependency_spec.rb +16 -1
- data/spec/unit/berkshelf/init_generator_spec.rb +71 -7
- metadata +44 -116
- data/.cane +0 -4
- data/features/apply_command.feature +0 -40
- data/features/groups_install.feature +0 -113
- data/features/update_command.feature +0 -136
- data/features/upload_command.feature +0 -327
- data/features/vendor_command.feature +0 -83
- data/lib/berkshelf/chef.rb +0 -7
- data/lib/berkshelf/chef/cookbook.rb +0 -5
- data/lib/berkshelf/chef/cookbook/chefignore.rb +0 -75
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_download/unpacks_the_archive.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/returns_the_cookbook_and_version_information.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/returns_the_version_number_of_the_latest_version_of_the_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_satisfy/returns_the_version_number_of_the_best_solution.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/returns_an_array_containing_an_item_for_each_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +0 -3694
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_source_as_sources.yml +0 -3829
- data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +0 -19
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -23,7 +23,7 @@ module Berkshelf
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
DEFAULT_API_URL = "
|
26
|
+
DEFAULT_API_URL = "https://api.berkshelf.com".freeze
|
27
27
|
|
28
28
|
include Berkshelf::Mixin::Logging
|
29
29
|
include Berkshelf::Mixin::DSLEval
|
@@ -135,21 +135,21 @@ module Berkshelf
|
|
135
135
|
# in a second source would not be used.
|
136
136
|
#
|
137
137
|
# @example
|
138
|
-
# source "
|
139
|
-
# source "
|
138
|
+
# source "https://api.berkshelf.com"
|
139
|
+
# source "https://berks-api.riotgames.com"
|
140
140
|
#
|
141
141
|
# @param [String] api_url
|
142
142
|
# url for the api to add
|
143
143
|
#
|
144
144
|
# @raise [Berkshelf::InvalidSourceURI]
|
145
145
|
#
|
146
|
-
# @return [Array<
|
146
|
+
# @return [Array<Berkshelf::Source>]
|
147
147
|
def source(api_url)
|
148
148
|
new_source = Source.new(api_url)
|
149
149
|
@sources.push(new_source) unless @sources.include?(new_source)
|
150
150
|
end
|
151
151
|
|
152
|
-
# @return [Array<
|
152
|
+
# @return [Array<Berkshelf::Source>]
|
153
153
|
def sources
|
154
154
|
@sources.empty? ? self.class.default_sources : @sources
|
155
155
|
end
|
@@ -342,7 +342,7 @@ module Berkshelf
|
|
342
342
|
# Names of the cookbooks to retrieve dependencies for
|
343
343
|
#
|
344
344
|
# @raise [Berkshelf::OutdatedDependency]
|
345
|
-
# if the lockfile constraints do not satisfy the
|
345
|
+
# if the lockfile constraints do not satisfy the Berksfile constraints
|
346
346
|
#
|
347
347
|
# @return [Array<Berkshelf::CachedCookbook>]
|
348
348
|
def install(options = {})
|
@@ -468,6 +468,10 @@ module Berkshelf
|
|
468
468
|
# on the remote Chef Server and frozen.
|
469
469
|
# @option options [String] :server_url
|
470
470
|
# An overriding Chef Server to upload the cookbooks to
|
471
|
+
# @option options [String] :client_name
|
472
|
+
# An overriding client name to use for connecting to the chef server
|
473
|
+
# @option options [String] :client_key
|
474
|
+
# An overriding client key to use for connecting to the chef server
|
471
475
|
#
|
472
476
|
# @raise [Berkshelf::UploadFailure]
|
473
477
|
# if you are uploading cookbooks with an invalid or not-specified client key
|
@@ -565,10 +569,10 @@ module Berkshelf
|
|
565
569
|
FileUtils.cp_r(path, destination)
|
566
570
|
|
567
571
|
unless options[:ignore_chefignore]
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
end
|
572
|
+
chefignore = Ridley::Chef::Chefignore.new(destination) rescue nil
|
573
|
+
Dir["#{destination}/**/*"].each do |path|
|
574
|
+
FileUtils.rm_rf(path) if chefignore.ignored?(path)
|
575
|
+
end if chefignore
|
572
576
|
end
|
573
577
|
end
|
574
578
|
|
@@ -612,13 +616,7 @@ module Berkshelf
|
|
612
616
|
chefignore = nil
|
613
617
|
cached_cookbooks = install(options.slice(:except, :only))
|
614
618
|
|
615
|
-
if cached_cookbooks.empty?
|
616
|
-
return nil
|
617
|
-
end
|
618
|
-
|
619
|
-
if ignore_file = Berkshelf::Chef::Cookbook::Chefignore.find_relative_to(Dir.pwd)
|
620
|
-
chefignore = Berkshelf::Chef::Cookbook::Chefignore.new(ignore_file)
|
621
|
-
end
|
619
|
+
return nil if cached_cookbooks.empty?
|
622
620
|
|
623
621
|
cached_cookbooks.each do |cookbook|
|
624
622
|
Berkshelf.formatter.vendor(cookbook, destination)
|
@@ -634,6 +632,11 @@ module Berkshelf
|
|
634
632
|
end
|
635
633
|
|
636
634
|
FileUtils.cp_r(files, cookbook_destination)
|
635
|
+
|
636
|
+
chefignore = Ridley::Chef::Chefignore.new(destination) rescue nil
|
637
|
+
Dir["#{cookbook_destination}/**/*"].each do |path|
|
638
|
+
FileUtils.rm_rf(path) if chefignore.ignored?(path)
|
639
|
+
end if chefignore
|
637
640
|
end
|
638
641
|
|
639
642
|
FileUtils.mv(scratch, destination)
|
@@ -713,10 +716,11 @@ module Berkshelf
|
|
713
716
|
# @raise [Berkshelf::ChefConnectionError]
|
714
717
|
def ridley_connection(options = {}, &block)
|
715
718
|
ridley_options = options.slice(:ssl)
|
719
|
+
|
716
720
|
ridley_options[:server_url] = options[:server_url] || Berkshelf.config.chef.chef_server_url
|
717
|
-
ridley_options[:client_name] = Berkshelf.config.chef.node_name
|
718
|
-
ridley_options[:client_key] = Berkshelf.config.chef.client_key
|
719
|
-
ridley_options[:ssl] = { verify: (options[:ssl_verify]
|
721
|
+
ridley_options[:client_name] = options[:client_name] || Berkshelf.config.chef.node_name
|
722
|
+
ridley_options[:client_key] = options[:client_key] || Berkshelf.config.chef.client_key
|
723
|
+
ridley_options[:ssl] = { verify: (options[:ssl_verify].nil?) ? Berkshelf.config.ssl.verify : options[:ssl_verify]}
|
720
724
|
|
721
725
|
unless ridley_options[:server_url].present?
|
722
726
|
raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.server_url'
|
@@ -12,8 +12,15 @@ module Berkshelf
|
|
12
12
|
cached_name = File.basename(path.to_s).slice(DIRNAME_REGEXP, 1)
|
13
13
|
return nil if cached_name.nil?
|
14
14
|
|
15
|
-
from_path(path, name: cached_name)
|
15
|
+
loaded_cookbooks[path.to_s] ||= from_path(path, name: cached_name)
|
16
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [Hash<String, CachedCookbook>]
|
21
|
+
def loaded_cookbooks
|
22
|
+
@loaded_cookbooks ||= {}
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
DIRNAME_REGEXP = /^(.+)-(.+)$/
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -40,12 +40,12 @@ module Berkshelf
|
|
40
40
|
|
41
41
|
class << self
|
42
42
|
def dispatch(meth, given_args, given_opts, config)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
if given_args.length > 1 && !(given_args & Thor::HELP_MAPPINGS).empty?
|
44
|
+
command = given_args.first
|
45
|
+
|
46
|
+
if self.subcommands.include?(command)
|
47
|
+
super(meth, [command, 'help'].compact, nil, config)
|
47
48
|
else
|
48
|
-
command = given_args.first
|
49
49
|
super(meth, ['help', command].compact, nil, config)
|
50
50
|
end
|
51
51
|
else
|
@@ -308,11 +308,6 @@ module Berkshelf
|
|
308
308
|
Berkshelf.formatter.deprecation '--git is now the default' if options[:git]
|
309
309
|
Berkshelf.formatter.deprecation '--vagrant is now the default' if options[:vagrant]
|
310
310
|
|
311
|
-
if File.chef_cookbook?(path)
|
312
|
-
options[:chefignore] = true
|
313
|
-
options[:metadata_entry] = true
|
314
|
-
end
|
315
|
-
|
316
311
|
Berkshelf::InitGenerator.new([path], options).invoke_all
|
317
312
|
|
318
313
|
Berkshelf.formatter.msg 'Successfully initialized'
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'retryable'
|
3
|
-
require 'addressable/uri'
|
4
3
|
|
5
4
|
module Berkshelf
|
6
5
|
class CommunityREST < Faraday::Connection
|
@@ -49,7 +48,7 @@ module Berkshelf
|
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
V1_API = '
|
51
|
+
V1_API = 'https://cookbooks.opscode.com/api/v1'.freeze
|
53
52
|
|
54
53
|
# @return [String]
|
55
54
|
attr_reader :api_uri
|
@@ -69,11 +68,11 @@ module Berkshelf
|
|
69
68
|
# how often we should pause between retries
|
70
69
|
def initialize(uri = V1_API, options = {})
|
71
70
|
options = options.reverse_merge(retries: 5, retry_interval: 0.5)
|
72
|
-
@api_uri =
|
71
|
+
@api_uri = uri
|
73
72
|
@retries = options[:retries]
|
74
73
|
@retry_interval = options[:retry_interval]
|
75
74
|
|
76
|
-
builder
|
75
|
+
options[:builder] ||= Faraday::Builder.new do |b|
|
77
76
|
b.response :parse_json
|
78
77
|
b.response :gzip
|
79
78
|
b.request :retry,
|
@@ -84,7 +83,7 @@ module Berkshelf
|
|
84
83
|
b.adapter :net_http
|
85
84
|
end
|
86
85
|
|
87
|
-
super(api_uri,
|
86
|
+
super(api_uri, options)
|
88
87
|
end
|
89
88
|
|
90
89
|
# @param [String] name
|
data/lib/berkshelf/config.rb
CHANGED
@@ -95,11 +95,11 @@ module Berkshelf
|
|
95
95
|
default: false
|
96
96
|
attribute 'vagrant.vm.box',
|
97
97
|
type: String,
|
98
|
-
default: '
|
98
|
+
default: 'opscode_ubuntu-12.04_provisionerless',
|
99
99
|
required: true
|
100
100
|
attribute 'vagrant.vm.box_url',
|
101
101
|
type: String,
|
102
|
-
default: 'https://
|
102
|
+
default: 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box',
|
103
103
|
required: true
|
104
104
|
attribute 'vagrant.vm.forward_port',
|
105
105
|
type: Hash,
|
@@ -113,6 +113,12 @@ module Berkshelf
|
|
113
113
|
attribute 'vagrant.vm.provision',
|
114
114
|
type: String,
|
115
115
|
default: 'chef_solo'
|
116
|
+
attribute 'vagrant.omnibus.enabled',
|
117
|
+
type: Boolean,
|
118
|
+
default: true
|
119
|
+
attribute 'vagrant.omnibus.version',
|
120
|
+
type: String,
|
121
|
+
default: 'latest'
|
116
122
|
attribute 'ssl.verify',
|
117
123
|
type: Boolean,
|
118
124
|
default: true,
|
@@ -89,25 +89,20 @@ module Berkshelf
|
|
89
89
|
# Returns an array of the Cookbooks that have been cached to the
|
90
90
|
# storage_path of this instance of CookbookStore.
|
91
91
|
#
|
92
|
-
# @param [String] filter
|
92
|
+
# @param [String, Regexp] filter
|
93
93
|
# return only the CachedCookbooks whose name match the given filter
|
94
94
|
#
|
95
95
|
# @return [Array<Berkshelf::CachedCookbook>]
|
96
96
|
def cookbooks(filter = nil)
|
97
|
-
cookbooks =
|
97
|
+
cookbooks = storage_path.children.collect do |path|
|
98
|
+
CachedCookbook.from_store_path(path)
|
99
|
+
end.compact
|
98
100
|
|
99
|
-
|
100
|
-
Celluloid::Future.new do
|
101
|
-
cached_cookbook = CachedCookbook.from_store_path(path)
|
101
|
+
return cookbooks unless filter
|
102
102
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
cookbooks << cached_cookbook
|
107
|
-
end
|
108
|
-
end.each(&:value)
|
109
|
-
|
110
|
-
cookbooks
|
103
|
+
cookbooks.select do |cookbook|
|
104
|
+
filter === cookbook.cookbook_name
|
105
|
+
end
|
111
106
|
end
|
112
107
|
|
113
108
|
# Returns an expanded path to the location on disk where the Cookbook
|
@@ -141,7 +136,7 @@ module Berkshelf
|
|
141
136
|
graph = Solve::Graph.new
|
142
137
|
cookbooks(name).each { |cookbook| graph.artifacts(name, cookbook.version) }
|
143
138
|
|
144
|
-
name, version = Solve.it!(graph, [[name, constraint]]).first
|
139
|
+
name, version = Solve.it!(graph, [[name, constraint]], ENV['DEBUG_RESOLVER'] ? { ui: Berkshelf.ui } : {}).first
|
145
140
|
|
146
141
|
cookbook(name, version)
|
147
142
|
rescue Solve::Errors::NoSolutionError
|
data/lib/berkshelf/dependency.rb
CHANGED
@@ -76,6 +76,8 @@ module Berkshelf
|
|
76
76
|
attr_reader :groups
|
77
77
|
# @return [Berkshelf::Location]
|
78
78
|
attr_reader :location
|
79
|
+
# @return [Solve::Version]
|
80
|
+
attr_accessor :locked_version
|
79
81
|
# @return [Solve::Constraint]
|
80
82
|
attr_accessor :version_constraint
|
81
83
|
# @return [Berkshelf::CachedCookbook]
|
@@ -139,7 +141,11 @@ module Berkshelf
|
|
139
141
|
@cached_cookbook ||= if location
|
140
142
|
location.download
|
141
143
|
else
|
142
|
-
|
144
|
+
if locked_version
|
145
|
+
CookbookStore.instance.cookbook(name, locked_version)
|
146
|
+
else
|
147
|
+
Berkshelf::CookbookStore.instance.satisfy(name, version_constraint)
|
148
|
+
end
|
143
149
|
end
|
144
150
|
end
|
145
151
|
|
@@ -163,18 +169,6 @@ module Berkshelf
|
|
163
169
|
groups.include?(group.to_sym)
|
164
170
|
end
|
165
171
|
|
166
|
-
# Get the locked version of this cookbook. First check the instance variable
|
167
|
-
# and then resort to the cached_cookbook for the version.
|
168
|
-
#
|
169
|
-
# This was formerly a delegator, but it would fail if the `@cached_cookbook`
|
170
|
-
# was nil or undefined.
|
171
|
-
#
|
172
|
-
# @return [Solve::Version, nil]
|
173
|
-
# the locked version of this cookbook
|
174
|
-
def locked_version
|
175
|
-
@locked_version ||= cached_cookbook ? cached_cookbook.version : nil
|
176
|
-
end
|
177
|
-
|
178
172
|
# The location for this dependency, such as a remote Chef Server, the
|
179
173
|
# community API, :git, or a :path location. By default, this will be the
|
180
174
|
# community API.
|
@@ -191,6 +185,15 @@ module Berkshelf
|
|
191
185
|
@groups ||= []
|
192
186
|
end
|
193
187
|
|
188
|
+
# Determines if this dependency has a location and is it a {PathLocation}
|
189
|
+
#
|
190
|
+
# @return [Boolean]
|
191
|
+
def path_location?
|
192
|
+
location.nil? ? false : location.is_a?(PathLocation)
|
193
|
+
end
|
194
|
+
|
195
|
+
# Determines if this dependency has a location and if it is an SCM location
|
196
|
+
#
|
194
197
|
# @return [Boolean]
|
195
198
|
def scm_location?
|
196
199
|
if location.nil?
|
data/lib/berkshelf/errors.rb
CHANGED
@@ -323,7 +323,7 @@ module Berkshelf
|
|
323
323
|
" #{@dependency.name} (#{@dependency.version_constraint})\n\n" +
|
324
324
|
" In Berksfile.lock:\n" +
|
325
325
|
" #{@locked_dependency.name} (#{@locked_dependency.locked_version})\n\n" +
|
326
|
-
"Try running `berks update #{@dependency.name}
|
326
|
+
"Try running `berks update #{@dependency.name}`, which will try to find '#{@dependency.name}' matching " +
|
327
327
|
"'#{@dependency.version_constraint}'."
|
328
328
|
end
|
329
329
|
end
|
@@ -475,4 +475,18 @@ module Berkshelf
|
|
475
475
|
class DuplicateDemand < BerkshelfError; status_code(138); end
|
476
476
|
class VendorError < BerkshelfError; status_code(139); end
|
477
477
|
class LockfileNotFound < BerkshelfError; status_code(140); end
|
478
|
+
|
479
|
+
class NotACookbook < BerkshelfError
|
480
|
+
status_code(141)
|
481
|
+
|
482
|
+
# @param [String] path
|
483
|
+
# the path to the thing that is not a cookbook
|
484
|
+
def initialize(path)
|
485
|
+
@path = File.expand_path(path) rescue path
|
486
|
+
end
|
487
|
+
|
488
|
+
def to_s
|
489
|
+
"#{@path} does not appear to be a valid cookbook. Does it have a `metadata.rb`?"
|
490
|
+
end
|
491
|
+
end
|
478
492
|
end
|
@@ -33,7 +33,7 @@ module Berkshelf
|
|
33
33
|
# @param [Berkshelf::Dependency] dependency
|
34
34
|
def fetch(dependency)
|
35
35
|
cookbooks[dependency] ||= {}
|
36
|
-
cookbooks[dependency][:version] = dependency.
|
36
|
+
cookbooks[dependency][:version] = dependency.locked_version.to_s
|
37
37
|
cookbooks[dependency][:location] = dependency.location
|
38
38
|
end
|
39
39
|
|
@@ -13,11 +13,11 @@ module Berkshelf
|
|
13
13
|
|
14
14
|
class_option :metadata_entry,
|
15
15
|
type: :boolean,
|
16
|
-
default:
|
16
|
+
default: true
|
17
17
|
|
18
18
|
class_option :chefignore,
|
19
19
|
type: :boolean,
|
20
|
-
default:
|
20
|
+
default: true
|
21
21
|
|
22
22
|
class_option :skip_vagrant,
|
23
23
|
type: :boolean,
|
@@ -59,6 +59,7 @@ module Berkshelf
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def generate
|
62
|
+
validate_cookbook
|
62
63
|
validate_configuration
|
63
64
|
check_option_support
|
64
65
|
|
@@ -66,7 +67,7 @@ module Berkshelf
|
|
66
67
|
template 'Thorfile.erb', target.join('Thorfile')
|
67
68
|
|
68
69
|
if options[:chefignore]
|
69
|
-
copy_file 'chefignore', target.join(
|
70
|
+
copy_file 'chefignore', target.join(Ridley::Chef::Chefignore::FILENAME)
|
70
71
|
end
|
71
72
|
|
72
73
|
unless options[:skip_git]
|
@@ -129,6 +130,19 @@ module Berkshelf
|
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
133
|
+
# Assert the current working directory is a cookbook
|
134
|
+
#
|
135
|
+
# @raise [NotACookbook] if the current working directory is
|
136
|
+
# not a cookbook
|
137
|
+
#
|
138
|
+
# @return [nil]
|
139
|
+
def validate_cookbook
|
140
|
+
path = File.expand_path(File.join(target, 'metadata.rb'))
|
141
|
+
unless File.exists?(path)
|
142
|
+
raise Berkshelf::NotACookbook.new(path)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
132
146
|
# Assert valid configuration
|
133
147
|
#
|
134
148
|
# @raise [InvalidConfiguration] if the configuration is invalid
|
data/lib/berkshelf/installer.rb
CHANGED
@@ -42,6 +42,7 @@ module Berkshelf
|
|
42
42
|
|
43
43
|
cached_cookbooks = resolver.resolve.collect do |name, version, dependency|
|
44
44
|
lock_deps << dependency
|
45
|
+
dependency.locked_version ||= Solve::Version.new(version)
|
45
46
|
if dependency.downloaded?
|
46
47
|
Berkshelf.formatter.use(dependency.name, dependency.cached_cookbook.version, dependency.location)
|
47
48
|
dependency.cached_cookbook
|
@@ -115,9 +116,19 @@ module Berkshelf
|
|
115
116
|
#
|
116
117
|
# If a locked dependency exists, but doesn't satisfy the constraint, raise a
|
117
118
|
# {Berkshelf::OutdatedDependency} and tell the user to run update.
|
119
|
+
#
|
120
|
+
# Never use the locked constraint for a dependency with a {PathLocation}
|
121
|
+
#
|
122
|
+
# @param [Array<Berkshelf::Dependency>] dependencies
|
123
|
+
#
|
124
|
+
# @return [Array<Berkshelf::Dependency>]
|
118
125
|
def lockfile_reduce(dependencies = [])
|
119
126
|
dependencies.collect do |dependency|
|
120
|
-
|
127
|
+
if dependency.path_location?
|
128
|
+
dependency
|
129
|
+
else
|
130
|
+
dependency_from_lockfile(dependency) || dependency
|
131
|
+
end
|
121
132
|
end
|
122
133
|
end
|
123
134
|
|
data/lib/berkshelf/logger.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Berkshelf
|
2
|
-
Logger =
|
2
|
+
Logger = Ridley.logger
|
3
3
|
|
4
|
-
Logger.
|
5
|
-
|
6
|
-
|
4
|
+
Logger.class.class_eval do
|
5
|
+
alias_method :fatal, :error
|
6
|
+
|
7
|
+
def deprecate(message)
|
8
|
+
trace = caller.join("\n\t")
|
9
|
+
warn "DEPRECATION WARNING: #{message}\n\t#{trace}"
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|