rhc 1.13.6 → 1.14.7
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/features/env.feature +35 -0
- data/features/lib/rhc_helper.rb +1 -0
- data/features/lib/rhc_helper/commandify.rb +25 -3
- data/features/lib/rhc_helper/env.rb +29 -0
- data/features/step_definitions/env_steps.rb +31 -0
- data/features/support/platform_support.rb +3 -13
- data/lib/rhc/cartridge_helpers.rb +4 -2
- data/lib/rhc/commands.rb +5 -1
- data/lib/rhc/commands/app.rb +25 -17
- data/lib/rhc/commands/cartridge.rb +23 -21
- data/lib/rhc/commands/domain.rb +14 -14
- data/lib/rhc/commands/snapshot.rb +1 -1
- data/lib/rhc/helpers.rb +12 -10
- data/lib/rhc/rest/application.rb +4 -0
- data/lib/rhc/rest/client.rb +16 -9
- data/lib/rhc/rest/domain.rb +4 -0
- data/lib/rhc/rest/httpclient.rb +20 -0
- data/lib/rhc/rest/mock.rb +3 -2
- data/lib/rhc/tar_gz.rb +1 -1
- data/lib/rhc/wizard.rb +11 -10
- data/spec/rhc/cli_spec.rb +24 -2
- data/spec/rhc/commands/app_spec.rb +23 -4
- data/spec/rhc/commands/cartridge_spec.rb +20 -21
- data/spec/rhc/commands/domain_spec.rb +2 -2
- data/spec/rhc/commands/snapshot_spec.rb +2 -2
- data/spec/rhc/helpers_spec.rb +4 -1
- data/spec/rhc/rest_application_spec.rb +3 -3
- data/spec/rhc/rest_client_spec.rb +8 -8
- data/spec/rhc/rest_spec.rb +9 -1
- data/spec/rhc/wizard_spec.rb +5 -5
- data/spec/wizard_spec_helper.rb +6 -6
- metadata +7 -5
data/lib/rhc/commands/domain.rb
CHANGED
@@ -5,10 +5,10 @@ module RHC::Commands
|
|
5
5
|
summary "Add or rename the container for your apps"
|
6
6
|
syntax "<action>"
|
7
7
|
description <<-DESC
|
8
|
-
OpenShift groups applications within a domain.
|
9
|
-
|
8
|
+
OpenShift groups applications within a domain. The name of the domain
|
9
|
+
will be used as part of the public URL for an application.
|
10
10
|
|
11
|
-
For example, when creating a domain with the
|
11
|
+
For example, when creating a domain with the name "test", any applications
|
12
12
|
created in that domain will have the public URL:
|
13
13
|
|
14
14
|
http://<appname>-test.rhcloud.com
|
@@ -17,11 +17,11 @@ module RHC::Commands
|
|
17
17
|
DESC
|
18
18
|
default_action :list
|
19
19
|
|
20
|
-
summary "
|
20
|
+
summary "Create a new application grouping."
|
21
21
|
syntax "<namespace>"
|
22
|
-
argument :namespace, "
|
22
|
+
argument :namespace, "Name for your application(s) (alphanumeric)", ["-n", "--namespace NAME"]
|
23
23
|
def create(namespace)
|
24
|
-
paragraph { say "Creating domain
|
24
|
+
paragraph { say "Creating domain '#{namespace}'" }
|
25
25
|
rest_client.add_domain(namespace)
|
26
26
|
|
27
27
|
results do
|
@@ -32,26 +32,26 @@ module RHC::Commands
|
|
32
32
|
0
|
33
33
|
end
|
34
34
|
|
35
|
-
summary "
|
36
|
-
syntax "<old
|
37
|
-
argument :old_namespace, "
|
38
|
-
argument :new_namespace, "New
|
35
|
+
summary "Rename a domain (will change application urls)"
|
36
|
+
syntax "<old name> <new name>"
|
37
|
+
argument :old_namespace, "Existing domain name", []
|
38
|
+
argument :new_namespace, "New domain name", ["-n", "--namespace NAME"]
|
39
39
|
alias_action :alter, :deprecated => true
|
40
40
|
def update(old_namespace, new_namespace)
|
41
41
|
domain = rest_client.find_domain(old_namespace)
|
42
42
|
|
43
|
-
say "
|
43
|
+
say "Renaming domain '#{domain.id}' to '#{new_namespace}' ... "
|
44
44
|
|
45
45
|
domain.update(new_namespace)
|
46
46
|
|
47
|
-
success "
|
48
|
-
info "Applications in this domain will use the new
|
47
|
+
success "done"
|
48
|
+
info "Applications in this domain will use the new name in their URL."
|
49
49
|
|
50
50
|
0
|
51
51
|
end
|
52
52
|
|
53
53
|
summary "Display a domain and its applications"
|
54
|
-
argument :namespace, "
|
54
|
+
argument :namespace, "Name of the domain", ["-n", "--namespace NAME"], :optional => true
|
55
55
|
def show(namespace)
|
56
56
|
domain = (rest_client.find_domain(namespace) if namespace) || rest_client.domains.first
|
57
57
|
|
@@ -78,7 +78,7 @@ module RHC::Commands
|
|
78
78
|
rest_app = rest_client.find_application(options.namespace, app)
|
79
79
|
ssh_uri = URI.parse(rest_app.ssh_url)
|
80
80
|
|
81
|
-
ssh_cmd = "cat #{filename} | ssh #{ssh_uri.user}@#{ssh_uri.host} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
|
81
|
+
ssh_cmd = "cat '#{filename}' | ssh #{ssh_uri.user}@#{ssh_uri.host} 'restore#{include_git ? ' INCLUDE_GIT' : ''}'"
|
82
82
|
|
83
83
|
say "Restoring from snapshot #{filename}..."
|
84
84
|
debug ssh_cmd
|
data/lib/rhc/helpers.rb
CHANGED
@@ -26,9 +26,6 @@ module RHC
|
|
26
26
|
|
27
27
|
extend self
|
28
28
|
|
29
|
-
MAX_RETRIES = 7
|
30
|
-
DEFAULT_DELAY_THROTTLE = 2.0
|
31
|
-
|
32
29
|
def decode_json(s)
|
33
30
|
RHC::Vendor::OkJson.decode(s)
|
34
31
|
end
|
@@ -174,6 +171,11 @@ module RHC
|
|
174
171
|
ssh_url
|
175
172
|
end
|
176
173
|
|
174
|
+
def ssh_string_parts(ssh_url)
|
175
|
+
uri = URI.parse(ssh_url)
|
176
|
+
[uri.host, uri.user]
|
177
|
+
end
|
178
|
+
|
177
179
|
def openshift_rest_endpoint
|
178
180
|
uri = to_uri((options.server rescue nil) || ENV['LIBRA_SERVER'] || "openshift.redhat.com")
|
179
181
|
uri.path = '/broker/rest/api' if uri.path.blank? || uri.path == '/'
|
@@ -426,12 +428,16 @@ module RHC
|
|
426
428
|
[status, stdout, stderr]
|
427
429
|
end
|
428
430
|
|
429
|
-
def
|
430
|
-
|
431
|
+
def env_var_regex_pattern
|
432
|
+
/^([a-zA-Z_][\w]*)=(.*)$/
|
433
|
+
end
|
434
|
+
|
435
|
+
def collect_env_vars(items)
|
436
|
+
return nil if items.blank?
|
431
437
|
|
432
438
|
env_vars = []
|
433
439
|
|
434
|
-
|
440
|
+
Array(items).each do |item|
|
435
441
|
if match = item.match(env_var_regex_pattern)
|
436
442
|
name, value = match.captures
|
437
443
|
env_vars << RHC::Rest::EnvironmentVariable.new({ :name => name, :value => value })
|
@@ -447,9 +453,5 @@ module RHC
|
|
447
453
|
env_vars
|
448
454
|
end
|
449
455
|
|
450
|
-
def env_var_regex_pattern
|
451
|
-
/^([a-zA-Z_][\w]*)=(.*)$/
|
452
|
-
end
|
453
|
-
|
454
456
|
end
|
455
457
|
end
|
data/lib/rhc/rest/application.rb
CHANGED
@@ -167,6 +167,10 @@ module RHC
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
def supports_add_cartridge_with_env_vars?
|
171
|
+
has_param?('ADD_CARTRIDGE', 'environment_variables')
|
172
|
+
end
|
173
|
+
|
170
174
|
def add_alias(app_alias)
|
171
175
|
debug "Running add_alias for #{name}"
|
172
176
|
rest_method "ADD_ALIAS", :event => "add-alias", :alias => app_alias
|
data/lib/rhc/rest/client.rb
CHANGED
@@ -9,8 +9,6 @@ require 'set'
|
|
9
9
|
module RHC
|
10
10
|
module Rest
|
11
11
|
|
12
|
-
MAX_RETRIES = 5
|
13
|
-
|
14
12
|
#
|
15
13
|
# These are methods that belong to the API object but are
|
16
14
|
# callable from the client for convenience.
|
@@ -203,6 +201,7 @@ module RHC
|
|
203
201
|
# matching one supported by the server.
|
204
202
|
# See #api_version_negotiated
|
205
203
|
CLIENT_API_VERSIONS = [1.1, 1.2, 1.3, 1.4, 1.5]
|
204
|
+
MAX_RETRIES = 5
|
206
205
|
|
207
206
|
def initialize(*args)
|
208
207
|
options = args[0].is_a?(Hash) && args[0] || {}
|
@@ -246,8 +245,15 @@ module RHC
|
|
246
245
|
current_api_version
|
247
246
|
end
|
248
247
|
|
248
|
+
def attempt(retries, &block)
|
249
|
+
(0..retries).each do |i|
|
250
|
+
yield i < (retries-1), i
|
251
|
+
end
|
252
|
+
raise "Too many retries, giving up."
|
253
|
+
end
|
254
|
+
|
249
255
|
def request(options, &block)
|
250
|
-
(
|
256
|
+
attempt(MAX_RETRIES) do |more, i|
|
251
257
|
begin
|
252
258
|
client, args = new_request(options.dup)
|
253
259
|
auth = options[:auth] || self.auth
|
@@ -257,11 +263,11 @@ module RHC
|
|
257
263
|
time = Benchmark.realtime{ response = client.request(*(args << true)) }
|
258
264
|
debug " code %s %4i ms" % [response.status, (time*1000).to_i] if response
|
259
265
|
|
260
|
-
next if retry_proxy(response, i, args, client)
|
261
|
-
auth.retry_auth?(response, self) and next if auth
|
266
|
+
next if more && retry_proxy(response, i, args, client)
|
267
|
+
auth.retry_auth?(response, self) and next if more && auth
|
262
268
|
handle_error!(response, args[1], client) unless response.ok?
|
263
269
|
|
264
|
-
|
270
|
+
return (if block_given?
|
265
271
|
yield response
|
266
272
|
else
|
267
273
|
parse_response(response.content) unless response.nil? or response.code == 204
|
@@ -270,8 +276,8 @@ module RHC
|
|
270
276
|
if e.res
|
271
277
|
debug "Response: #{e.res.status} #{e.res.headers.inspect}\n#{e.res.content}\n-------------" if debug?
|
272
278
|
|
273
|
-
next if retry_proxy(e.res, i, args, client)
|
274
|
-
auth.retry_auth?(e.res, self) and next if auth
|
279
|
+
next if more && retry_proxy(e.res, i, args, client)
|
280
|
+
auth.retry_auth?(e.res, self) and next if more && auth
|
275
281
|
handle_error!(e.res, args[1], client)
|
276
282
|
end
|
277
283
|
raise ConnectionException.new(
|
@@ -504,7 +510,8 @@ module RHC
|
|
504
510
|
def parse_messages(result, data)
|
505
511
|
warnings, messages = Array(result['messages']).inject([[],[]]) do |a, m|
|
506
512
|
severity, field, text = m.values_at('severity', 'field', 'text')
|
507
|
-
text
|
513
|
+
text.gsub!(/\A\n+/m, "")
|
514
|
+
text.rstrip!
|
508
515
|
case severity
|
509
516
|
when 'warning'
|
510
517
|
a[0] << text
|
data/lib/rhc/rest/domain.rb
CHANGED
data/lib/rhc/rest/httpclient.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
|
3
|
+
class HTTPClient
|
4
|
+
class SSPINegotiateAuth
|
5
|
+
def get_with_rescue(*args)
|
6
|
+
get_without_rescue(*args)
|
7
|
+
rescue
|
8
|
+
unless @warned
|
9
|
+
@warned = true
|
10
|
+
RHC::Helpers.warn "Could not enable Kerberos authentication"
|
11
|
+
RHC::Helpers.warn $!.message.sub('gss_init_sec_context did not return GSS_S_COMPLETE: Unspecified GSS failure. Minor code may provide more information', '').strip rescue nil
|
12
|
+
end
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :get_without_rescue, :get if method_defined? :get
|
17
|
+
alias_method :get, :get_with_rescue
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
1
21
|
module RHC
|
2
22
|
module Rest
|
3
23
|
#
|
data/lib/rhc/rest/mock.rb
CHANGED
@@ -194,6 +194,7 @@ module RHC::Rest::Mock
|
|
194
194
|
:domain_id => domain_name,
|
195
195
|
:id => 1,
|
196
196
|
:name => name,
|
197
|
+
:ssh_url => "ssh://12345@#{name}-#{domain_name}.rhcloud.com",
|
197
198
|
:app_url => "http://#{name}-#{domain_name}.rhcloud.com",
|
198
199
|
:links => mock_response_links([
|
199
200
|
]),
|
@@ -357,7 +358,7 @@ module RHC::Rest::Mock
|
|
357
358
|
end
|
358
359
|
|
359
360
|
def mock_app_links(domain_id='test_domain',app_id='test_app')
|
360
|
-
[['ADD_CARTRIDGE', "domains/#{domain_id}/apps/#{app_id}/carts/add", 'post'],
|
361
|
+
[['ADD_CARTRIDGE', "domains/#{domain_id}/apps/#{app_id}/carts/add", 'post', {'optional_params' => [{'name' => 'environment_variables'}]} ],
|
361
362
|
['LIST_CARTRIDGES', "broker/rest/domains/#{domain_id}/applications/#{app_id}/cartridges", 'get' ],
|
362
363
|
['GET_GEAR_GROUPS', "domains/#{domain_id}/apps/#{app_id}/gear_groups", 'get' ],
|
363
364
|
['START', "domains/#{domain_id}/apps/#{app_id}/start", 'post'],
|
@@ -403,7 +404,7 @@ module RHC::Rest::Mock
|
|
403
404
|
end
|
404
405
|
|
405
406
|
def mock_domain_links(domain_id='test_domain')
|
406
|
-
[['ADD_APPLICATION', "domains/#{domain_id}/apps/add", 'post'],
|
407
|
+
[['ADD_APPLICATION', "domains/#{domain_id}/apps/add", 'post', {'optional_params' => [{'name' => 'environment_variables'}]} ],
|
407
408
|
['LIST_APPLICATIONS', "domains/#{domain_id}/apps/", 'get' ],
|
408
409
|
['UPDATE', "domains/#{domain_id}/update", 'post'],
|
409
410
|
['DELETE', "domains/#{domain_id}/delete", 'post']]
|
data/lib/rhc/tar_gz.rb
CHANGED
@@ -30,7 +30,7 @@ module RHC
|
|
30
30
|
else
|
31
31
|
# combining STDOUT and STDERR (i.e., 2>&1) does not suppress output
|
32
32
|
# when the specs run via 'bundle exec rake spec'
|
33
|
-
system "#{TAR_BIN} --wildcards -tf #{filename} #{regex.source} 2>/dev/null >/dev/null"
|
33
|
+
system "#{TAR_BIN} --wildcards -tf '#{filename}' '#{regex.source}' 2>/dev/null >/dev/null"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/lib/rhc/wizard.rb
CHANGED
@@ -273,7 +273,7 @@ module RHC
|
|
273
273
|
key_fingerprint = fingerprint_for_default_key
|
274
274
|
unless key_fingerprint
|
275
275
|
paragraph do
|
276
|
-
warn "Your
|
276
|
+
warn "Your public SSH key at #{system_path(RHC::Config.ssh_pub_key_file_path)} is invalid or unreadable. "\
|
277
277
|
"Setup can not continue until you manually remove or fix your "\
|
278
278
|
"public and private keys id_rsa keys."
|
279
279
|
end
|
@@ -288,7 +288,7 @@ module RHC
|
|
288
288
|
end
|
289
289
|
else
|
290
290
|
paragraph do
|
291
|
-
info "You can upload your SSH key at a later time using the 'rhc sshkey' command"
|
291
|
+
info "You can upload your public SSH key at a later time using the 'rhc sshkey' command"
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
@@ -376,16 +376,16 @@ module RHC
|
|
376
376
|
|
377
377
|
def config_namespace_stage
|
378
378
|
paragraph do
|
379
|
-
say "Checking
|
379
|
+
say "Checking for a domain ... "
|
380
380
|
domains = rest_client.domains
|
381
381
|
if domains.length == 0
|
382
382
|
warn "none"
|
383
383
|
|
384
384
|
paragraph do
|
385
385
|
say [
|
386
|
-
"
|
387
|
-
("You may
|
388
|
-
"You will not be able to create
|
386
|
+
"Applications are grouped into domains - each domain has a unique name (called a namespace) that becomes part of your public application URL.",
|
387
|
+
("You may create your first domain here or leave it blank and use 'rhc create-domain' later." if namespace_optional?),
|
388
|
+
"You will not be able to create an application without completing this step.",
|
389
389
|
].compact.join(' ')
|
390
390
|
end
|
391
391
|
|
@@ -485,7 +485,8 @@ module RHC
|
|
485
485
|
|
486
486
|
applications.take(1).each do |app|
|
487
487
|
begin
|
488
|
-
|
488
|
+
host, user = RHC::Helpers.ssh_string_parts(app.ssh_url)
|
489
|
+
ssh = Net::SSH.start(host, user, :timeout => 60)
|
489
490
|
rescue Interrupt => e
|
490
491
|
debug_error(e)
|
491
492
|
raise "Connection attempt to #{app.host} was interrupted"
|
@@ -513,7 +514,7 @@ module RHC
|
|
513
514
|
def config_namespace(namespace)
|
514
515
|
# skip if string is empty
|
515
516
|
if namespace_optional? and (namespace.nil? or namespace.chomp.blank?)
|
516
|
-
paragraph{ info "You may create a
|
517
|
+
paragraph{ info "You may create a domain later through 'rhc create-domain'" }
|
517
518
|
return true
|
518
519
|
end
|
519
520
|
|
@@ -521,9 +522,9 @@ module RHC
|
|
521
522
|
domain = rest_client.add_domain(namespace)
|
522
523
|
options.namespace = namespace
|
523
524
|
|
524
|
-
success "Your domain
|
525
|
+
success "Your domain '#{domain.id}' has been successfully created"
|
525
526
|
rescue RHC::Rest::ValidationException => e
|
526
|
-
error e.message || "Unknown error during
|
527
|
+
error e.message || "Unknown error during domain creation."
|
527
528
|
return false
|
528
529
|
end
|
529
530
|
true
|
data/spec/rhc/cli_spec.rb
CHANGED
@@ -149,14 +149,36 @@ describe RHC::CLI do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
describe 'option provided twice' do
|
153
|
+
before{ user_config }
|
154
|
+
let!(:rest_client){ MockRestClient.new }
|
155
|
+
before(:each) do
|
156
|
+
domain = rest_client.add_domain("mock_domain")
|
157
|
+
@app = domain.add_application("app1", "mock_type")
|
158
|
+
end
|
159
|
+
context 'when run with -a provided twice, last being the valid one' do
|
160
|
+
let(:arguments) { ['cartridge', 'remove', 'mock_cart-1', '--confirm', '--trace','-a', 'app2', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
161
|
+
it "should remove cartridge" do
|
162
|
+
@app.add_cartridge('mock_cart-1')
|
163
|
+
expect { run }.to exit_with_code(0)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
context 'when run with -a provided twice, last not being the valid one' do
|
167
|
+
let(:arguments) { ['cartridge', 'remove', 'mock_cart-1', '--confirm', '--trace','-a', 'app1', '-a', 'app2', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
168
|
+
it "should raise an application not found exception" do
|
169
|
+
expect{ run }.to raise_error(RHC::Rest::ApplicationNotFoundException)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
152
174
|
describe '#set_terminal' do
|
153
175
|
before(:each) { mock_terminal }
|
154
|
-
it('should update $terminal.wrap_at') do
|
176
|
+
it('should update $terminal.wrap_at') do
|
155
177
|
$stdin.should_receive(:tty?).once.and_return(true)
|
156
178
|
HighLine::SystemExtensions.should_receive(:terminal_size).and_return([5])
|
157
179
|
expect { RHC::CLI.set_terminal }.to change($terminal, :wrap_at)
|
158
180
|
end
|
159
|
-
it('should not update $terminal.page_at') do
|
181
|
+
it('should not update $terminal.page_at') do
|
160
182
|
$stdin.should_receive(:tty?).once.and_return(true)
|
161
183
|
$stdout.should_receive(:tty?).once.and_return(true)
|
162
184
|
expect { RHC::CLI.set_terminal }.to_not change($terminal, :page_at)
|
@@ -163,7 +163,7 @@ describe RHC::Commands::App do
|
|
163
163
|
before{ rest_client.domains.clear }
|
164
164
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1'] }
|
165
165
|
# skips login stage and insecure check because of mock rest client, doesn't check keys
|
166
|
-
it { run_output(['mydomain', 'y', 'mykey']).should match(/This wizard.*Checking
|
166
|
+
it { run_output(['mydomain', 'y', 'mykey']).should match(/This wizard.*Checking for a domain.*You will not be able to create an application without completing this step.*Your domain 'mydomain' has been successfully created.*Creating application.*Your public SSH key.*Uploading key 'mykey'.*Your application 'app1' is now available.*Cloned to/m) }
|
167
167
|
end
|
168
168
|
|
169
169
|
context 'when run without a cart' do
|
@@ -722,10 +722,11 @@ describe RHC::Commands::App do
|
|
722
722
|
end
|
723
723
|
|
724
724
|
describe 'create app with env vars' do
|
725
|
-
before{ rest_client.add_domain("mockdomain") }
|
725
|
+
before{ @domain = rest_client.add_domain("mockdomain") }
|
726
726
|
|
727
727
|
[['app', 'create', 'app1', 'mock_standalone_cart-1', '-e', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
728
|
-
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
728
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
729
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
729
730
|
].each_with_index do |args, i|
|
730
731
|
context "when run with single env var #{i}" do
|
731
732
|
let(:arguments) { args }
|
@@ -737,7 +738,10 @@ describe RHC::Commands::App do
|
|
737
738
|
end
|
738
739
|
|
739
740
|
[['app', 'create', 'app1', 'mock_standalone_cart-1', '-e', 'VAR1=VAL1', '-e', 'VAR2=VAL2', '-e', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
740
|
-
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'VAR1=VAL1', '--env', 'VAR2=VAL2', '--env', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
741
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'VAR1=VAL1', '--env', 'VAR2=VAL2', '--env', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
742
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', 'VAR1=VAL1', 'VAR2=VAL2', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
743
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', 'VAR1=VAL1', 'VAR2=VAL2', '-e', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
744
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', 'VAR1=VAL1', '--env', 'VAR2=VAL2', '-e', 'VAR3=VAL3', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
741
745
|
].each_with_index do |args, i|
|
742
746
|
context "when run with multiple env vars #{i}" do
|
743
747
|
let(:arguments) { args }
|
@@ -748,5 +752,20 @@ describe RHC::Commands::App do
|
|
748
752
|
end
|
749
753
|
end
|
750
754
|
|
755
|
+
[['app', 'create', 'app1', 'mock_standalone_cart-1', '-e', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
756
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', '--env', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
757
|
+
['app', 'create', 'app1', 'mock_standalone_cart-1', 'FOO=BAR', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
758
|
+
].each_with_index do |args, i|
|
759
|
+
context "when run against a server without env vars support #{i}" do
|
760
|
+
let(:arguments) { args }
|
761
|
+
before { @domain.should_receive(:has_param?).with('ADD_APPLICATION','environment_variables').and_return(false) }
|
762
|
+
it { expect { run }.to exit_with_code(0) }
|
763
|
+
it { run_output.should match("Success") }
|
764
|
+
it { run_output.should match(/Cartridges:\s+mock_standalone_cart-1\n/) }
|
765
|
+
it { run_output.should match("Server does not support environment variables") }
|
766
|
+
it { run_output.should_not match(/Environment Variables:\s+FOO=BAR\n/) }
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
751
770
|
end
|
752
771
|
end
|
@@ -556,19 +556,17 @@ describe RHC::Commands::Cartridge do
|
|
556
556
|
|
557
557
|
describe 'cartridge add with env vars' do
|
558
558
|
let!(:rest_client){ MockRestClient.new }
|
559
|
+
before do
|
560
|
+
domain = rest_client.add_domain("mock_domain")
|
561
|
+
@app = domain.add_application("app1", "mock_type")
|
562
|
+
end
|
559
563
|
|
560
564
|
[['app', 'cartridge', 'add', 'unique_mock_cart', '-e', 'FOO=BAR', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
561
565
|
['app', 'cartridge', 'add', 'unique_mock_cart', '--env', 'FOO=BAR', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
562
566
|
].each_with_index do |args, i|
|
563
567
|
context "when run with single env var #{i}" do
|
564
568
|
let(:arguments) { args }
|
565
|
-
|
566
|
-
domain = rest_client.add_domain("mock_domain")
|
567
|
-
app = domain.add_application("app1", "mock_type")
|
568
|
-
end
|
569
|
-
it {
|
570
|
-
succeed_with_message(/Environment Variables:\s+FOO=BAR/)
|
571
|
-
}
|
569
|
+
it { succeed_with_message(/Environment Variables:\s+FOO=BAR/) }
|
572
570
|
end
|
573
571
|
end
|
574
572
|
|
@@ -577,13 +575,7 @@ describe RHC::Commands::Cartridge do
|
|
577
575
|
].each_with_index do |args, i|
|
578
576
|
context "when run with multiple env vars #{i}" do
|
579
577
|
let(:arguments) { args }
|
580
|
-
|
581
|
-
domain = rest_client.add_domain("mock_domain")
|
582
|
-
app = domain.add_application("app1", "mock_type")
|
583
|
-
end
|
584
|
-
it {
|
585
|
-
succeed_with_message(/Environment Variables:\s+FOO1=BAR1, FOO2=BAR2/)
|
586
|
-
}
|
578
|
+
it { succeed_with_message(/Environment Variables:\s+FOO1=BAR1, FOO2=BAR2/) }
|
587
579
|
end
|
588
580
|
end
|
589
581
|
|
@@ -592,14 +584,21 @@ describe RHC::Commands::Cartridge do
|
|
592
584
|
].each_with_index do |args, i|
|
593
585
|
context "when run with env vars from files #{i}" do
|
594
586
|
let(:arguments) { args }
|
595
|
-
|
596
|
-
domain = rest_client.add_domain("mock_domain")
|
597
|
-
app = domain.add_application("app1", "mock_type")
|
598
|
-
end
|
599
|
-
it {
|
600
|
-
succeed_with_message(/Environment Variables:\s+BAR=456, FOO=123, MY_EMPTY_ENV_VAR=, MY_OPENSHIFT_ENV_VAR=mongodb:\/\/user:pass@host:port\/\n/)
|
601
|
-
}
|
587
|
+
it { succeed_with_message(/Environment Variables:\s+BAR=456, FOO=123, MY_EMPTY_ENV_VAR=, MY_OPENSHIFT_ENV_VAR=mongodb:\/\/user:pass@host:port\/\n/) }
|
602
588
|
end
|
603
589
|
end
|
590
|
+
|
591
|
+
[['app', 'cartridge', 'add', 'unique_mock_cart', '-e', 'FOO=BAR', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'],
|
592
|
+
['app', 'cartridge', 'add', 'unique_mock_cart', '--env', 'FOO=BAR', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password']
|
593
|
+
].each_with_index do |args, i|
|
594
|
+
context "when run against a server without env vars support #{i}" do
|
595
|
+
let(:arguments) { args }
|
596
|
+
before{ @app.should_receive(:has_param?).with('ADD_CARTRIDGE','environment_variables').and_return(false) }
|
597
|
+
it { expect { run }.to exit_with_code(0) }
|
598
|
+
it { run_output.should match(/Server does not support environment variables/) }
|
599
|
+
it { run_output.should_not match(/Environment Variables:\s+FOO=BAR/) }
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
604
603
|
end
|
605
604
|
end
|