Class: Train::Transports::Podman::Connection
- Inherits:
-
BaseConnection
- Object
- BaseConnection
- Train::Transports::Podman::Connection
- Defined in:
- lib/train/transports/podman.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #unique_identifier ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/train/transports/podman.rb', line 56 def initialize() super() @id = [:host] if RUBY_PLATFORM =~ /windows|mswin|msys|mingw|cygwin/ raise "Unsupported host platform." end # Currently Podman url can be set using option and setting the environment variable. uid = Process.uid podman_url = [:podman_url] || ENV["CONTAINER_HOST"] podman_url ||= "unix:///run/podman/podman.sock" if uid == 0 podman_url ||= "unix:///run/user/#{uid}/podman/podman.sock" Docker.url = podman_url # Using docker-api ruby library to fetch the Podman container data. @container = ::Docker::Container.get(@id) || raise("Can't find Podman container #{@id}") @cmd_wrapper = nil @cmd_wrapper = CommandWrapper.load(self, @options) @probably_windows = nil rescue Excon::Error::Socket raise Train::TransportError, "Unable to connect to Podman using #{podman_url}" rescue Docker::Error::NotFoundError => e raise Train::TransportError, "Container Not Found: #{e.}" rescue Docker::Error::ServerError => e raise Train::TransportError, "#{e.}" end |
Instance Method Details
#close ⇒ Object
87 88 89 |
# File 'lib/train/transports/podman.rb', line 87 def close # nothing to do at the moment end |
#unique_identifier ⇒ Object
99 100 101 |
# File 'lib/train/transports/podman.rb', line 99 def unique_identifier @container.nil? ? @id : @container.id # default uuid set to the podman host. end |
#uri ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/train/transports/podman.rb', line 91 def uri if @container.nil? "podman://#{@id}" else "podman://#{@container.id}" end end |