app/lib/katello/util/cdn_var_substitutor.rb in katello-2.4.5 vs app/lib/katello/util/cdn_var_substitutor.rb in katello-3.0.0.rc1

- old
+ new

@@ -94,12 +94,13 @@ validate_all_substitutions_accepted(content, substitutions) content_url = content.contentUrl real_path = gsub_vars(content_url, substitutions) if substituable?(real_path) - fail Errors::CdnSubstitutionError, _("%{substitutions} are not valid substitutions for %{content_url}") % - { substitutions: substitutions, content_url: content.contentUrl } + fail Errors::CdnSubstitutionError, _("Missing arguments %{substitutions} for %{content_url}") % + { substitutions: substitutions_needed(real_path).join(', '), + content_url: real_path } else is_valid = valid_path?(real_path, 'repodata/repomd.xml') || valid_path?(real_path, 'PULP_MANIFEST') unless is_valid @resource.log :error, "No valid metadata files found for #{real_path}" fail Errors::CdnSubstitutionError, _("%{substitutions} are not valid substitutions for %{content_url}."\ @@ -108,9 +109,15 @@ end end end protected + + def substitutions_needed(content_url) + # e.g. if content_url = "/content/dist/rhel/server/7/$releasever/$basearch/kickstart" + # return ['releasever', 'basearch'] + content_url.split('/').map { |word| word.start_with?('$') ? word[1..-1] : nil }.compact + end def validate_all_substitutions_accepted(content, substitutions) unaccepted_substitutions = substitutions.keys.reject do |key| content.contentUrl.include?("$#{key}") end