Method: Chef::Util::DSC::LocalConfigurationManager::Parser.test_dsc_parser

Defined in:
lib/chef/util/dsc/lcm_output_parser.rb

.test_dsc_parser(lcm_output) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/chef/util/dsc/lcm_output_parser.rb', line 82

def self.test_dsc_parser(lcm_output)
  current_resource = {}

  resources = []
  lcm_output.each do |line|
    op_action , op_value = line.strip.split(":")
    op_action&.strip!
    case op_action
    when "InDesiredState"
      current_resource[:skipped] = op_value.strip == "True" ? true : false
    when "ResourcesInDesiredState", "ResourcesNotInDesiredState"
      current_resource[:name] = op_value.strip if op_value
    when "ReturnValue"
      current_resource[:context] = nil
    end
  end
  if current_resource[:name]
    resources.push(current_resource)
  end

  if resources.length > 0
    build_resource_info(resources)
  else
    raise Chef::Exceptions::LCMParser, "Could not parse:\n#{lcm_output}"
  end
end