Sha256: fba5e207c5356e3a3420bb144f293e60eab03f13a540dafa7b0a06304587240d

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module Percheron
  class Unit
    module ImageHelper
      def image_name
        '%s:%s' % [ image_repo, image_version.to_s ] if image_repo && image_version
      end

      def image_repo
        if !buildable?
          unit_config.docker_image.split(':')[0]
        elsif pseudo?
          pseudo_full_name
        else
          full_name
        end
      end

      def image_version
        if buildable?
          unit_config.version
        elsif !unit_config.docker_image.nil?
          unit_config.docker_image.split(':')[1] || 'latest'
        else
          fail Errors::UnitInvalid, 'Cannot determine image version'
        end
      end

      def image_exists?
        image.nil? ? false : true
      end

      def image_size
        image.nil? ? nil : '%s MB' % [ image.info['VirtualSize'] / 1_048_576 ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
percheron-0.8.1 lib/percheron/unit/image_helper.rb