class Dependabot::Terraform::MetadataFinder

Private Instance Methods

find_source_from_git_url() click to toggle source
# File lib/dependabot/terraform/metadata_finder.rb, line 33
def find_source_from_git_url
  info = dependency.requirements.map { |r| r[:source] }.compact.first

  url = info[:url] || info.fetch("url")
  Source.from_url(url)
end
find_source_from_registry_details() click to toggle source
# File lib/dependabot/terraform/metadata_finder.rb, line 40
def find_source_from_registry_details
  info = dependency.requirements.map { |r| r[:source] }.compact.first
  hostname = info[:registry_hostname] || info["registry_hostname"]

  RegistryClient.
    new(hostname: hostname, credentials: credentials).
    source(dependency: dependency)
end
look_up_source() click to toggle source
# File lib/dependabot/terraform/metadata_finder.rb, line 15
def look_up_source
  case new_source_type
  when "git" then find_source_from_git_url
  when "registry", "provider" then find_source_from_registry_details
  else raise "Unexpected source type: #{new_source_type}"
  end
end
new_source_type() click to toggle source
# File lib/dependabot/terraform/metadata_finder.rb, line 23
def new_source_type
  sources =
    dependency.requirements.map { |r| r.fetch(:source) }.uniq.compact

  return "default" if sources.empty?
  raise "Multiple sources! #{sources.join(', ')}" if sources.count > 1

  sources.first[:type] || sources.first.fetch("type")
end