Skip to content

Commit

Permalink
Strict type Dependabot::Terraform::MetaDataFinder. (dependabot#9936)
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-meka authored Jun 7, 2024
1 parent 3baf968 commit b4cb85a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion terraform/lib/dependabot/terraform/metadata_finder.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: strict
# frozen_string_literal: true

require "excon"
Expand All @@ -7,12 +7,16 @@
require "dependabot/metadata_finders/base"
require "dependabot/terraform/registry_client"
require "dependabot/shared_helpers"
require "sorbet-runtime"

module Dependabot
module Terraform
class MetadataFinder < Dependabot::MetadataFinders::Base
extend T::Sig

private

sig { override.returns(T.nilable(Dependabot::Source)) }
def look_up_source
case new_source_type
when "git" then find_source_from_git_url
Expand All @@ -21,17 +25,20 @@ def look_up_source
end
end

sig { returns(T.nilable(String)) }
def new_source_type
dependency.source_type
end

sig { returns(T.nilable(Dependabot::Source)) }
def find_source_from_git_url
info = dependency.requirements.filter_map { |r| r[:source] }.first

url = info[:url] || info.fetch("url")
Source.from_url(url)
end

sig { returns(T.nilable(Dependabot::Source)) }
def find_source_from_registry_details
info = dependency.requirements.filter_map { |r| r[:source] }.first
hostname = info[:registry_hostname] || info["registry_hostname"]
Expand Down

0 comments on commit b4cb85a

Please sign in to comment.