Class: Kamal::Lint::Checks::ImageRegistryMismatch
- Inherits:
-
Kamal::Lint::Check
- Object
- Kamal::Lint::Check
- Kamal::Lint::Checks::ImageRegistryMismatch
- Defined in:
- lib/kamal/lint/checks/image_registry_mismatch.rb
Constant Summary collapse
- DOCKER_HUB_HOSTS =
Docker Hub accepts unprefixed images (‘myorg/myapp` resolves to `docker.io/myorg/myapp`), so we don’t flag a missing prefix when the configured registry is Docker Hub under any of its canonical names.
%w[docker.io index.docker.io registry.hub.docker.com].freeze
Instance Attribute Summary
Attributes inherited from Kamal::Lint::Check
Instance Method Summary collapse
Methods inherited from Kamal::Lint::Check
applies_to?, autofixable, id, #initialize, severity, since, title, until_version
Constructor Details
This class inherits a constructor from Kamal::Lint::Check
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kamal/lint/checks/image_registry_mismatch.rb', line 17 def call image = parsed["image"] registry = parsed["registry"] || parsed.dig("builder", "registry") || {} server = registry["server"] if registry.is_a?(Hash) return [] unless image.is_a?(String) && server.is_a?(String) && !server.empty? normalized_server = server.sub(%r{/+\z}, "") return [] if DOCKER_HUB_HOSTS.include?(normalized_server) prefix = "#{normalized_server}/" return [] if image.start_with?(prefix) [ finding( message: "image `#{image}` does not include the configured registry `#{server}`; Kamal will push to the wrong registry", line: context.line_for([ "image" ]) ) ] end |