Sha256: d2d2ede3f74ea140483b5a25bd7b08d25ca71a0d657f4f017fc4bb1874a82d0b

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

module Percheron
  module Actions
    class Shell
      include Base

      DEFAULT_SHELL = '/bin/sh'
      DOCKER_CLIENT = 'docker'

      def initialize(container, shell: DEFAULT_SHELL)
        @container = container
        @shell = shell
      end

      def execute!
        $logger.debug "Executing #{shell} on '#{container.name}' container"
        exec! if valid?
      end

      private

        attr_reader :container, :shell

        def valid?
          Validators::DockerClient.new.valid?
        end

        def exec!
          system('%s exec -ti %s %s' % [ DOCKER_CLIENT, container.full_name, shell ])
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percheron-0.7.4 lib/percheron/actions/shell.rb
percheron-0.7.3 lib/percheron/actions/shell.rb