Skip to content

Commit

Permalink
(MAINT) Handle no metadata.json when calculating Puppet/Ruby version
Browse files Browse the repository at this point in the history
PDK::Util::PuppetVersion.from_module_metadata now issues a warning and
returns nil if the module does not have a metadata.json file.
  • Loading branch information
scotje committed May 8, 2018
1 parent fdbdea3 commit 0e660d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/pdk/util/puppet_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ def from_pe_version(version_str)
end

def from_module_metadata(metadata = nil)
metadata ||= PDK::Module::Metadata.from_file(PDK::Util.find_upwards('metadata.json'))
if metadata.nil?
metadata_file = PDK::Util.find_upwards('metadata.json')

unless metadata_file
PDK.logger.warn _('Unable to determine Puppet version for module: no metadata.json present in module.')
return nil
end

metadata = PDK::Module::Metadata.from_file(metadata_file)
end

metadata.validate_puppet_version_requirement!
metadata_requirement = metadata.puppet_requirement

Expand Down

0 comments on commit 0e660d2

Please sign in to comment.