Skip to content
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

Avoid proliferation of constants and ensure they're initialised #443

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Changes from all commits
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
13 changes: 8 additions & 5 deletions lib/puppet/reports/datadog_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
API_KEY = config[:datadog_api_key]

# if need be initialize the regex
HOSTNAME_REGEX = config[:hostname_extraction_regex]
begin
HOSTNAME_EXTRACTION_REGEX = Regexp.new HOSTNAME_REGEX unless HOSTNAME_REGEX.nil?
rescue
raise(Puppet::ParseError, "Invalid hostname_extraction_regex #{HOSTNAME_REGEX}")
if !config[:hostname_extraction_regex].nil?
begin
HOSTNAME_EXTRACTION_REGEX = Regexp.new config[:hostname_extraction_regex]
rescue
raise(Puppet::ParseError, "Invalid hostname_extraction_regex #{HOSTNAME_REGEX}")
end
else
HOSTNAME_EXTRACTION_REGEX = nil
end

desc <<-DESC
Expand Down