27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/tunnel-cf-plugin/plugin.rb', line 27
def tunnel
instances = client.service_instances
fail "No services available for tunneling." if instances.empty?
instance = input[:instance, instances.sort_by(&:name)]
vendor = instance.service_plan.service.label
clients = tunnel_clients[vendor] || {}
client_name = input[:client, clients]
tunnel = CFTunnel.new(client, instance)
port = tunnel.pick_port!(input[:port])
conn_info =
with_progress("Opening tunnel on port #{c(port, :name)}") do
tunnel.open!
end
if client_name == "none"
unless quiet?
line
display_tunnel_connection_info(conn_info)
line
line "Open another shell to run command-line clients or"
line "use a UI tool to connect using the displayed information."
line "Press Ctrl-C to exit..."
end
tunnel.wait_for_end
else
with_progress("Waiting for local tunnel to become available") do
tunnel.wait_for_start
end
unless start_local_prog(clients, client_name, conn_info, port)
fail "'#{client_name}' execution failed; is it in your $PATH?"
end
end
end
|