Sha256: 009e76d84850a108b58aa8c2dcd2db2e3698e6f90c192e76b4a6edda17359f69

Contents?: true

Size: 1.65 KB

Versions: 70

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require 'avm/version'
require 'avm/entries/jobs/with_variables_source'
require 'eac_ruby_utils/core_ext'
require 'eac_docker/images/templatized'
require 'eac_docker/registry'

module Avm
  module Docker
    class Image < ::EacDocker::Images::Templatized
      prepend ::Avm::Entries::Jobs::WithVariablesSource

      DEFAULT_REGISTRY_NAME = 'local'

      class << self
        # @return [EacDocker::Registry]
        def default_registry
          ::EacDocker::Registry.new(DEFAULT_REGISTRY_NAME)
        end
      end

      attr_reader :registry
      attr_accessor :snapshot
      attr_accessor :version

      def initialize(registry = nil)
        @registry = registry || self.class.default_registry
        self.snapshot = true
        self.version = true
      end

      def build(extra_args = [])
        nyi "Extra args: #{extra_args}" if extra_args.any?

        provide
      end

      def generator_version
        ::Avm::VERSION
      end

      def push
        ::EacDocker::Executables.docker.command.append(['push', tag]).system!
      end

      def run(instance)
        run_run(instance) if container_exist?(instance)
      end

      def tag
        r = tag_name
        r += ":#{tag_version}" if tag_version.present?
        r
      end

      def tag_name
        return registry.name if registry.name.present?

        raise 'Registry name is blank'
      end

      def tag_version
        [tag_version_version, stereotype_tag].reject(&:blank?).join('_')
      end

      def tag_version_version
        return nil unless version

        r = generator_version
        r += '-snapshot' if snapshot
        r
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 2 rubygems

Version Path
avm-0.84.0 lib/avm/docker/image.rb
eac_tools-0.83.0 sub/avm/lib/avm/docker/image.rb
avm-0.83.0 lib/avm/docker/image.rb
eac_tools-0.82.0 sub/avm/lib/avm/docker/image.rb
avm-0.82.0 lib/avm/docker/image.rb
eac_tools-0.81.0 sub/avm/lib/avm/docker/image.rb
eac_tools-0.80.0 sub/avm/lib/avm/docker/image.rb
avm-0.81.0 lib/avm/docker/image.rb
eac_tools-0.79.0 sub/avm/lib/avm/docker/image.rb
avm-0.80.0 lib/avm/docker/image.rb
eac_tools-0.78.0 sub/avm/lib/avm/docker/image.rb
eac_tools-0.77.1 sub/avm/lib/avm/docker/image.rb
eac_tools-0.77.0 sub/avm/lib/avm/docker/image.rb
eac_tools-0.76.1 sub/avm/lib/avm/docker/image.rb
eac_tools-0.76.0 sub/avm/lib/avm/docker/image.rb
eac_tools-0.75.2 sub/avm/lib/avm/docker/image.rb
eac_tools-0.75.1 sub/avm/lib/avm/docker/image.rb
eac_tools-0.75.0 sub/avm/lib/avm/docker/image.rb
eac_tools-0.74.1 sub/avm/lib/avm/docker/image.rb
eac_tools-0.74.0 sub/avm/lib/avm/docker/image.rb