chef 0.9.10.rc.0 → 0.9.10.rc.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.
@@ -89,6 +89,11 @@ class Chef::Application::Client < Chef::Application
89
89
  :description => "Run chef-client periodically, in seconds",
90
90
  :proc => lambda { |s| s.to_i }
91
91
 
92
+ option :once,
93
+ :long => "--short",
94
+ :description => "Cancel any interval or splay options, run chef once and exit",
95
+ :boolean => true
96
+
92
97
  option :json_attribs,
93
98
  :short => "-j JSON_ATTRIBS",
94
99
  :long => "--json-attributes JSON_ATTRIBS",
@@ -149,7 +154,9 @@ class Chef::Application::Client < Chef::Application
149
154
 
150
155
  if Chef::Config[:daemonize]
151
156
  Chef::Config[:interval] ||= 1800
152
- else
157
+ end
158
+
159
+ if Chef::Config[:once]
153
160
  Chef::Config[:interval] = nil
154
161
  Chef::Config[:splay] = nil
155
162
  end
@@ -220,6 +220,7 @@ class Chef
220
220
 
221
221
 
222
222
  @node.consume_external_attrs(ohai.data, @json_attribs)
223
+ @node.expand!
223
224
  @node.save unless Chef::Config[:solo]
224
225
  @node.reset_defaults_and_overrides
225
226
 
@@ -418,7 +418,20 @@ class Chef
418
418
  object = klass.load(name)
419
419
 
420
420
  output = edit_data(object)
421
- if output.to_s != object.to_s
421
+
422
+ # Only make the save if the user changed the object.
423
+ #
424
+ # Output JSON for the original (object) and edited (output), then parse
425
+ # them without reconstituting the objects into real classes
426
+ # (create_additions=false). Then, compare the resulting simple objects,
427
+ # which will be Array/Hash/String/etc.
428
+ #
429
+ # We wouldn't have to do these shenanigans if all the editable objects
430
+ # implemented to_hash, or if to_json against a hash returned a string
431
+ # with stable key order.
432
+ object_parsed_again = JSON.parse(object.to_json, :create_additions => false)
433
+ output_parsed_again = JSON.parse(output.to_json, :create_additions => false)
434
+ if object_parsed_again != output_parsed_again
422
435
  output.save
423
436
  self.msg("Saved #{output}")
424
437
  else
@@ -33,7 +33,7 @@ class Chef
33
33
 
34
34
 
35
35
  def action_create
36
- if file_cache_location
36
+ if file_cache_location && content_stale?
37
37
  Chef::Log.debug("content of file #{@new_resource.path} requires update")
38
38
  backup_new_resource
39
39
  Tempfile.open(::File.basename(@new_resource.name)) do |staging_file|
@@ -46,7 +46,7 @@ class Chef
46
46
  else
47
47
  set_all_access_controls(@new_resource.path)
48
48
  end
49
- @new_resource.updated_by_last_action(true)
49
+ @new_resource.updated_by_last_action?
50
50
  end
51
51
 
52
52
  def action_create_if_missing
@@ -91,6 +91,10 @@ class Chef
91
91
  end
92
92
  end
93
93
 
94
+ def content_stale?
95
+ ( ! ::File.exist?(@new_resource.path)) || ( ! compare_content)
96
+ end
97
+
94
98
  end
95
99
  end
96
100
  end
@@ -17,5 +17,5 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '0.9.10.rc.0'
20
+ VERSION = '0.9.10.rc.1'
21
21
  end
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 9
8
8
  - 10
9
9
  - rc
10
- - 0
11
- version: 0.9.10.rc.0
10
+ - 1
11
+ version: 0.9.10.rc.1
12
12
  platform: ruby
13
13
  authors:
14
14
  - Adam Jacob