rhc 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rhc/config.rb CHANGED
@@ -76,7 +76,7 @@ module RHC
76
76
  when :integer, :boolean
77
77
  value.nil? ? "<#{type}>" : value
78
78
  else
79
- "\"#{value.nil? ? "<#{type || 'string'}>" : value}\""
79
+ value.nil? ? "<#{type || 'string'}>" : value
80
80
  end
81
81
  end
82
82
 
data/lib/rhc/rest.rb CHANGED
@@ -95,5 +95,7 @@ module RHC
95
95
  class SelfSignedCertificate < CertificateVerificationFailed; end
96
96
 
97
97
  class SSLVersionRejected < SSLConnectionFailed; end
98
+
99
+ class MultipleCartridgeCreationNotSupported < Exception; end
98
100
  end
99
101
  end
@@ -13,9 +13,16 @@ module RHC
13
13
  debug "Adding application #{name} to domain #{id}"
14
14
 
15
15
  payload = {:name => name}
16
- options.each do |key, value|
17
- payload[key] = value
16
+ options.each{ |key, value| payload[key.to_sym] = value }
17
+
18
+ cartridges = Array(payload.delete(:cartridge)).concat(Array(payload.delete(:cartridges))).compact.uniq
19
+ if (client.api_version_negotiated >= 1.3)
20
+ payload[:cartridges] = cartridges
21
+ else
22
+ raise RHC::Rest::MultipleCartridgeCreationNotSupported, "The server only supports creating an application with a single web cartridge." if cartridges.length > 1
23
+ payload[:cartridge] = cartridges.first
18
24
  end
25
+
19
26
  options = {:timeout => options[:scale] && 0 || nil}
20
27
  rest_method "ADD_APPLICATION", payload, options
21
28
  end
data/lib/rhc/rest/mock.rb CHANGED
@@ -37,6 +37,15 @@ module RHC::Rest::Mock
37
37
  }.to_json
38
38
  })
39
39
  end
40
+ def stub_api_v12(auth=false)
41
+ stub_api_request(:get, 'broker/rest/api', auth).
42
+ to_return({
43
+ :body => {
44
+ :data => mock_response_links(mock_real_client_links),
45
+ :supported_api_versions => [1.0, 1.1, 1.2],
46
+ }.to_json
47
+ })
48
+ end
40
49
  def stub_user(auth=mock_user_auth)
41
50
  stub_api_request(:get, 'broker/rest/user', auth).to_return(simple_user(username))
42
51
  end
@@ -103,7 +112,8 @@ module RHC::Rest::Mock
103
112
  :body => {
104
113
  :type => 'domains',
105
114
  :data => [{:id => name, :links => mock_response_links([
106
- ['LIST_APPLICATIONS', "broker/rest/domains/#{name}/applications", 'get']
115
+ ['LIST_APPLICATIONS', "broker/rest/domains/#{name}/applications", 'get'],
116
+ ['ADD_APPLICATION', "broker/rest/domains/#{name}/applications", 'post'],
107
117
  ])}],
108
118
  }.to_json
109
119
  })
@@ -29,6 +29,46 @@ describe RHC::Rest::Cartridge do
29
29
  end
30
30
  end
31
31
 
32
+ describe RHC::Rest::Domain do
33
+ subject{ RHC::Rest::Client.new(:server => mock_uri) }
34
+ let(:user_auth){ nil }
35
+ let(:domain) { subject.domains.first }
36
+ context "against a 1.2 server" do
37
+ before{ stub_api_v12; stub_one_domain('bar') }
38
+ before do
39
+ stub_api_request(:post, 'broker/rest/domains/bar/applications', false).
40
+ with(:body => {:name => 'foo', :cartridge => 'bar'}.to_json).
41
+ to_return(:status => 201, :body => {:type => 'application', :data => {:id => '1'}}.to_json)
42
+ end
43
+
44
+ it{ domain.add_application('foo', :cartridges => ['bar']).should be_true }
45
+ it{ expect{ domain.add_application('foo', :cartridges => ['bar', 'other']) }.to raise_error(RHC::Rest::MultipleCartridgeCreationNotSupported) }
46
+ it{ domain.add_application('foo', :cartridges => 'bar').should be_true }
47
+ it{ domain.add_application('foo', :cartridge => 'bar').should be_true }
48
+ it{ domain.add_application('foo', :cartridge => ['bar']).should be_true }
49
+ end
50
+ context "against a server newer than 1.3" do
51
+ let(:cartridges){ ['bar'] }
52
+ before{ stub_api; stub_one_domain('bar') }
53
+ before do
54
+ stub_api_request(:post, 'broker/rest/domains/bar/applications', false).
55
+ with(:body => {:name => 'foo', :cartridges => cartridges}.to_json).
56
+ to_return(:status => 201, :body => {:type => 'application', :data => {:id => '1'}}.to_json)
57
+ end
58
+
59
+ it{ domain.add_application('foo', :cartridges => ['bar']).should be_true }
60
+ it{ domain.add_application('foo', :cartridges => 'bar').should be_true }
61
+ it{ domain.add_application('foo', :cartridge => 'bar').should be_true }
62
+ it{ domain.add_application('foo', :cartridge => ['bar']).should be_true }
63
+
64
+ context "with multiple cartridges" do
65
+ let(:cartridges){ ['bar'] }
66
+ it{ domain.add_application('foo', :cartridges => cartridges).should be_true }
67
+ it{ domain.add_application('foo', :cartridge => cartridges).should be_true }
68
+ end
69
+ end
70
+ end
71
+
32
72
  module RHC
33
73
 
34
74
  describe Rest do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.4.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-11 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -233,141 +233,141 @@ executables:
233
233
  extensions: []
234
234
  extra_rdoc_files: []
235
235
  files:
236
- - lib/rhc/cartridge_helpers.rb
237
- - lib/rhc/exceptions.rb
238
- - lib/rhc/rest/user.rb
239
- - lib/rhc/rest/application.rb
240
- - lib/rhc/rest/base.rb
241
- - lib/rhc/rest/mock.rb
242
- - lib/rhc/rest/domain.rb
243
- - lib/rhc/rest/gear_group.rb
244
- - lib/rhc/rest/key.rb
245
- - lib/rhc/rest/api.rb
246
- - lib/rhc/rest/attributes.rb
247
- - lib/rhc/rest/client.rb
248
- - lib/rhc/rest/cartridge.rb
249
- - lib/rhc/auth.rb
250
- - lib/rhc/version.rb
251
- - lib/rhc/output_helpers.rb
252
236
  - lib/rhc/core_ext.rb
253
- - lib/rhc/autocomplete.rb
254
- - lib/rhc/coverage_helper.rb
255
- - lib/rhc/config.rb
256
- - lib/rhc/json.rb
257
- - lib/rhc/commands.rb
258
- - lib/rhc/commands/server.rb
259
- - lib/rhc/commands/base.rb
260
- - lib/rhc/commands/domain.rb
237
+ - lib/rhc/help_formatter.rb
238
+ - lib/rhc/vendor/zliby.rb
239
+ - lib/rhc/vendor/sshkey.rb
240
+ - lib/rhc/vendor/parseconfig.rb
241
+ - lib/rhc/vendor/okjson.rb
261
242
  - lib/rhc/commands/apps.rb
243
+ - lib/rhc/commands/port_forward.rb
262
244
  - lib/rhc/commands/threaddump.rb
263
- - lib/rhc/commands/account.rb
245
+ - lib/rhc/commands/sshkey.rb
246
+ - lib/rhc/commands/setup.rb
264
247
  - lib/rhc/commands/snapshot.rb
248
+ - lib/rhc/commands/account.rb
265
249
  - lib/rhc/commands/git_clone.rb
266
- - lib/rhc/commands/port_forward.rb
267
- - lib/rhc/commands/cartridge.rb
268
- - lib/rhc/commands/setup.rb
250
+ - lib/rhc/commands/domain.rb
251
+ - lib/rhc/commands/alias.rb
252
+ - lib/rhc/commands/server.rb
269
253
  - lib/rhc/commands/app.rb
254
+ - lib/rhc/commands/base.rb
270
255
  - lib/rhc/commands/tail.rb
271
- - lib/rhc/commands/sshkey.rb
272
- - lib/rhc/commands/alias.rb
273
- - lib/rhc/vendor/zliby.rb
274
- - lib/rhc/vendor/okjson.rb
275
- - lib/rhc/vendor/parseconfig.rb
276
- - lib/rhc/vendor/sshkey.rb
277
- - lib/rhc/tar_gz.rb
278
- - lib/rhc/command_runner.rb
279
- - lib/rhc/ssh_helpers.rb
256
+ - lib/rhc/commands/cartridge.rb
257
+ - lib/rhc/helpers.rb
258
+ - lib/rhc/auth/basic.rb
259
+ - lib/rhc/exceptions.rb
260
+ - lib/rhc/context_helper.rb
261
+ - lib/rhc/commands.rb
262
+ - lib/rhc/config.rb
280
263
  - lib/rhc/git_helpers.rb
264
+ - lib/rhc/coverage_helper.rb
265
+ - lib/rhc/json.rb
266
+ - lib/rhc/version.rb
267
+ - lib/rhc/autocomplete.rb
268
+ - lib/rhc/auth.rb
281
269
  - lib/rhc/wizard.rb
282
270
  - lib/rhc/cli.rb
283
- - lib/rhc/auth/basic.rb
284
- - lib/rhc/context_helper.rb
285
- - lib/rhc/help_formatter.rb
271
+ - lib/rhc/output_helpers.rb
272
+ - lib/rhc/tar_gz.rb
286
273
  - lib/rhc/rest.rb
287
- - lib/rhc/helpers.rb
274
+ - lib/rhc/command_runner.rb
275
+ - lib/rhc/cartridge_helpers.rb
276
+ - lib/rhc/ssh_helpers.rb
277
+ - lib/rhc/rest/key.rb
278
+ - lib/rhc/rest/mock.rb
279
+ - lib/rhc/rest/api.rb
280
+ - lib/rhc/rest/attributes.rb
281
+ - lib/rhc/rest/application.rb
282
+ - lib/rhc/rest/client.rb
283
+ - lib/rhc/rest/domain.rb
284
+ - lib/rhc/rest/user.rb
285
+ - lib/rhc/rest/base.rb
286
+ - lib/rhc/rest/cartridge.rb
287
+ - lib/rhc/rest/gear_group.rb
288
288
  - lib/rhc.rb
289
+ - lib/rhc/usage_templates/options_help.erb
289
290
  - lib/rhc/usage_templates/command_syntax_help.erb
290
- - lib/rhc/usage_templates/help.erb
291
- - lib/rhc/usage_templates/missing_help.erb
292
291
  - lib/rhc/usage_templates/command_help.erb
293
- - lib/rhc/usage_templates/options_help.erb
292
+ - lib/rhc/usage_templates/missing_help.erb
293
+ - lib/rhc/usage_templates/help.erb
294
294
  - lib/rhc/autocomplete_templates/rhc.erb
295
295
  - conf/express.conf
296
296
  - LICENSE
297
297
  - COPYRIGHT
298
298
  - README.md
299
299
  - Rakefile
300
- - spec/spec_helper.rb
301
- - spec/coverage_helper.rb
302
- - spec/rhc/json_spec.rb
303
- - spec/rhc/rest_spec.rb
304
- - spec/rhc/helpers_spec.rb
305
- - spec/rhc/rest_client_spec.rb
306
300
  - spec/rhc/wizard_spec.rb
307
- - spec/rhc/config_spec.rb
308
- - spec/rhc/cli_spec.rb
301
+ - spec/rhc/targz_spec.rb
302
+ - spec/rhc/commands/setup_spec.rb
309
303
  - spec/rhc/commands/tail_spec.rb
304
+ - spec/rhc/commands/alias_spec.rb
305
+ - spec/rhc/commands/account_spec.rb
310
306
  - spec/rhc/commands/domain_spec.rb
311
- - spec/rhc/commands/apps_spec.rb
312
- - spec/rhc/commands/git_clone_spec.rb
313
- - spec/rhc/commands/server_spec.rb
314
307
  - spec/rhc/commands/app_spec.rb
315
- - spec/rhc/commands/setup_spec.rb
316
- - spec/rhc/commands/port_forward_spec.rb
317
- - spec/rhc/commands/account_spec.rb
318
308
  - spec/rhc/commands/snapshot_spec.rb
319
- - spec/rhc/commands/alias_spec.rb
320
309
  - spec/rhc/commands/cartridge_spec.rb
321
310
  - spec/rhc/commands/sshkey_spec.rb
311
+ - spec/rhc/commands/server_spec.rb
312
+ - spec/rhc/commands/port_forward_spec.rb
322
313
  - spec/rhc/commands/threaddump_spec.rb
314
+ - spec/rhc/commands/apps_spec.rb
315
+ - spec/rhc/commands/git_clone_spec.rb
316
+ - spec/rhc/auth_spec.rb
317
+ - spec/rhc/json_spec.rb
318
+ - spec/rhc/config_spec.rb
319
+ - spec/rhc/helpers_spec.rb
320
+ - spec/rhc/rest_spec.rb
321
+ - spec/rhc/context_spec.rb
323
322
  - spec/rhc/assets/foo.txt
324
323
  - spec/rhc/assets/targz_corrupted.tar.gz
325
324
  - spec/rhc/assets/targz_sample.tar.gz
326
- - spec/rhc/command_spec.rb
325
+ - spec/rhc/rest_client_spec.rb
326
+ - spec/rhc/cli_spec.rb
327
327
  - spec/rhc/rest_application_spec.rb
328
- - spec/rhc/targz_spec.rb
329
- - spec/rhc/context_spec.rb
330
- - spec/rhc/auth_spec.rb
328
+ - spec/rhc/command_spec.rb
329
+ - spec/spec.opts
330
+ - spec/rest_spec_helper.rb
331
+ - spec/spec_helper.rb
332
+ - spec/coverage_helper.rb
331
333
  - spec/wizard_spec_helper.rb
332
- - spec/keys/example.pem
333
- - spec/keys/server.pem
334
334
  - spec/keys/example_private.pem
335
- - spec/rest_spec_helper.rb
336
- - spec/spec.opts
337
- - features/multiple_cartridge.feature
338
- - features/domain.feature
339
- - features/verify.feature
340
- - features/cartridge.feature
335
+ - spec/keys/server.pem
336
+ - spec/keys/example.pem
341
337
  - features/client.feature
342
- - features/support/env.rb
338
+ - features/verify.feature
339
+ - features/README.md
340
+ - features/geared_application.feature
341
+ - features/support/before_hooks.rb
343
342
  - features/support/key2.pub
344
- - features/support/key1
343
+ - features/support/assumptions.rb
345
344
  - features/support/key1.pub
346
- - features/support/before_hooks.rb
345
+ - features/support/key1
346
+ - features/support/env.rb
347
347
  - features/support/key3.pub
348
348
  - features/support/key2
349
- - features/support/assumptions.rb
350
- - features/application.feature
349
+ - features/lib/rhc_helper/sshkey.rb
350
+ - features/lib/rhc_helper/api.rb
351
+ - features/lib/rhc_helper/commandify.rb
352
+ - features/lib/rhc_helper/persistable.rb
353
+ - features/lib/rhc_helper/loggable.rb
354
+ - features/lib/rhc_helper/domain.rb
355
+ - features/lib/rhc_helper/runnable.rb
356
+ - features/lib/rhc_helper/app.rb
357
+ - features/lib/rhc_helper/httpify.rb
358
+ - features/lib/rhc_helper/cartridge.rb
359
+ - features/lib/rhc_helper.rb
351
360
  - features/sshkey.feature
352
- - features/geared_application.feature
361
+ - features/domain.feature
362
+ - features/cartridge.feature
353
363
  - features/scaled_application.feature
354
364
  - features/step_definitions/cartridge_steps.rb
365
+ - features/step_definitions/sshkey_steps.rb
355
366
  - features/step_definitions/application_steps.rb
356
367
  - features/step_definitions/client_steps.rb
357
368
  - features/step_definitions/domain_steps.rb
358
- - features/step_definitions/sshkey_steps.rb
359
- - features/lib/rhc_helper.rb
360
- - features/lib/rhc_helper/httpify.rb
361
- - features/lib/rhc_helper/domain.rb
362
- - features/lib/rhc_helper/runnable.rb
363
- - features/lib/rhc_helper/loggable.rb
364
- - features/lib/rhc_helper/commandify.rb
365
- - features/lib/rhc_helper/api.rb
366
- - features/lib/rhc_helper/cartridge.rb
367
- - features/lib/rhc_helper/app.rb
368
- - features/lib/rhc_helper/persistable.rb
369
- - features/lib/rhc_helper/sshkey.rb
370
- - features/README.md
369
+ - features/application.feature
370
+ - features/multiple_cartridge.feature
371
371
  - bin/rhc
372
372
  homepage: https://github.com/openshift/rhc
373
373
  licenses: []
@@ -400,74 +400,74 @@ signing_key:
400
400
  specification_version: 3
401
401
  summary: OpenShift Client Tools
402
402
  test_files:
403
- - spec/spec_helper.rb
404
- - spec/coverage_helper.rb
405
- - spec/rhc/json_spec.rb
406
- - spec/rhc/rest_spec.rb
407
- - spec/rhc/helpers_spec.rb
408
- - spec/rhc/rest_client_spec.rb
409
403
  - spec/rhc/wizard_spec.rb
410
- - spec/rhc/config_spec.rb
411
- - spec/rhc/cli_spec.rb
404
+ - spec/rhc/targz_spec.rb
405
+ - spec/rhc/commands/setup_spec.rb
412
406
  - spec/rhc/commands/tail_spec.rb
407
+ - spec/rhc/commands/alias_spec.rb
408
+ - spec/rhc/commands/account_spec.rb
413
409
  - spec/rhc/commands/domain_spec.rb
414
- - spec/rhc/commands/apps_spec.rb
415
- - spec/rhc/commands/git_clone_spec.rb
416
- - spec/rhc/commands/server_spec.rb
417
410
  - spec/rhc/commands/app_spec.rb
418
- - spec/rhc/commands/setup_spec.rb
419
- - spec/rhc/commands/port_forward_spec.rb
420
- - spec/rhc/commands/account_spec.rb
421
411
  - spec/rhc/commands/snapshot_spec.rb
422
- - spec/rhc/commands/alias_spec.rb
423
412
  - spec/rhc/commands/cartridge_spec.rb
424
413
  - spec/rhc/commands/sshkey_spec.rb
414
+ - spec/rhc/commands/server_spec.rb
415
+ - spec/rhc/commands/port_forward_spec.rb
425
416
  - spec/rhc/commands/threaddump_spec.rb
417
+ - spec/rhc/commands/apps_spec.rb
418
+ - spec/rhc/commands/git_clone_spec.rb
419
+ - spec/rhc/auth_spec.rb
420
+ - spec/rhc/json_spec.rb
421
+ - spec/rhc/config_spec.rb
422
+ - spec/rhc/helpers_spec.rb
423
+ - spec/rhc/rest_spec.rb
424
+ - spec/rhc/context_spec.rb
426
425
  - spec/rhc/assets/foo.txt
427
426
  - spec/rhc/assets/targz_corrupted.tar.gz
428
427
  - spec/rhc/assets/targz_sample.tar.gz
429
- - spec/rhc/command_spec.rb
428
+ - spec/rhc/rest_client_spec.rb
429
+ - spec/rhc/cli_spec.rb
430
430
  - spec/rhc/rest_application_spec.rb
431
- - spec/rhc/targz_spec.rb
432
- - spec/rhc/context_spec.rb
433
- - spec/rhc/auth_spec.rb
431
+ - spec/rhc/command_spec.rb
432
+ - spec/spec.opts
433
+ - spec/rest_spec_helper.rb
434
+ - spec/spec_helper.rb
435
+ - spec/coverage_helper.rb
434
436
  - spec/wizard_spec_helper.rb
435
- - spec/keys/example.pem
436
- - spec/keys/server.pem
437
437
  - spec/keys/example_private.pem
438
- - spec/rest_spec_helper.rb
439
- - spec/spec.opts
440
- - features/multiple_cartridge.feature
441
- - features/domain.feature
442
- - features/verify.feature
443
- - features/cartridge.feature
438
+ - spec/keys/server.pem
439
+ - spec/keys/example.pem
444
440
  - features/client.feature
445
- - features/support/env.rb
441
+ - features/verify.feature
442
+ - features/README.md
443
+ - features/geared_application.feature
444
+ - features/support/before_hooks.rb
446
445
  - features/support/key2.pub
447
- - features/support/key1
446
+ - features/support/assumptions.rb
448
447
  - features/support/key1.pub
449
- - features/support/before_hooks.rb
448
+ - features/support/key1
449
+ - features/support/env.rb
450
450
  - features/support/key3.pub
451
451
  - features/support/key2
452
- - features/support/assumptions.rb
453
- - features/application.feature
452
+ - features/lib/rhc_helper/sshkey.rb
453
+ - features/lib/rhc_helper/api.rb
454
+ - features/lib/rhc_helper/commandify.rb
455
+ - features/lib/rhc_helper/persistable.rb
456
+ - features/lib/rhc_helper/loggable.rb
457
+ - features/lib/rhc_helper/domain.rb
458
+ - features/lib/rhc_helper/runnable.rb
459
+ - features/lib/rhc_helper/app.rb
460
+ - features/lib/rhc_helper/httpify.rb
461
+ - features/lib/rhc_helper/cartridge.rb
462
+ - features/lib/rhc_helper.rb
454
463
  - features/sshkey.feature
455
- - features/geared_application.feature
464
+ - features/domain.feature
465
+ - features/cartridge.feature
456
466
  - features/scaled_application.feature
457
467
  - features/step_definitions/cartridge_steps.rb
468
+ - features/step_definitions/sshkey_steps.rb
458
469
  - features/step_definitions/application_steps.rb
459
470
  - features/step_definitions/client_steps.rb
460
471
  - features/step_definitions/domain_steps.rb
461
- - features/step_definitions/sshkey_steps.rb
462
- - features/lib/rhc_helper.rb
463
- - features/lib/rhc_helper/httpify.rb
464
- - features/lib/rhc_helper/domain.rb
465
- - features/lib/rhc_helper/runnable.rb
466
- - features/lib/rhc_helper/loggable.rb
467
- - features/lib/rhc_helper/commandify.rb
468
- - features/lib/rhc_helper/api.rb
469
- - features/lib/rhc_helper/cartridge.rb
470
- - features/lib/rhc_helper/app.rb
471
- - features/lib/rhc_helper/persistable.rb
472
- - features/lib/rhc_helper/sshkey.rb
473
- - features/README.md
472
+ - features/application.feature
473
+ - features/multiple_cartridge.feature