Class: Dependabot::Docker::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::Docker::FileFetcher
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/docker/file_fetcher.rb
Constant Summary collapse
- YAML_REGEXP =
/^[^\.].*\.ya?ml$/i
- DOCKER_REGEXP =
/dockerfile/i
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
19 20 21 22 |
# File 'lib/dependabot/docker/file_fetcher.rb', line 19 def self.required_files_in?(filenames) filenames.any? { |f| f.match?(DOCKER_REGEXP) } or filenames.any? { |f| f.match?(YAML_REGEXP) } end |
.required_files_message ⇒ Object
25 26 27 |
# File 'lib/dependabot/docker/file_fetcher.rb', line 25 def self. "Repo must contain a Dockerfile or Kubernetes YAML files." end |
Instance Method Details
#fetch_files ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dependabot/docker/file_fetcher.rb', line 30 def fetch_files fetched_files = [] fetched_files += correctly_encoded_dockerfiles fetched_files += correctly_encoded_yamlfiles return fetched_files if fetched_files.any? if incorrectly_encoded_dockerfiles.none? && incorrectly_encoded_yamlfiles.none? raise Dependabot::DependencyFileNotFound.new( File.join(directory, "Dockerfile"), "No Dockerfiles nor Kubernetes YAML found in #{directory}" ) elsif incorrectly_encoded_dockerfiles.none? raise( Dependabot::DependencyFileNotParseable, T.must(incorrectly_encoded_yamlfiles.first).path ) else raise( Dependabot::DependencyFileNotParseable, T.must(incorrectly_encoded_dockerfiles.first).path ) end end |