Class: VMCTunnel::Tunnel
- Inherits:
-
VMC::CLI
- Object
- Mothership
- VMC::CLI
- VMCTunnel::Tunnel
- Defined in:
- lib/tunnel-vmc-plugin/plugin.rb
Constant Summary collapse
- CLIENTS_FILE =
"#{VMC::CONFIG_DIR}/tunnel-clients.yml"
- STOCK_CLIENTS =
File.("../../../config/clients.yml", __FILE__)
Constants inherited from Mothership
Instance Attribute Summary
Attributes inherited from Mothership
Instance Method Summary collapse
Methods inherited from VMC::CLI
#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #debug?, #default_action, #ensure_config_dir, #err, #execute, #fail, #fail_unknown, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #normalize_targets_info, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #save_token_if_it_changes, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?, #wrap_errors
Methods included from VMC::Spacing
#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes
Methods included from VMC::Interactive
#ask, #handler, #input_state, #list_choices, #prompt, #show_default
Methods inherited from Mothership
add_input, after, alias_command, around, before, change_argument, commands, #default_action, desc, #execute, #exit_status, #filter, filter, global_option, group, #help, #initialize, input, #interact, interactions, #invoke, method_added, option, #run, start, #unknown_command, #with_filters
Constructor Details
This class inherits a constructor from Mothership
Instance Method Details
#tunnel ⇒ Object
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-vmc-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 = v2? ? instance.service_plan.service.label : instance.vendor 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, port) 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 |
#tunnel_clients ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tunnel-vmc-plugin/plugin.rb', line 67 def tunnel_clients return @tunnel_clients if @tunnel_clients stock_config = YAML.load_file(STOCK_CLIENTS) custom_config_file = File.(CLIENTS_FILE) if File.exists?(custom_config_file) custom_config = YAML.load_file(custom_config_file) @tunnel_clients = deep_merge(stock_config, custom_config) else @tunnel_clients = stock_config end end |