Sha256: a8ff19d7efc9d4c097017e4f96a3dea41edb49320b72b3bda3a9c86c0662e544

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

require "docktor/manifest_parser"
require "docktor/docker_client"

module Docktor
  class Runner
    class ContainerNotFound < StandardError; end

    DEFAULT_YAML_PATH = "./docktor.yml"

    def invoke(
      container_name: nil,
      yaml_path: DEFAULT_YAML_PATH,
      parser: Docktor::ManifestParser.new,
      client: Docktor::DockerClient.new
    )
      manifest = parser.parse(yaml_path)

      manifest.select_container_for_execution(container_name) if container_name.present?

      manifest.containers_for_execution.each do |container|
        if client.container_exists?(container)
          client.start container
        else
          client.run container
        end
      end
    rescue Docktor::Manifest::ContainerNotFound => e
      raise ContainerNotFound, e.message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docktor-0.2.0 lib/docktor/runner.rb