Class: Dependabot::DockerCompose::FileFetcher

Inherits:
Shared::SharedFileFetcher
  • Object
show all
Defined in:
lib/dependabot/docker_compose/file_fetcher.rb

Constant Summary collapse

FILENAME_REGEX =
/(docker-)?compose(-[\w]+)?(?>\.[\w-]+)?\.ya?ml/i

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.filename_regexObject



22
23
24
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 22

def self.filename_regex
  FILENAME_REGEX
end

.required_files_messageObject



48
49
50
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 48

def self.required_files_message
  "Repo must contain a docker-compose.yaml file."
end

Instance Method Details

#correctly_encoded_docker_compose_filesObject



38
39
40
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 38

def correctly_encoded_docker_compose_files
  docker_compose_files.select { |f| T.must(f.content).valid_encoding? }
end

#docker_compose_filesObject



27
28
29
30
31
32
33
34
35
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 27

def docker_compose_files
  @docker_compose_files ||=
    T.let(
      repo_contents(raise_errors: false)
                .select { |f| f.type == "file" && f.name.match?(FILENAME_REGEX) }
                .map { |f| fetch_file_from_host(f.name) },
      T.nilable(T::Array[DependencyFile])
    )
end

#fetch_filesObject



12
13
14
15
16
17
18
19
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 12

def fetch_files
  fetched_files = []
  fetched_files += correctly_encoded_docker_compose_files

  return fetched_files if fetched_files.any?

  raise_appropriate_error
end

#incorrectly_encoded_docker_compose_filesObject



43
44
45
# File 'lib/dependabot/docker_compose/file_fetcher.rb', line 43

def incorrectly_encoded_docker_compose_files
  docker_compose_files.reject { |f| T.must(f.content).valid_encoding? }
end