chef 0.9.0.a90 → 0.9.0.a91
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/lib/chef/config.rb +3 -0
- data/lib/chef/knife/configure.rb +11 -7
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/mixin/deprecation.rb +65 -0
- data/lib/chef/provider/package/rubygems.rb +14 -2
- data/lib/chef/recipe.rb +4 -0
- data/lib/chef/version.rb +1 -1
- metadata +3 -2
data/lib/chef/config.rb
CHANGED
data/lib/chef/knife/configure.rb
CHANGED
@@ -113,13 +113,17 @@ EOH
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def ask_user_for_config
|
116
|
-
@chef_server = config[:chef_server_url] || ask_question("
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
116
|
+
@chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => 'http://localhost:4000')
|
117
|
+
if config[:initial]
|
118
|
+
@new_client_name = config[:node_name] || ask_question("Please enter a clientname for the new client: ", :default => Etc.getlogin)
|
119
|
+
@admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin clientname: ", :default => 'chef-webui')
|
120
|
+
@admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin client's private key: ", :default => '/etc/chef/webui.pem')
|
121
|
+
else
|
122
|
+
@new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", :default => Etc.getlogin)
|
123
|
+
end
|
124
|
+
@validation_client_name = config[:validation_client_name] || ask_question("Please enter the validation clientname: ", :default => 'chef-validator')
|
125
|
+
@validation_key = config[:validation_key] || ask_question("Please enter the location of the validation key: ", :default => '/etc/chef/validation.pem')
|
126
|
+
@chef_repo = config[:repository] || ask_question("Please enter the path to a chef repository (or leave blank): ")
|
123
127
|
|
124
128
|
@new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem")
|
125
129
|
end
|
@@ -208,10 +208,10 @@ class Chef
|
|
208
208
|
result = shell_out("sh -c 'erubis -x #{erb_file} | ruby -c'")
|
209
209
|
result.error!
|
210
210
|
rescue Chef::Exceptions::ShellCommandFailed
|
211
|
-
file_relative_path = erb_file[/^#{Regexp.escape(cookbook_dir
|
211
|
+
file_relative_path = erb_file[/^#{Regexp.escape(cookbook_dir+File::Separator)}(.*)/, 1]
|
212
212
|
Chef::Log.fatal("Erb template #{file_relative_path} has a syntax error:")
|
213
213
|
result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
214
|
-
exit
|
214
|
+
exit(1)
|
215
215
|
end
|
216
216
|
|
217
217
|
def test_ruby_file(cookbook_dir, ruby_file)
|
@@ -219,10 +219,10 @@ class Chef
|
|
219
219
|
result = shell_out("ruby -c #{ruby_file}")
|
220
220
|
result.error!
|
221
221
|
rescue Chef::Exceptions::ShellCommandFailed
|
222
|
-
file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_dir
|
222
|
+
file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_dir+File::Separator)}(.*)/, 1]
|
223
223
|
Chef::Log.fatal("Cookbook file #{file_relative_path} has a syntax error:")
|
224
224
|
result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
225
|
-
exit
|
225
|
+
exit(1)
|
226
226
|
end
|
227
227
|
|
228
228
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
module Mixin
|
21
|
+
module Deprecation
|
22
|
+
class DeprecatedObjectProxyBase
|
23
|
+
KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id}
|
24
|
+
instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s)}
|
25
|
+
end
|
26
|
+
|
27
|
+
class DeprecatedInstanceVariable < DeprecatedObjectProxyBase
|
28
|
+
def initialize(target, ivar_name, level=nil)
|
29
|
+
@target, @ivar_name = target, ivar_name
|
30
|
+
@level ||= :warn
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(method_name, *args, &block)
|
34
|
+
log_deprecation_msg(caller[0..3])
|
35
|
+
@target.send(method_name, *args, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def inspect
|
39
|
+
@target.inspect
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def log_deprecation_msg(*called_from)
|
45
|
+
called_from = called_from.flatten
|
46
|
+
log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.")
|
47
|
+
log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:")
|
48
|
+
called_from.each {|l| log(l)}
|
49
|
+
end
|
50
|
+
|
51
|
+
def log(msg)
|
52
|
+
# WTF: I don't get the log prefix (i.e., "[timestamp] LEVEL:") if I
|
53
|
+
# send to Chef::Log. No one but me should use method_missing, ever.
|
54
|
+
Chef::Log.logger.send(@level, msg)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def deprecated_ivar(obj, name, level=nil)
|
60
|
+
DeprecatedInstanceVariable.new(obj, name, level)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -149,7 +149,9 @@ class Chef
|
|
149
149
|
# Other options are passed to Gem::DependencyInstaller.new
|
150
150
|
def install(gem_dependency, options={})
|
151
151
|
with_gem_sources(*options.delete(:sources)) do
|
152
|
-
|
152
|
+
with_correct_verbosity do
|
153
|
+
dependency_installer(options).install(gem_dependency)
|
154
|
+
end
|
153
155
|
end
|
154
156
|
end
|
155
157
|
|
@@ -161,7 +163,17 @@ class Chef
|
|
161
163
|
# Options are passed to Gem::Uninstaller.new
|
162
164
|
def uninstall(gem_name, gem_version=nil, opts={})
|
163
165
|
gem_version ? opts[:version] = gem_version : opts[:all] = true
|
164
|
-
|
166
|
+
with_correct_verbosity do
|
167
|
+
uninstaller(gem_name, opts).uninstall
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Set rubygems' user interaction to ConsoleUI or SilentUI depending
|
173
|
+
# on our current debug level
|
174
|
+
def with_correct_verbosity
|
175
|
+
Gem::DefaultUserInteraction.ui = Chef::Log.debug? ? Gem::ConsoleUI.new : Gem::SilentUI.new
|
176
|
+
yield
|
165
177
|
end
|
166
178
|
|
167
179
|
def dependency_installer(opts={})
|
data/lib/chef/recipe.rb
CHANGED
@@ -23,6 +23,8 @@ require 'chef/mixin/from_file'
|
|
23
23
|
require 'chef/mixin/language'
|
24
24
|
require 'chef/mixin/language_include_recipe'
|
25
25
|
|
26
|
+
require 'chef/mixin/deprecation'
|
27
|
+
|
26
28
|
class Chef
|
27
29
|
class Recipe
|
28
30
|
|
@@ -30,6 +32,7 @@ class Chef
|
|
30
32
|
include Chef::Mixin::Language
|
31
33
|
include Chef::Mixin::LanguageIncludeRecipe
|
32
34
|
include Chef::Mixin::RecipeDefinitionDSLCore
|
35
|
+
include Chef::Mixin::Deprecation
|
33
36
|
|
34
37
|
attr_accessor :cookbook_name, :recipe_name, :recipe, :params, :run_context
|
35
38
|
|
@@ -54,6 +57,7 @@ class Chef
|
|
54
57
|
@run_context = run_context
|
55
58
|
# TODO: 5/19/2010 cw/tim: determine whether this can be removed
|
56
59
|
@params = Hash.new
|
60
|
+
@node = deprecated_ivar(run_context.node, :node, :warn)
|
57
61
|
end
|
58
62
|
|
59
63
|
# Used in DSL mixins
|
data/lib/chef/version.rb
CHANGED
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 9
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.9.0.
|
9
|
+
- a91
|
10
|
+
version: 0.9.0.a91
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Jacob
|
@@ -364,6 +364,7 @@ files:
|
|
364
364
|
- lib/chef/mixin/convert_to_class_name.rb
|
365
365
|
- lib/chef/mixin/create_path.rb
|
366
366
|
- lib/chef/mixin/deep_merge.rb
|
367
|
+
- lib/chef/mixin/deprecation.rb
|
367
368
|
- lib/chef/mixin/find_preferred_file.rb
|
368
369
|
- lib/chef/mixin/from_file.rb
|
369
370
|
- lib/chef/mixin/language.rb
|