Class: Dependabot::DockerCompose::FileUpdater

Inherits:
Shared::SharedFileUpdater 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

Constants inherited from Shared::SharedFileUpdater

Shared::SharedFileUpdater::FROM_REGEX

Instance Method Summary collapse

Instance Method Details

#build_old_declaration_regex(escaped_declaration) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/docker_compose/file_updater.rb', line 31

def build_old_declaration_regex(escaped_declaration)
  %r{
    #{IMAGE_REGEX}
    (?:[>|][-+]?\s*)?              # optional YAML block scalar indicator (folded/literal)
    \s+
    ["']?
    (?:\$\{[^\}:]+:-)?
    (docker\.io/)?
    #{escaped_declaration}
    (?:\})?
    ["']?
    (?=\s|$)
  }x
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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dependabot/docker_compose/file_updater.rb', line 47

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