Sha256: 6b96718559e71725aec7ca579ff6713e330de5de3941d3009f2dad815f8a68f0

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require "active_support/core_ext/string/filters"

class Kamal::Commands::Builder < Kamal::Commands::Base
  delegate :create, :remove, :push, :clean, :pull, :info, to: :target

  def name
    target.class.to_s.remove("Kamal::Commands::Builder::").underscore.inquiry
  end

  def target
    case
    when !config.builder.multiarch? && !config.builder.cached?
      native
    when !config.builder.multiarch? && config.builder.cached?
      native_cached
    when config.builder.local? && config.builder.remote?
      multiarch_remote
    when config.builder.remote?
      native_remote
    else
      multiarch
    end
  end

  def native
    @native ||= Kamal::Commands::Builder::Native.new(config)
  end

  def native_cached
    @native ||= Kamal::Commands::Builder::Native::Cached.new(config)
  end

  def native_remote
    @native ||= Kamal::Commands::Builder::Native::Remote.new(config)
  end

  def multiarch
    @multiarch ||= Kamal::Commands::Builder::Multiarch.new(config)
  end

  def multiarch_remote
    @multiarch_remote ||= Kamal::Commands::Builder::Multiarch::Remote.new(config)
  end


  def ensure_local_dependencies_installed
    if name.native?
      ensure_local_docker_installed
    else
      combine \
        ensure_local_docker_installed,
        ensure_local_buildx_installed
    end
  end

  private
    def ensure_local_docker_installed
      docker "--version"
    end

    def ensure_local_buildx_installed
      docker :buildx, "version"
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamal-0.16.1 lib/kamal/commands/builder.rb