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 +4 -4
- data/lib/canals/cli/setup.rb +6 -0
- data/lib/canals/cli.rb +23 -0
- data/lib/canals/options.rb +5 -0
- data/lib/canals/repository.rb +1 -0
- data/lib/canals/version.rb +1 -1
- data/spec/canals/options_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45f4994183e88934eb7ed5641324544cc104add8
|
4
|
+
data.tar.gz: 3a512829032993ac8ae25672136b10bb9d5c90ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc53b0c66a2383a2fd2164d3da1398aced964f43d2b0cdda2367802f80c4e9b85830de3cd38a6ae41cefdd07636047404c51ddd98134c85ac9115db53e7c2ff
|
7
|
+
data.tar.gz: d6d29cf4e0db03c81f92c7f70f6a5442e71a82a71f30333285dd8ab4b306f04bc085a021a32f26a0836ad4e5d682b8b296600f0d2ffc25befb0dcdce430e4fb9
|
data/lib/canals/cli/setup.rb
CHANGED
@@ -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)
|
data/lib/canals/options.rb
CHANGED
@@ -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
|
|
data/lib/canals/repository.rb
CHANGED
data/lib/canals/version.rb
CHANGED
data/spec/canals/options_spec.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|