Class: Gitlab::QA::Docker::Engine
- Inherits:
-
Object
- Object
- Gitlab::QA::Docker::Engine
- Defined in:
- lib/gitlab/qa/docker/engine.rb
Constant Summary collapse
- DOCKER_HOST =
ENV['DOCKER_HOST'] || 'http://localhost'
Instance Method Summary collapse
- #attach(name, &block) ⇒ Object
- #exec(name, command) ⇒ Object
- #hostname ⇒ Object
- #network_create(name) ⇒ Object
- #network_exists?(name) ⇒ Boolean
- #port(name, port) ⇒ Object
- #pull(image, tag) ⇒ Object
- #read_file(image, tag, path, &block) ⇒ Object
- #remove(name) ⇒ Object
- #restart(name) ⇒ Object
- #run(image, tag, *args) ⇒ Object
- #stop(name) ⇒ Object
Instance Method Details
#attach(name, &block) ⇒ Object
35 36 37 |
# File 'lib/gitlab/qa/docker/engine.rb', line 35 def attach(name, &block) Docker::Command.execute("attach --sig-proxy=false #{name}", &block) end |
#exec(name, command) ⇒ Object
26 27 28 |
# File 'lib/gitlab/qa/docker/engine.rb', line 26 def exec(name, command) Docker::Command.execute("exec #{name} bash -c '#{command}'") end |
#hostname ⇒ Object
7 8 9 |
# File 'lib/gitlab/qa/docker/engine.rb', line 7 def hostname URI(DOCKER_HOST).host end |
#network_create(name) ⇒ Object
59 60 61 |
# File 'lib/gitlab/qa/docker/engine.rb', line 59 def network_create(name) Docker::Command.execute("network create #{name}") end |
#network_exists?(name) ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/gitlab/qa/docker/engine.rb', line 51 def network_exists?(name) Docker::Command.execute("network inspect #{name}") rescue Docker::Shellout::StatusError false else true end |
#port(name, port) ⇒ Object
63 64 65 |
# File 'lib/gitlab/qa/docker/engine.rb', line 63 def port(name, port) Docker::Command.execute("port #{name} #{port}/tcp") end |
#pull(image, tag) ⇒ Object
11 12 13 |
# File 'lib/gitlab/qa/docker/engine.rb', line 11 def pull(image, tag) Docker::Command.execute("pull #{image}:#{tag}") end |
#read_file(image, tag, path, &block) ⇒ Object
30 31 32 33 |
# File 'lib/gitlab/qa/docker/engine.rb', line 30 def read_file(image, tag, path, &block) cat_file = "run --rm --entrypoint /bin/cat #{image}:#{tag} #{path}" Docker::Command.execute(cat_file, &block) end |
#remove(name) ⇒ Object
47 48 49 |
# File 'lib/gitlab/qa/docker/engine.rb', line 47 def remove(name) Docker::Command.execute("rm -f #{name}") end |
#restart(name) ⇒ Object
39 40 41 |
# File 'lib/gitlab/qa/docker/engine.rb', line 39 def restart(name) Docker::Command.execute("restart #{name}") end |