Sha256: 7f047cf39fa1efd413acadad1699e13a22f0fedc0d748e009c4a9a41ec441a60

Contents?: true

Size: 1.19 KB

Versions: 267

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'eac_docker/executables'
require 'eac_ruby_utils/core_ext'
require 'avm/docker/container'

module Avm
  module Instances
    class Base
      module Dockerizable
        enable_simple_cache
        attr_reader :docker_image_options

        def docker_image_options=(options)
          @docker_image_options = ::ActiveSupport::HashWithIndifferentAccess.new(options)
          reset_cache
        end

        def docker_container_exist?
          ::EacDocker::Executables.docker.command.append(
            ['ps', '-qaf', "name=#{docker_container_name}"]
          ).execute!.present?
        end

        def docker_container_name
          id
        end

        private

        def docker_container_uncached
          ::Avm::Docker::Container.new(self)
        end

        def docker_image_uncached
          r = docker_image_class.new(docker_image_options.fetch(:registry))
          r.instance = self if r.respond_to?(:instance)
          r.version = docker_image_options[:version] if docker_image_options.key?(:version)
          r.snapshot = docker_image_options[:snapshot] if docker_image_options.key?(:snapshot)
          r
        end
      end
    end
  end
end

Version data entries

267 entries across 267 versions & 3 rubygems

Version Path
eac_tools-0.62.0 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.61.1 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.61.0 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.67.1 lib/avm/instances/base/dockerizable.rb
eac_tools-0.60.3 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.60.2 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.67.0 lib/avm/instances/base/dockerizable.rb
eac_tools-0.60.1 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.60.0 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.59.0 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.66.1 lib/avm/instances/base/dockerizable.rb
eac_tools-0.58.0 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.57.0 sub/avm/lib/avm/instances/base/dockerizable.rb
eac_tools-0.56.1 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.66.0 lib/avm/instances/base/dockerizable.rb
eac_tools-0.56.0 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.65.0 lib/avm/instances/base/dockerizable.rb
eac_tools-0.55.7 sub/avm/lib/avm/instances/base/dockerizable.rb
avm-0.64.2 lib/avm/instances/base/dockerizable.rb
eac_tools-0.55.6 sub/avm/lib/avm/instances/base/dockerizable.rb