Method: PDQTest::Instance.shell
- Defined in:
- lib/pdqtest/instance.rb
.shell ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/pdqtest/instance.rb', line 117 def self.shell # pick the first test platform to test on as our shell - want to do a specific one # just list it with --image-name image_name = (@@image_name || Docker::acceptance_test_images).first $logger.info "Opening a shell in #{image_name}" @@active_container = PDQTest::Docker::new_container(image_name, @@privileged) # Shell is always executed with docker - if you want a new shell for # in-place, your already in it ;-) PDQTest::Execution.exec(PDQTest::Docker, @@active_container, PDQTest::Puppet.setup) # In theory I should be able to get something like the code below to # redirect all input streams and give a makeshift interactive shell, howeve # I'm damned if I get get this to do anything at all, so instead go the # easy way and start the container running, then use system() to redirect # all streams using the regular docker command. Works a treat! # @@active_container.tap(&:start).attach(:tty => true) # @@active_container.exec('bash', tty: true).tap(&:start).attach( :tty => true, :stdin => $stdin) { |out, err| # puts out # puts err # } system("docker exec -ti #{@@active_container.id} #{Util.shell}") if @@keep_container $logger.info "finished build, container #{@@active_container.id} left on system" $logger.info " docker exec -ti #{@@active_container.id} #{Util.shell} " else PDQTest::Docker.cleanup_container(@@active_container) @@active_container = nil end end |