Class: Dependabot::Helm::FileUpdater

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

Defined Under Namespace

Classes: ChartUpdater, ImageUpdater, LockFileGenerator

Constant Summary collapse

CHART_YAML_REGEXP =
/Chart\.ya?ml/i
CHART_LOCK_REGEXP =
/Chart\.lock/i
VALUES_YAML_REGEXP =
/values(?>\.[\w-]+)?\.ya?ml/i
YAML_REGEXP =
/(Chart|values(?>\.[\w-]+)?)\.ya?ml/i
IMAGE_REGEX =
/(?:image:|repository:\s*)/i

Instance Method Summary collapse

Instance Method Details

#build_old_declaration_regex(escaped_declaration) ⇒ Object



38
39
40
# File 'lib/dependabot/helm/file_updater.rb', line 38

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

#container_image_regexObject



33
34
35
# File 'lib/dependabot/helm/file_updater.rb', line 33

def container_image_regex
  IMAGE_REGEX
end

#file_typeObject



23
24
25
# File 'lib/dependabot/helm/file_updater.rb', line 23

def file_type
  "Helm chart"
end

#updated_dependency_filesObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/dependabot/helm/file_updater.rb', line 43

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

    if file.name.match?(CHART_YAML_REGEXP)
      updated_content = chart_updater.updated_chart_yaml_content(file)
      updated_files << updated_file(
        file: file,
        content: T.must(updated_content)
      )

      updated_files.concat(update_chart_locks(T.must(updated_content))) if chart_locks
    elsif file.name.match?(VALUES_YAML_REGEXP)
      updated_files << updated_file(
        file: file,
        content: T.must(image_updater.updated_values_yaml_content(file.name))
      )
    end
  end

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

  updated_files
end

#yaml_file_patternObject



28
29
30
# File 'lib/dependabot/helm/file_updater.rb', line 28

def yaml_file_pattern
  YAML_REGEXP
end