summaryrefslogtreecommitdiff
path: root/lib/chef/util/dsc
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-05 15:00:00 -0800
commit686113531d23f30e9973d659c456ae33eb9cff1f (patch)
treef225de7251a8b49b8d183dd168bab0a0addbe23f /lib/chef/util/dsc
parentd1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff)
downloadchef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces 1860 Style/SpaceAroundOperators 1336 Style/SpaceInsideBlockBraces 1292 Style/AlignHash 997 Style/SpaceAfterComma 860 Style/SpaceAroundEqualsInParameterDefault 310 Style/EmptyLines 294 Style/IndentationConsistency 267 Style/TrailingWhitespace 238 Style/ExtraSpacing 212 Style/SpaceBeforeBlockBraces 166 Style/MultilineOperationIndentation 144 Style/TrailingBlankLines 120 Style/EmptyLineBetweenDefs 101 Style/IndentationWidth 82 Style/SpaceAroundBlockParameters 40 Style/EmptyLinesAroundMethodBody 29 Style/EmptyLinesAroundAccessModifier 1 Style/RescueEnsureAlignment
Diffstat (limited to 'lib/chef/util/dsc')
-rw-r--r--lib/chef/util/dsc/configuration_generator.rb8
-rw-r--r--lib/chef/util/dsc/lcm_output_parser.rb6
-rw-r--r--lib/chef/util/dsc/local_configuration_manager.rb4
-rw-r--r--lib/chef/util/dsc/resource_info.rb30
-rw-r--r--lib/chef/util/dsc/resource_store.rb139
5 files changed, 93 insertions, 94 deletions
diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb
index bec9c69ff7..af9a71b246 100644
--- a/lib/chef/util/dsc/configuration_generator.rb
+++ b/lib/chef/util/dsc/configuration_generator.rb
@@ -70,7 +70,7 @@ class Chef::Util::DSC
def get_merged_configuration_flags!(configuration_flags, configuration_name)
merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) }
if configuration_flags
- configuration_flags.map do | switch, value |
+ configuration_flags.map do |switch, value|
if merged_configuration_flags.key?(switch.to_s.downcase.to_sym)
raise ArgumentError, "The `flags` attribute for the dsc_script resource contained a command line switch :#{switch} that is disallowed."
end
@@ -114,7 +114,7 @@ Configuration '#{configuration_name}'
def write_document_generation_script(code, configuration_name, imports)
script_path = "#{@config_directory}/chef_dsc_config.ps1"
- ::File.open(script_path, "wt") do | script |
+ ::File.open(script_path, "wt") do |script|
script.write(configuration_code(code, configuration_name, imports))
end
script_path
@@ -122,7 +122,7 @@ Configuration '#{configuration_name}'
def find_configuration_document(configuration_name)
document_directory = configuration_document_directory(configuration_name)
- document_file_name = ::Dir.entries(document_directory).find { | path | path =~ /.*.mof/ }
+ document_file_name = ::Dir.entries(document_directory).find { |path| path =~ /.*.mof/ }
::File.join(document_directory, document_file_name) if document_file_name
end
@@ -131,7 +131,7 @@ Configuration '#{configuration_name}'
end
def get_configuration_document(document_path)
- ::File.open(document_path, "rb") do | file |
+ ::File.open(document_path, "rb") do |file|
file.read
end
end
diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb
index 8f62a27c8a..2e81b363e0 100644
--- a/lib/chef/util/dsc/lcm_output_parser.rb
+++ b/lib/chef/util/dsc/lcm_output_parser.rb
@@ -73,7 +73,7 @@ class Chef
if current_resource[:name]
resources.push(current_resource)
end
- current_resource = {:name => info}
+ current_resource = { :name => info }
else
Chef::Log.debug("Ignoring op_action #{op_action}: Read line #{line}")
end
@@ -108,8 +108,8 @@ class Chef
# If the line looks like
# What If: [machinename]: LCM: [op_action op_type] message
# extract op_action, op_type, and message
- operation, info = match.captures
- op_action, op_type = operation.strip.split(" ").map {|m| m.downcase.to_sym}
+ operation, info = match.captures
+ op_action, op_type = operation.strip.split(" ").map { |m| m.downcase.to_sym }
else
op_action = op_type = :info
if match = line.match(/^.*?:.*?: \s+(.*)/)
diff --git a/lib/chef/util/dsc/local_configuration_manager.rb b/lib/chef/util/dsc/local_configuration_manager.rb
index 6db8f40eae..3b4eaa92a9 100644
--- a/lib/chef/util/dsc/local_configuration_manager.rb
+++ b/lib/chef/util/dsc/local_configuration_manager.rb
@@ -111,7 +111,7 @@ EOH
def save_configuration_document(configuration_document)
::FileUtils.mkdir_p(@configuration_path)
- ::File.open(configuration_document_path, "wb") do | file |
+ ::File.open(configuration_document_path, "wb") do |file|
file.write(configuration_document)
end
end
@@ -121,7 +121,7 @@ EOH
end
def configuration_document_path
- File.join(@configuration_path,"..mof")
+ File.join(@configuration_path, "..mof")
end
def clear_execution_time
diff --git a/lib/chef/util/dsc/resource_info.rb b/lib/chef/util/dsc/resource_info.rb
index 4a32451721..d6dfcff59a 100644
--- a/lib/chef/util/dsc/resource_info.rb
+++ b/lib/chef/util/dsc/resource_info.rb
@@ -2,25 +2,25 @@
class Chef
class Util
class DSC
- class ResourceInfo
- # The name is the text following [Start Set]
- attr_reader :name
+ class ResourceInfo
+ # The name is the text following [Start Set]
+ attr_reader :name
- # A list of all log messages between [Start Set] and [End Set].
- # Each line is an element in the list.
- attr_reader :change_log
+ # A list of all log messages between [Start Set] and [End Set].
+ # Each line is an element in the list.
+ attr_reader :change_log
- def initialize(name, sets, change_log)
- @name = name
- @sets = sets
- @change_log = change_log || []
- end
+ def initialize(name, sets, change_log)
+ @name = name
+ @sets = sets
+ @change_log = change_log || []
+ end
- # Does this resource change the state of the system?
- def changes_state?
- @sets
- end
+ # Does this resource change the state of the system?
+ def changes_state?
+ @sets
end
+ end
end
end
end
diff --git a/lib/chef/util/dsc/resource_store.rb b/lib/chef/util/dsc/resource_store.rb
index df8cfa84ed..bb3480d105 100644
--- a/lib/chef/util/dsc/resource_store.rb
+++ b/lib/chef/util/dsc/resource_store.rb
@@ -21,90 +21,89 @@ require "chef/util/powershell/cmdlet_result"
require "chef/exceptions"
class Chef
-class Util
-class DSC
- class ResourceStore
+ class Util
+ class DSC
+ class ResourceStore
- def self.instance
- @@instance ||= ResourceStore.new.tap do |store|
- store.send(:populate_cache)
- end
- end
+ def self.instance
+ @@instance ||= ResourceStore.new.tap do |store|
+ store.send(:populate_cache)
+ end
+ end
- def resources
- @resources ||= []
- end
+ def resources
+ @resources ||= []
+ end
- def find(name, module_name=nil)
- found = find_resources(name, module_name, resources)
+ def find(name, module_name = nil)
+ found = find_resources(name, module_name, resources)
- # We don't have it, query for the resource...it might
- # have been added since we last queried
- if found.length == 0
- rs = query_resource(name)
- add_resources(rs)
- found = find_resources(name, module_name, rs)
- end
+ # We don't have it, query for the resource...it might
+ # have been added since we last queried
+ if found.length == 0
+ rs = query_resource(name)
+ add_resources(rs)
+ found = find_resources(name, module_name, rs)
+ end
- found
- end
-
- private
+ found
+ end
- def add_resource(new_r)
- count = resources.count do |r|
- r["ResourceType"].casecmp(new_r["ResourceType"]) == 0
- end
- if count == 0
- resources << new_r
- end
- end
+ private
- def add_resources(rs)
- rs.each do |r|
- add_resource(r)
- end
- end
+ def add_resource(new_r)
+ count = resources.count do |r|
+ r["ResourceType"].casecmp(new_r["ResourceType"]) == 0
+ end
+ if count == 0
+ resources << new_r
+ end
+ end
- def populate_cache
- @resources = query_resources
- end
+ def add_resources(rs)
+ rs.each do |r|
+ add_resource(r)
+ end
+ end
- def find_resources(name, module_name, rs)
- found = rs.find_all do |r|
- name_matches = r["Name"].casecmp(name) == 0
- if name_matches
- module_name == nil || (r["Module"] and r["Module"]["Name"].casecmp(module_name) == 0)
- else
- false
+ def populate_cache
+ @resources = query_resources
end
- end
- end
+ def find_resources(name, module_name, rs)
+ found = rs.find_all do |r|
+ name_matches = r["Name"].casecmp(name) == 0
+ if name_matches
+ module_name == nil || (r["Module"] and r["Module"]["Name"].casecmp(module_name) == 0)
+ else
+ false
+ end
+ end
+ end
- # Returns a list of dsc resources
- def query_resources
- cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource",
- :object)
- result = cmdlet.run
- result.return_value
- end
+ # Returns a list of dsc resources
+ def query_resources
+ cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource",
+ :object)
+ result = cmdlet.run
+ result.return_value
+ end
- # Returns a list of dsc resources matching the provided name
- def query_resource(resource_name)
- cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource #{resource_name}",
- :object)
- result = cmdlet.run
- ret_val = result.return_value
- if ret_val.nil?
- []
- elsif ret_val.is_a? Array
- ret_val
- else
- [ret_val]
+ # Returns a list of dsc resources matching the provided name
+ def query_resource(resource_name)
+ cmdlet = Chef::Util::Powershell::Cmdlet.new(nil, "get-dscresource #{resource_name}",
+ :object)
+ result = cmdlet.run
+ ret_val = result.return_value
+ if ret_val.nil?
+ []
+ elsif ret_val.is_a? Array
+ ret_val
+ else
+ [ret_val]
+ end
+ end
end
end
end
end
-end
-end