Class: Dependabot::Terraform::RequirementsUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/terraform/requirements_updater.rb

Instance Method Summary collapse

Constructor Details

#initialize(requirements:, latest_version:, tag_for_latest_version:) ⇒ RequirementsUpdater

Returns a new instance of RequirementsUpdater.


14
15
16
17
18
19
20
21
22
23
# File 'lib/dependabot/terraform/requirements_updater.rb', line 14

def initialize(requirements:, latest_version:,
               tag_for_latest_version:)
  @requirements = requirements
  @tag_for_latest_version = tag_for_latest_version

  return unless latest_version
  return unless version_class.correct?(latest_version)

  @latest_version = version_class.new(latest_version)
end

Instance Method Details

#updated_requirementsObject


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/terraform/requirements_updater.rb', line 25

def updated_requirements
  return requirements unless latest_version

  # Note: Order is important here. The FileUpdater needs the updated
  # requirement at index `i` to correspond to the previous requirement
  # at the same index.
  requirements.map do |req|
    case req.dig(:source, :type)
    when "git" then update_git_requirement(req)
    when "registry" then update_registry_requirement(req)
    else req
    end
  end
end