summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-10-17 15:27:16 -0500
committertyler-ball <tyleraball@gmail.com>2014-10-17 15:27:16 -0500
commited7a6d2dead738a99ebcb1782d29ca89924093cc (patch)
tree6b2e216604dbd6df9db7ca5f4c17c94300e538eb /lib
parent335072475b38df2550dc78ad3f4a340dfc908ece (diff)
downloadchef-ed7a6d2dead738a99ebcb1782d29ca89924093cc.tar.gz
1) No longer allowing multiple args passed to ResourceCollection#<< 2) removing ResourceCollection#insert_at
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/application/client.rb5
-rw-r--r--lib/chef/resource_collection.rb39
-rw-r--r--lib/chef/resource_collection/resource_list.rb12
3 files changed, 18 insertions, 38 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 7f0a39782a..5463f504bc 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -238,6 +238,11 @@ class Chef::Application::Client < Chef::Application
:boolean => true
end
+ option :audit_mode,
+ :long => "--[no-]audit-mode",
+ :description => "If not specified, run converge and audit phase. If true, run only audit phase. If false, run only converge phase.",
+ :boolean => true
+
IMMEDIATE_RUN_SIGNAL = "1".freeze
attr_reader :chef_client_json
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
index 772be0b68d..30520cff7e 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -32,6 +32,9 @@ class Chef
include ResourceCollectionSerialization
extend Forwardable
+ attr_reader :resource_set, :resource_list
+ private :resource_set, :resource_list
+
def initialize
@resource_set = ResourceSet.new
@resource_list = ResourceList.new
@@ -47,40 +50,24 @@ class Chef
def insert(resource, opts={})
resource_type ||= opts[:resource_type] # Would rather use Ruby 2.x syntax, but oh well
instance_name ||= opts[:instance_name]
- at_location ||= opts[:at_location]
- if at_location
- @resource_list.insert_at(at_location, resource)
- else
- @resource_list.insert(resource)
- end
+ resource_list.insert(resource)
if !(resource_type.nil? && instance_name.nil?)
- @resource_set.insert_as(resource, resource_type, instance_name)
+ resource_set.insert_as(resource, resource_type, instance_name)
else
- @resource_set.insert_as(resource)
- end
- end
-
- # @param insert_at_index [Integer] Location to insert resources
- # @param resources [Chef::Resource] Resources to insert
- # @deprecated Callers should use the insert method above and loop through their resources as necessary
- def insert_at(insert_at_index, *resources)
- Chef::Log.warn("`insert_at` is deprecated, use `insert` with the `at_location` parameter")
- @resource_list.insert_at(insert_at_index, *resources)
- resources.each do |resource|
- @resource_set.insert_as(resource)
+ resource_set.insert_as(resource)
end
end
# @deprecated
def []=(index, resource)
Chef::Log.warn("`[]=` is deprecated, use `insert` with the `at_location` parameter")
- @resource_list[index] = resource
- @resource_set.insert_as(resource)
+ resource_list[index] = resource
+ resource_set.insert_as(resource)
end
# @deprecated
- def <<(*resources)
- Chef::Log.warn("`<<` is deprecated, use `insert`")
+ def push(*resources)
+ Chef::Log.warn("`push` is deprecated, use `insert`")
resources.flatten.each do |res|
insert(res)
end
@@ -88,7 +75,7 @@ class Chef
end
# @deprecated
- alias_method :push, :<<
+ alias_method :<<, :insert
# Read-only methods are simple to delegate - doing that below
@@ -97,8 +84,8 @@ class Chef
[:find] # find needs to run on the set
resource_set_methods = [:lookup, :find, :resources, :keys, :validate_lookup_spec!]
- def_delegators :@resource_list, *resource_list_methods
- def_delegators :@resource_set, *resource_set_methods
+ def_delegators :resource_list, *resource_list_methods
+ def_delegators :resource_set, *resource_set_methods
end
end
diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb
index 56bf89f1e4..e083cc0a9f 100644
--- a/lib/chef/resource_collection/resource_list.rb
+++ b/lib/chef/resource_collection/resource_list.rb
@@ -58,17 +58,6 @@ class Chef
end
end
- # @param index [Integer] location in the array to insert the resources
- # @param resources [Array of Chef::Resource] Resources to insert
- # Locate the index indicated and insert all resources, pushing any remaining resources further down in the array.
- def insert_at(index, *resources)
- resources.each do |resource|
- is_chef_resource!(resource)
- end
- @resources.insert(index, *resources)
- @insert_after_idx += resources.size unless @insert_after_idx.nil?
- end
-
# @deprecated - can be removed when it is removed from resource_collection.rb
def []=(index, resource)
@resources[index] = resource
@@ -88,7 +77,6 @@ class Chef
end
end
- # so far, and then move that logic up into the ResourceCollection class to simplify this class
def execute_each_resource(&resource_exec_block)
@iterator = ResourceCollection::StepableIterator.for_collection(@resources)
@iterator.each_with_index do |resource, idx|