canals 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3df35b01f8f9e53a33d3b7f4f382cf5a7be93e44
4
- data.tar.gz: 54eed2eb3f91b7d9c3c0dff54d58fa19ed066062
3
+ metadata.gz: 45f4994183e88934eb7ed5641324544cc104add8
4
+ data.tar.gz: 3a512829032993ac8ae25672136b10bb9d5c90ca
5
5
  SHA512:
6
- metadata.gz: 6678efe399cdd797b6972f9db2f156747d0998b196f08259095e05eba1d22715e9348c883693b48b7aed800fb09a27f70ccbd221a5deb661bfe845ce7c0ad06e
7
- data.tar.gz: 27f72678f52e4cf58cf48ff02c3f6cc6ba3896f265e3f211e7d507bc799ba70f186cbedfbc5d27b8109b5cbd6c2fa2d2bfb8921cbcb1d46be203ae1a1e808b89
6
+ metadata.gz: 9fc53b0c66a2383a2fd2164d3da1398aced964f43d2b0cdda2367802f80c4e9b85830de3cd38a6ae41cefdd07636047404c51ddd98134c85ac9115db53e7c2ff
7
+ data.tar.gz: d6d29cf4e0db03c81f92c7f70f6a5442e71a82a71f30333285dd8ab4b306f04bc085a021a32f26a0836ad4e5d682b8b296600f0d2ffc25befb0dcdce430e4fb9
@@ -21,6 +21,12 @@ module Canals
21
21
  install_completion
22
22
  end
23
23
 
24
+ desc "bind-address", "Setup a global bind address (defaults to 127.0.0.1)"
25
+ def bind_address(bind)
26
+ Canals.config[:bind_address] = bind
27
+ Canals.config.save!
28
+ end
29
+
24
30
  no_commands do
25
31
  def setup_first_environment
26
32
  say "We'll start by setting up your first environment", :green
data/lib/canals/cli.rb CHANGED
@@ -31,6 +31,29 @@ module Canals
31
31
  say "Tunnel #{name.inspect} created.", :green
32
32
  end
33
33
 
34
+ desc 'update NAME', "Update an existing tunnel"
35
+ method_option :remote_host, :type => :string, :desc => "The remote host of the tunnel"
36
+ method_option :remote_port, :type => :string, :desc => "The remote port of the tunnel"
37
+ method_option :local_port, :type => :string, :desc => "The local port to use"
38
+ method_option :env, :type => :string, :desc => "The proxy environment to use"
39
+ method_option :hostname, :type => :string, :desc => "The proxy host we will use to connect through"
40
+ method_option :user, :type => :string, :desc => "The user for the ssh proxy host"
41
+ def update(name)
42
+ tunnel = Canals.repository.get(name)
43
+ if tunnel.nil?
44
+ say "couldn't find tunnel #{name.inspect}. try using 'create' instead", :red
45
+ return
46
+ end
47
+ if options.empty?
48
+ say "you need to specify what to update. use `canal help update` to see a list of optional updates"
49
+ return
50
+ end
51
+ opts = tunnel.to_hash.merge(options)
52
+ opts = Canals::CanalOptions.new(opts)
53
+ Canals.create_tunnel(opts)
54
+ say "Tunnel #{name.inspect} updated.", :green
55
+ end
56
+
34
57
  desc 'start NAME', 'Start tunnel'
35
58
  def start(name)
36
59
  tstart(name)
@@ -17,8 +17,13 @@ module Canals
17
17
  @env = Canals.repository.environment(@env_name)
18
18
  end
19
19
 
20
+ def to_s
21
+ return "CanalOptions<#{@args}>"
22
+ end
23
+
20
24
  def bind_address
21
25
  return @args["bind_address"] if @args["bind_address"]
26
+ return Canals.config[:bind_address] if Canals.config[:bind_address]
22
27
  return BIND_ADDRESS
23
28
  end
24
29
 
@@ -35,6 +35,7 @@ module Canals
35
35
  end
36
36
 
37
37
  def get(name)
38
+ return nil if !@repo[:tunnels].has_key? name
38
39
  CanalOptions.new(@repo[:tunnels][name])
39
40
  end
40
41
 
@@ -1,6 +1,6 @@
1
1
  module Canals
2
2
 
3
3
  # Canals gem current version
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3"
5
5
 
6
6
  end
@@ -8,6 +8,7 @@ describe Canals::CanalOptions do
8
8
  let(:remote_port) { 1234 }
9
9
  let(:local_port) { 4321 }
10
10
  let(:bind_address) { "1.2.3.4" }
11
+ let(:global_bind_address) { "4.3.2.1" }
11
12
  let(:hostname) { "nat.example.com" }
12
13
  let(:user) { "user" }
13
14
  let(:pem) { "/tmp/file.pem" }
@@ -81,16 +82,25 @@ describe Canals::CanalOptions do
81
82
 
82
83
  describe "bind_address" do
83
84
  it "returns 'bind_address' if 'bind_address' is availble" do
84
- args = {"name" => name, "remote_host" => remote_host, "remote_port" => remote_port, "local_port" => local_port, "bind_address" => bind_address}
85
+ allow(Canals.config).to receive(:[]).with(:bind_address).and_return(global_bind_address)
86
+ args = {"name" => name, "remote_host" => remote_host, "remote_port"=> remote_port, "local_port" => local_port, "bind_address" => bind_address}
85
87
  opt = Canals::CanalOptions.new(args)
86
88
  expect(opt.bind_address).to eq bind_address
87
89
  end
88
90
 
89
- it "returns 'Canals::CanalOptions::BIND_ADDRESS' for 'bind_address' if 'bind_address' isn't given" do
91
+ it "returns 'Canals::CanalOptions::BIND_ADDRESS' for 'bind_address' if 'bind_address' isn't given and no global bind_address" do
92
+ allow(Canals.config).to receive(:[]).with(:bind_address).and_return(nil)
90
93
  args = {"name" => name, "remote_host" => remote_host, "remote_port" => remote_port, "local_port" => local_port}
91
94
  opt = Canals::CanalOptions.new(args)
92
95
  expect(opt.bind_address).to eq Canals::CanalOptions::BIND_ADDRESS
93
96
  end
97
+
98
+ it "returns 'Canals.config[:bind_address]' for 'bind_address' if 'bind_address' isn't given and global bind_address" do
99
+ allow(Canals.config).to receive(:[]).with(:bind_address).and_return(global_bind_address)
100
+ args = {"name" => name, "remote_host" => remote_host, "remote_port" => remote_port, "local_port" => local_port}
101
+ opt = Canals::CanalOptions.new(args)
102
+ expect(opt.bind_address).to eq global_bind_address
103
+ end
94
104
  end
95
105
 
96
106
  describe "environment variables" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ido Abramovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor