Skip to content

Fixes #35, implement fqdn_resolves? method #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ def get_config(product)
node.run_state[:ingredient_config_data] ||= {}
node.run_state[:ingredient_config_data][product] ||= ''
end

def fqdn_resolves?(fqdn)
require 'resolv'
Resolv.getaddress(fqdn)
return true
rescue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rescue the specific ResolvError exception here.

false
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider using Module#module_function to make these sort of functions callable with the Module as the receiver:

module_function :fqdn_resolves?

That would allow the following:

ChefIngredientCookbook::Helpers.fqdn_resolves?(fqdn)

end
end

Expand Down