0

this is my code:

if node['app']['source']
    src = "#{node['app']['source']}\\#{node['app']['file_name']}"
else 
    src = "second_source"
end

I want to add a log.warn at the end of my statement in case of any source isn't valid, something like:

if node['app']['source']
    src = "#{node['app']['source']}\\#{node['app']['file_name']}"
else 
    src = "second_source"
whatever
    Chef::Log.warn "This path #{src} is not supported, check attributes again"
    return
end

I will glad if somebody has an any idea, Thank you...

goldver
  • 191
  • 1
  • 12

1 Answers1

0

That isn't how code works, a condition can either be true or false, and the two branches of if/else cover both cases. You would have to come up with a way to check if a source is valid and use if/elsif/else or similar.

coderanger
  • 52,400
  • 4
  • 52
  • 75