tunnel-vmc-plugin 0.1.11 → 0.2.0
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.
- data/lib/tunnel-vmc-plugin/plugin.rb +14 -15
- data/lib/tunnel-vmc-plugin/version.rb +1 -1
- data/spec/plugin_spec.rb +29 -0
- data/spec/spec_helper.rb +15 -0
- metadata +41 -25
|
@@ -64,6 +64,18 @@ module VMCTunnel
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def tunnel_clients
|
|
68
|
+
return @tunnel_clients if @tunnel_clients
|
|
69
|
+
stock_config = YAML.load_file(STOCK_CLIENTS)
|
|
70
|
+
custom_config_file = File.expand_path(CLIENTS_FILE)
|
|
71
|
+
if File.exists?(custom_config_file)
|
|
72
|
+
custom_config = YAML.load_file(custom_config_file)
|
|
73
|
+
@tunnel_clients = deep_merge(stock_config, custom_config)
|
|
74
|
+
else
|
|
75
|
+
@tunnel_clients = stock_config
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
67
79
|
private
|
|
68
80
|
|
|
69
81
|
def display_tunnel_connection_info(info)
|
|
@@ -131,19 +143,6 @@ module VMCTunnel
|
|
|
131
143
|
system(cmdline)
|
|
132
144
|
end
|
|
133
145
|
|
|
134
|
-
def tunnel_clients
|
|
135
|
-
return @tunnel_clients if @tunnel_clients
|
|
136
|
-
|
|
137
|
-
stock = YAML.load_file(STOCK_CLIENTS)
|
|
138
|
-
clients = File.expand_path CLIENTS_FILE
|
|
139
|
-
if File.exists? clients
|
|
140
|
-
user = YAML.load_file(clients)
|
|
141
|
-
@tunnel_clients = deep_merge(stock, user)
|
|
142
|
-
else
|
|
143
|
-
@tunnel_clients = stock
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
146
|
def resolve_symbols(str, info, local_port)
|
|
148
147
|
str.gsub(/\$\{\s*([^\}]+)\s*\}/) do
|
|
149
148
|
sym = $1
|
|
@@ -165,8 +164,8 @@ module VMCTunnel
|
|
|
165
164
|
end
|
|
166
165
|
|
|
167
166
|
def deep_merge(a, b)
|
|
168
|
-
merge = proc { |old, new|
|
|
169
|
-
if old
|
|
167
|
+
merge = proc { |_, old, new|
|
|
168
|
+
if old.is_a?(Hash) && new.is_a?(Hash)
|
|
170
169
|
old.merge(new, &merge)
|
|
171
170
|
else
|
|
172
171
|
new
|
data/spec/plugin_spec.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe VMCTunnel::Tunnel do
|
|
4
|
+
describe "#tunnel_clients" do
|
|
5
|
+
context "when the user has a custom clients.yml in their vmc directory" do
|
|
6
|
+
use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/with_custom_clients" }
|
|
7
|
+
|
|
8
|
+
it "overrides the default client config with the user's customizations" do
|
|
9
|
+
expect(subject.tunnel_clients["postgresql"]).to eq({
|
|
10
|
+
"psql" => {
|
|
11
|
+
"command"=>"-h ${host} -p ${port} -d ${name} -U ${user} -w",
|
|
12
|
+
"environment" => ["PGPASSWORD='dont_ask_password'"]
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "when the user does not have a custom clients.yml" do
|
|
19
|
+
it "returns the default client config" do
|
|
20
|
+
expect(subject.tunnel_clients["postgresql"]).to eq({
|
|
21
|
+
"psql" => {
|
|
22
|
+
"command"=>"-h ${host} -p ${port} -d ${name} -U ${user} -w",
|
|
23
|
+
"environment" => ["PGPASSWORD='${password}'"]
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
SPEC_ROOT = File.dirname(__FILE__).freeze
|
|
2
|
+
|
|
3
|
+
require "rspec"
|
|
4
|
+
require "cfoundry"
|
|
5
|
+
require "cfoundry/test_support"
|
|
6
|
+
require "vmc"
|
|
7
|
+
require "vmc/test_support"
|
|
8
|
+
|
|
9
|
+
require "#{SPEC_ROOT}/../lib/tunnel-vmc-plugin/plugin"
|
|
10
|
+
|
|
11
|
+
RSpec.configure do |c|
|
|
12
|
+
c.include Fake::FakeMethods
|
|
13
|
+
c.mock_with :rr
|
|
14
|
+
c.include VMC::TestSupport::FakeHomeDir
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tunnel-vmc-plugin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 0.
|
|
8
|
+
- 2
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.2.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Alex Suraci
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2013-
|
|
18
|
+
date: 2013-02-06 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: cfoundry
|
|
@@ -25,12 +25,12 @@ dependencies:
|
|
|
25
25
|
requirements:
|
|
26
26
|
- - ~>
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
hash:
|
|
28
|
+
hash: 11
|
|
29
29
|
segments:
|
|
30
30
|
- 0
|
|
31
|
-
-
|
|
31
|
+
- 5
|
|
32
32
|
- 0
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 0.5.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
version_requirements: *id001
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
@@ -100,12 +100,13 @@ dependencies:
|
|
|
100
100
|
requirement: &id006 !ruby/object:Gem::Requirement
|
|
101
101
|
none: false
|
|
102
102
|
requirements:
|
|
103
|
-
- -
|
|
103
|
+
- - ~>
|
|
104
104
|
- !ruby/object:Gem::Version
|
|
105
|
-
hash:
|
|
105
|
+
hash: 25
|
|
106
106
|
segments:
|
|
107
107
|
- 0
|
|
108
|
-
|
|
108
|
+
- 9
|
|
109
|
+
version: "0.9"
|
|
109
110
|
type: :development
|
|
110
111
|
version_requirements: *id006
|
|
111
112
|
- !ruby/object:Gem::Dependency
|
|
@@ -116,31 +117,43 @@ dependencies:
|
|
|
116
117
|
requirements:
|
|
117
118
|
- - ~>
|
|
118
119
|
- !ruby/object:Gem::Version
|
|
119
|
-
hash:
|
|
120
|
+
hash: 21
|
|
120
121
|
segments:
|
|
121
122
|
- 2
|
|
122
|
-
-
|
|
123
|
-
version: "2.
|
|
123
|
+
- 11
|
|
124
|
+
version: "2.11"
|
|
124
125
|
type: :development
|
|
125
126
|
version_requirements: *id007
|
|
126
127
|
- !ruby/object:Gem::Dependency
|
|
127
|
-
name:
|
|
128
|
+
name: webmock
|
|
128
129
|
prerelease: false
|
|
129
130
|
requirement: &id008 !ruby/object:Gem::Requirement
|
|
130
131
|
none: false
|
|
131
132
|
requirements:
|
|
132
|
-
- -
|
|
133
|
+
- - ~>
|
|
133
134
|
- !ruby/object:Gem::Version
|
|
134
|
-
hash:
|
|
135
|
+
hash: 29
|
|
135
136
|
segments:
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
- beta
|
|
140
|
-
- 42
|
|
141
|
-
version: 0.4.0.beta.42
|
|
137
|
+
- 1
|
|
138
|
+
- 9
|
|
139
|
+
version: "1.9"
|
|
142
140
|
type: :development
|
|
143
141
|
version_requirements: *id008
|
|
142
|
+
- !ruby/object:Gem::Dependency
|
|
143
|
+
name: rr
|
|
144
|
+
prerelease: false
|
|
145
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
146
|
+
none: false
|
|
147
|
+
requirements:
|
|
148
|
+
- - ~>
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
hash: 15
|
|
151
|
+
segments:
|
|
152
|
+
- 1
|
|
153
|
+
- 0
|
|
154
|
+
version: "1.0"
|
|
155
|
+
type: :development
|
|
156
|
+
version_requirements: *id009
|
|
144
157
|
description:
|
|
145
158
|
email:
|
|
146
159
|
- asuraci@vmware.com
|
|
@@ -159,6 +172,8 @@ files:
|
|
|
159
172
|
- helper-app/Gemfile.lock
|
|
160
173
|
- helper-app/server.rb
|
|
161
174
|
- config/clients.yml
|
|
175
|
+
- spec/plugin_spec.rb
|
|
176
|
+
- spec/spec_helper.rb
|
|
162
177
|
homepage: http://cloudfoundry.com/
|
|
163
178
|
licenses: []
|
|
164
179
|
|
|
@@ -192,5 +207,6 @@ rubygems_version: 1.8.24
|
|
|
192
207
|
signing_key:
|
|
193
208
|
specification_version: 3
|
|
194
209
|
summary: External access to your services on Cloud Foundry via a Caldecott HTTP tunnel.
|
|
195
|
-
test_files:
|
|
196
|
-
|
|
210
|
+
test_files:
|
|
211
|
+
- spec/plugin_spec.rb
|
|
212
|
+
- spec/spec_helper.rb
|