Sha256: 2b339d5b523fbdffc760b4070ce499228223fd4a605ef1af55b727546eed1d86

Contents?: true

Size: 1.09 KB

Versions: 104

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

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?
          ::Avm::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.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

104 entries across 104 versions & 1 rubygems

Version Path
avm-tools-0.70.2 lib/avm/instances/base/dockerizable.rb
avm-tools-0.70.1 lib/avm/instances/base/dockerizable.rb
avm-tools-0.70.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.69.3 lib/avm/instances/base/dockerizable.rb
avm-tools-0.69.2 lib/avm/instances/base/dockerizable.rb
avm-tools-0.69.1 lib/avm/instances/base/dockerizable.rb
avm-tools-0.69.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.68.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.67.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.66.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.65.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.64.2 lib/avm/instances/base/dockerizable.rb
avm-tools-0.64.1 lib/avm/instances/base/dockerizable.rb
avm-tools-0.64.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.63.0 lib/avm/instances/base/dockerizable.rb
avm-tools-0.62.4 lib/avm/instances/base/dockerizable.rb
avm-tools-0.62.3 lib/avm/instances/base/dockerizable.rb
avm-tools-0.62.2 lib/avm/instances/base/dockerizable.rb
avm-tools-0.62.1 lib/avm/instances/base/dockerizable.rb
avm-tools-0.62.0 lib/avm/instances/base/dockerizable.rb