Class: Dependabot::DockerCompose::FileUpdater

Inherits:
Shared::SharedFileUpdater
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dependabot/docker_compose/file_updater.rb

Constant Summary collapse

YAML_REGEXP =
/(docker-)?compose(?>\.[\w-]+)?\.ya?ml/i
IMAGE_REGEX =
/(?:from|image:\s*)/i

Instance Method Summary collapse

Instance Method Details

#build_old_declaration_regex(escaped_declaration) ⇒ Object



31
32
33
# File 'lib/dependabot/docker_compose/file_updater.rb', line 31

def build_old_declaration_regex(escaped_declaration)
  %r{#{IMAGE_REGEX}\s+["']?(?:\$\{[^\}:]+:-)?(docker\.io/)?#{escaped_declaration}(?:\})?["']?(?=\s|$)}
end

#container_image_regexObject



26
27
28
# File 'lib/dependabot/docker_compose/file_updater.rb', line 26

def container_image_regex
  IMAGE_REGEX
end

#file_typeObject



16
17
18
# File 'lib/dependabot/docker_compose/file_updater.rb', line 16

def file_type
  "Docker compose"
end

#updated_dependency_filesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dependabot/docker_compose/file_updater.rb', line 36

def updated_dependency_files
  updated_files = []
  dependency_files.each do |file|
    next unless requirement_changed?(file, T.must(dependency))

    updated_files << updated_file(
      file: file,
      content: T.must(updated_dockerfile_content(file))
    )
  end

  updated_files.reject! { |f| dependency_files.include?(f) }
  raise "No files changed!" if updated_files.none?

  updated_files
end

#yaml_file_patternObject



21
22
23
# File 'lib/dependabot/docker_compose/file_updater.rb', line 21

def yaml_file_pattern
  YAML_REGEXP
end