Class: Dependabot::Bazel::FileFetcher::DownloaderConfigFetcher

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/bazel/file_fetcher/downloader_config_fetcher.rb

Overview

Fetches downloader configuration files referenced in .bazelrc. Parses .bazelrc for –downloader_config flags and fetches those files.

Instance Method Summary collapse

Constructor Details

#initialize(fetcher:) ⇒ DownloaderConfigFetcher

Returns a new instance of DownloaderConfigFetcher.



16
17
18
# File 'lib/dependabot/bazel/file_fetcher/downloader_config_fetcher.rb', line 16

def initialize(fetcher:)
  @fetcher = fetcher
end

Instance Method Details

#fetch_downloader_config_filesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/bazel/file_fetcher/downloader_config_fetcher.rb', line 21

def fetch_downloader_config_files
  bazelrc_file = @fetcher.send(:fetch_file_if_present, ".bazelrc")
  return [] unless bazelrc_file

  config_paths = extract_downloader_config_paths(bazelrc_file)
  files = T.let([], T::Array[DependencyFile])

  config_paths.each do |path|
    fetched_file = @fetcher.send(:fetch_file_if_present, path)
    files << fetched_file if fetched_file
  rescue Dependabot::DependencyFileNotFound
    Dependabot.logger.warn(
      "Downloader config file '#{path}' referenced in .bazelrc but not found in repository"
    )
  end

  files
end