rhc 1.35.4 → 1.36.4
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/rhc/commands/app.rb +14 -2
- data/lib/rhc/commands/port_forward.rb +2 -1
- data/lib/rhc/rest/client.rb +2 -2
- data/spec/rhc/commands/app_spec.rb +43 -16
- data/spec/rhc/helpers_spec.rb +1 -1
- data/spec/rhc/rest_client_spec.rb +1 -1
- data/spec/rhc/rest_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -2
- metadata +4 -4
data/lib/rhc/commands/app.rb
CHANGED
@@ -101,6 +101,12 @@ module RHC::Commands
|
|
101
101
|
end.join(', ')
|
102
102
|
|
103
103
|
env = collect_env_vars(arg_envs.concat(Array(options.env)))
|
104
|
+
if options.env && env.empty?
|
105
|
+
raise RHC::EnvironmentVariableNotProvidedException.new(
|
106
|
+
"Environment variable(s) not provided.\n" +
|
107
|
+
"Please provide at least one environment variable using the syntax VARIABLE=VALUE. VARIABLE can only contain letters, digits and underscore ('_') and can't begin with a digit.")
|
108
|
+
end
|
109
|
+
|
104
110
|
if env.present? && !rest_domain.supports_add_application_with_env_vars?
|
105
111
|
env = []
|
106
112
|
warn "Server does not support environment variables."
|
@@ -179,7 +185,7 @@ module RHC::Commands
|
|
179
185
|
warn "not complete"
|
180
186
|
add_issue("Jenkins failed to install - #{e}",
|
181
187
|
"Installing jenkins and jenkins-client",
|
182
|
-
"rhc create-app jenkins",
|
188
|
+
"rhc create-app jenkins jenkins-1",
|
183
189
|
"rhc add-cartridge jenkins-client -a #{rest_app.name}")
|
184
190
|
end
|
185
191
|
end
|
@@ -432,10 +438,16 @@ module RHC::Commands
|
|
432
438
|
domain, app = discover_domain_and_app
|
433
439
|
gear_info = rest_client.find_application_gear_groups_endpoints(domain, app).map do |group|
|
434
440
|
group.gears.map do |gear|
|
441
|
+
color_cart = if gear['endpoints'].present?
|
442
|
+
e = gear['endpoints'].collect{ |c| c['cartridge_name'] }.uniq
|
443
|
+
lambda { |c| e.include?(c) ? color(c, :green) : c }
|
444
|
+
else
|
445
|
+
lambda { |c| c }
|
446
|
+
end
|
435
447
|
[
|
436
448
|
gear['id'],
|
437
449
|
gear['state'] == 'started' ? color(gear['state'], :green) : color(gear['state'], :yellow),
|
438
|
-
|
450
|
+
group.cartridges.collect{ |c| color_cart.call(c['name']) }.join(' '),
|
439
451
|
group.gear_profile,
|
440
452
|
gear['region'],
|
441
453
|
gear['zone'],
|
@@ -71,6 +71,7 @@ module RHC::Commands
|
|
71
71
|
syntax "<application>"
|
72
72
|
takes_application :argument => true
|
73
73
|
option ["-g", "--gear ID"], "Gear ID you are port forwarding to (optional)"
|
74
|
+
option ["-s", "--service [SERVICE,]"], "A CSV list of services to port forward (optional)"
|
74
75
|
def run(app)
|
75
76
|
rest_app = find_app
|
76
77
|
ssh_uri = URI.parse(options.gear ? rest_app.gear_ssh_url(options.gear) : rest_app.ssh_url)
|
@@ -95,7 +96,7 @@ module RHC::Commands
|
|
95
96
|
raise RHC::PermissionDeniedException.new "Permission denied." if line =~ /permission denied/i
|
96
97
|
# ...and also which services are available for the application
|
97
98
|
# for us to forward ports for.
|
98
|
-
if line =~ /\A\s*(\S+) -> #{HOST_AND_PORT}\z/
|
99
|
+
if line =~ /\A\s*(\S+) -> #{HOST_AND_PORT}\z/ and (options.service.nil? or options.service.empty? or options.service.split(',').include? $1)
|
99
100
|
debug fs = ForwardingSpec.new($1, $2, $3.to_i)
|
100
101
|
forwarding_specs << fs
|
101
102
|
else
|
data/lib/rhc/rest/client.rb
CHANGED
@@ -436,7 +436,7 @@ module RHC
|
|
436
436
|
handle_error!(e.res, args[1], client)
|
437
437
|
end
|
438
438
|
raise ConnectionException.new(
|
439
|
-
"An unexpected error
|
439
|
+
"An unexpected error occurred when connecting to the server: #{e.message}")
|
440
440
|
rescue HTTPClient::TimeoutError => e
|
441
441
|
raise TimeoutException.new(
|
442
442
|
"Connection to server timed out. "\
|
@@ -493,7 +493,7 @@ module RHC
|
|
493
493
|
raise
|
494
494
|
rescue => e
|
495
495
|
debug_error(e)
|
496
|
-
raise ConnectionException, "An unexpected error
|
496
|
+
raise ConnectionException, "An unexpected error occurred: #{e.message}", e.backtrace
|
497
497
|
end
|
498
498
|
end
|
499
499
|
end
|
@@ -775,27 +775,43 @@ describe RHC::Commands::App do
|
|
775
775
|
end
|
776
776
|
|
777
777
|
describe 'app show --gears' do
|
778
|
-
|
778
|
+
context do
|
779
|
+
let(:arguments) { ['app', 'show', 'app1', '--gears', '--raw'] }
|
779
780
|
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
781
|
+
context 'when run' do
|
782
|
+
before do
|
783
|
+
@domain = rest_client.add_domain("mockdomain")
|
784
|
+
@domain.add_application("app1", "mock_type")
|
785
|
+
end
|
786
|
+
it { run_output.should match(/ID\s+State\s+Cartridges\s+Size\s+SSH URL/) }
|
787
|
+
it { run_output.should match("fakegearid0 started mock_type small fakegearid0@fakesshurl.com") }
|
788
|
+
it { expect{ run }.to exit_with_code(0) }
|
789
|
+
end
|
790
|
+
|
791
|
+
context 'with regions and zones' do
|
792
|
+
before do
|
793
|
+
@domain = rest_client.add_domain("mockdomain")
|
794
|
+
@app = @domain.add_application("app1", "mock_type")
|
795
|
+
@app.gears.each{|g| g['region'] = 'south'; g['zone'] = 'west'}
|
796
|
+
end
|
797
|
+
it { run_output.should match(/ID\s+State\s+Cartridges\s+Size\s+Region\s+Zone\s+SSH URL/) }
|
798
|
+
it { run_output.should match(/fakegearid0\s+started\s+mock_type\s+small\s+south\s+west\s+fakegearid0@fakesshurl.com/) }
|
799
|
+
it { expect{ run }.to exit_with_code(0) }
|
784
800
|
end
|
785
|
-
it { run_output.should match(/ID\s+State\s+Cartridges\s+Size\s+SSH URL/) }
|
786
|
-
it { run_output.should match("fakegearid0 started mock_type small fakegearid0@fakesshurl.com") }
|
787
|
-
it { expect{ run }.to exit_with_code(0) }
|
788
801
|
end
|
789
802
|
|
790
|
-
context
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
803
|
+
context do
|
804
|
+
let(:arguments) { ['app', 'show', 'app1', '--gears'] }
|
805
|
+
|
806
|
+
context 'with cartridge that exposes an endpoint' do
|
807
|
+
before do
|
808
|
+
@domain = rest_client.add_domain("mockdomain")
|
809
|
+
# An application has to be scalable to expose an endpoint.
|
810
|
+
@app = @domain.add_application("app1", "mock_type", true)
|
811
|
+
@app.gears.first['endpoints'] = [{ 'cartridge_name' => 'mock_cart-1' }]
|
812
|
+
end
|
813
|
+
it { (run_output.match(/fakegearid0\s+([^\s]+)\s+small\s+fakegearid0@fakesshurl\.com/)[1]).should be_colorized("started", :green) }
|
795
814
|
end
|
796
|
-
it { run_output.should match(/ID\s+State\s+Cartridges\s+Size\s+Region\s+Zone\s+SSH URL/) }
|
797
|
-
it { run_output.should match(/fakegearid0\s+started\s+mock_type\s+small\s+south\s+west\s+fakegearid0@fakesshurl.com/) }
|
798
|
-
it { expect{ run }.to exit_with_code(0) }
|
799
815
|
end
|
800
816
|
end
|
801
817
|
|
@@ -974,5 +990,16 @@ describe RHC::Commands::App do
|
|
974
990
|
end
|
975
991
|
end
|
976
992
|
|
993
|
+
[['app', 'create', 'app1', 'mock_standalone_cart-1', '-e', 'FOOBAR'],
|
994
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'FOOBAR'],
|
995
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', '-eFOOBAR']
|
996
|
+
].each_with_index do |args, i|
|
997
|
+
context "when run with syntactically incorrect env vars #{i}" do
|
998
|
+
let(:arguments) { args }
|
999
|
+
it { expect { run }.to exit_with_code(159) }
|
1000
|
+
it { run_output.should match(/Environment variable\(s\) not provided.\nPlease provide at least one environment variable using the syntax VARIABLE=VALUE\. VARIABLE can only contain letters, digits and underscore \('_'\) and can't begin with a digit\./) }
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
977
1004
|
end
|
978
1005
|
end
|
data/spec/rhc/helpers_spec.rb
CHANGED
@@ -60,7 +60,7 @@ describe AllRhcHelpers do
|
|
60
60
|
it("should be colorized") do
|
61
61
|
message = "this is #{_color} -"
|
62
62
|
output = capture{ subject.send(method,message) }
|
63
|
-
output.should be_colorized(message,_color)
|
63
|
+
output.chomp.should be_colorized(message,_color)
|
64
64
|
end
|
65
65
|
it("should return true"){ subject.send(method,'anything').should be_true }
|
66
66
|
end
|
@@ -71,7 +71,7 @@ module RHC
|
|
71
71
|
context "against an endpoint that has a generic error" do
|
72
72
|
let(:endpoint){ mock_href('other_error') }
|
73
73
|
it "raises a generic error for any other error condition" do
|
74
|
-
expect{ client.api }.to raise_error(RHC::Rest::ConnectionException, "An unexpected error
|
74
|
+
expect{ client.api }.to raise_error(RHC::Rest::ConnectionException, "An unexpected error occurred: Other Error")
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/spec/rhc/rest_spec.rb
CHANGED
@@ -368,7 +368,7 @@ module RHC
|
|
368
368
|
stub_request(:get, mock_href).to_return(return_data)
|
369
369
|
end
|
370
370
|
it "throws an error" do
|
371
|
-
response.should raise_error(RHC::Rest::ConnectionException, 'An unexpected error
|
371
|
+
response.should raise_error(RHC::Rest::ConnectionException, 'An unexpected error occurred: unexpected nil')
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
@@ -496,7 +496,7 @@ module RHC
|
|
496
496
|
|
497
497
|
context "with a generic exception error" do
|
498
498
|
before{ stub_request(:get, mock_href).to_raise(Exception.new('Generic Error')) }
|
499
|
-
it{ response.should raise_error(RHC::Rest::ConnectionException, "An unexpected error
|
499
|
+
it{ response.should raise_error(RHC::Rest::ConnectionException, "An unexpected error occurred: Generic Error") }
|
500
500
|
end
|
501
501
|
|
502
502
|
context "with an unauthorized request" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 143
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 36
|
9
9
|
- 4
|
10
|
-
version: 1.
|
10
|
+
version: 1.36.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2015-
|
18
|
+
date: 2015-07-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: net-ssh
|