Class: Dependabot::Terraform::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Defined in:
lib/dependabot/terraform/file_parser.rb

Constant Summary collapse

ARCHIVE_EXTENSIONS =
%w(.zip .tbz2 .tgz .txz).freeze

Instance Method Summary collapse

Instance Method Details

#parseObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/terraform/file_parser.rb', line 21

def parse
  dependency_set = DependencySet.new

  terraform_files.each do |file|
    modules = parsed_file(file).fetch("module", []).map(&:first)
    modules.each do |name, details|
      dependency_set << build_terraform_dependency(file, name, details)
    end
  end

  terragrunt_files.each do |file|
    modules = parsed_file(file).fetch("terragrunt", []).first || {}
    modules = modules.fetch("terraform", [])
    modules.each do |details|
      next unless details["source"]

      dependency_set << build_terragrunt_dependency(file, details)
    end
  end

  dependency_set.dependencies
end