class Kamaze::DockerImage
Describe a docker image
Constants
- VERSION
Attributes
Get commands
Commands as run by runner
@see Kamaze::DockerImage::Runner#command
@see Kamaze::DockerImage::Concern::Setup#default_commands
@return [Hash]
Executable path or name for “docker“
@return [String]
Get image name
@return [String]
@see Concern::Setup#setup_defaults
@type [String]
Get name used to run container
@return [String]
@return [Runner]
Config related to ssh.
@return [Hash|nil]
Get namespace used for tasks
@return [String|Symbol|nil]
@see Concern::Setup#setup_defaults
@type [Boolean]
Get version
@return [String]
Public Class Methods
# File lib/kamaze/docker_image.rb, line 84 def initialize(&block) setup(caller_locations, &block) @runner = Runner.new(self) @ssh = SSH.new(self).freeze tasks_load! if tasks_load? end
Public Instance Methods
Get name of available commands.
@return [Array<Symbol>]
# File lib/kamaze/docker_image.rb, line 125 def available_commands commands.clone.reject { |_k, args| args.nil? }.to_h.keys.sort end
Get image id (through docker command).
@return [String, nil]
# File lib/kamaze/docker_image.rb, line 95 def id # docker image list --format "{{json .ID}}" image_name:image_version [ self.to_h[:docker_bin] || executable ].concat(['image', 'list', '--format', '{{json .ID}}', self.to_s]).yield_self do |command| Open3.capture3(*command).tap do |stdout, _, status| return nil unless status.success? return stdout.lines.empty? ? nil : JSON.parse(stdout.lines.first) end end end
@see Runner#actions
# File lib/kamaze/docker_image.rb, line 163 def method_missing(method, *args, &block) respond_to_missing?(method) ? runner.public_send(method, *args, &block) : super end
@return [Pathname]
# File lib/kamaze/docker_image.rb, line 158 def path Pathname.new(@path) end
# File lib/kamaze/docker_image.rb, line 167 def respond_to_missing?(method, include_private = false) # rubocop:disable Style/RedundantParentheses (runner&.actions).to_a.include?(method.to_sym) || super(method, include_private) # rubocop:enable Style/RedundantParentheses end
Denote image is running?.
@return [Boolean]
# File lib/kamaze/docker_image.rb, line 118 def running? runner.running? end
Denote image is started.
@return [Boolean]
# File lib/kamaze/docker_image.rb, line 111 def started? runner.started? end
Get tag
tag has the following format: “#{name}:#{version}“
@return [String]
# File lib/kamaze/docker_image.rb, line 134 def tag "#{name}:#{version}" end
@return [Boolean]
# File lib/kamaze/docker_image.rb, line 153 def tasks_load? !!self.tasks_load end
@return [Hash]
# File lib/kamaze/docker_image.rb, line 141 def to_h readable_attrs_values .to_h.tap { |h| h.merge!(tag: tag) } .sort.to_h end
@return [Boolean]
# File lib/kamaze/docker_image.rb, line 148 def verbose? !!@verbose end
Protected Instance Methods
Load tasks
# File lib/kamaze/docker_image.rb, line 220 def tasks_load! self.tap { Loader.new(self).call } end