ubalo 0.0.16 → 0.0.17
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/bin/ubalo +31 -9
- data/lib/ubalo.rb +20 -19
- data/lib/ubalo/version.rb +3 -0
- metadata +11 -10
data/bin/ubalo
CHANGED
@@ -69,6 +69,9 @@ program_desc 'Command-line access to ubalo.com.'
|
|
69
69
|
desc "Change the connect url"
|
70
70
|
flag 'connect-url'
|
71
71
|
|
72
|
+
desc "Prints the current version of the Ubalo gem"
|
73
|
+
switch 'version'
|
74
|
+
|
72
75
|
desc 'Display authentication information'
|
73
76
|
command :whoami do |c|
|
74
77
|
c.action do |global_options,options,args|
|
@@ -289,7 +292,7 @@ command :stop do |c|
|
|
289
292
|
end
|
290
293
|
end
|
291
294
|
|
292
|
-
desc '
|
295
|
+
desc 'Upload your ssh key (defaults to ~/.ssh/id_rsa.pub)'
|
293
296
|
arg_name '<file containing ssh key>'
|
294
297
|
command :add_key do |c|
|
295
298
|
c.action do |global_options,options,args|
|
@@ -300,10 +303,10 @@ command :add_key do |c|
|
|
300
303
|
end
|
301
304
|
end
|
302
305
|
|
303
|
-
desc 'Clear
|
304
|
-
command :
|
306
|
+
desc 'Clear your ssh key'
|
307
|
+
command :clear_key do |c|
|
305
308
|
c.action do |global_options,options,args|
|
306
|
-
puts ubalo.
|
309
|
+
puts ubalo.clear_key.fetch('message')
|
307
310
|
end
|
308
311
|
end
|
309
312
|
|
@@ -385,7 +388,17 @@ desc 'Edit your environment'
|
|
385
388
|
command :edit do |c|
|
386
389
|
c.action do |global_options,options,args|
|
387
390
|
username = args.first || local_username
|
388
|
-
|
391
|
+
puts "Opening an ssh connection to edit the environment belonging to #{username}."
|
392
|
+
ubalo.ssh(username, 'edit-environment')
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
desc 'Edit your shared data'
|
397
|
+
command "shared:edit" do |c|
|
398
|
+
c.action do |global_options,options,args|
|
399
|
+
username = args.first || local_username
|
400
|
+
puts "Opening an ssh connection to edit the shared data belonging to #{username}."
|
401
|
+
ubalo.ssh(username, 'edit-shared-data')
|
389
402
|
end
|
390
403
|
end
|
391
404
|
|
@@ -439,7 +452,7 @@ command :publish do |c|
|
|
439
452
|
$stderr.print "Publishing #{pod_name}..."
|
440
453
|
response = ubalo.publish(pod_name)
|
441
454
|
$stderr.puts " done."
|
442
|
-
$stderr.puts "Your pod is now available at #{response.fetch('
|
455
|
+
$stderr.puts "Your pod is now available at #{response.fetch('url')}."
|
443
456
|
end
|
444
457
|
end
|
445
458
|
|
@@ -456,19 +469,28 @@ command :unpublish do |c|
|
|
456
469
|
end
|
457
470
|
end
|
458
471
|
|
472
|
+
def unauthorized_command?(command)
|
473
|
+
command && [:login, :help].include?(command.name)
|
474
|
+
end
|
475
|
+
|
459
476
|
pre do |global,command,options,args|
|
460
477
|
config = Ubalo.config
|
461
|
-
connect_url = global['connect-url'] || config['connect-url'] || "https://ubalo.com
|
478
|
+
connect_url = global['connect-url'] || config['connect-url'] || "https://ubalo.com"
|
479
|
+
|
480
|
+
if global[:version]
|
481
|
+
print "Ubalo version #{Ubalo::VERSION}"
|
482
|
+
raise UbaloExit, 0
|
483
|
+
end
|
462
484
|
|
463
485
|
# When logging in, don't use the authorization:
|
464
|
-
unless command
|
486
|
+
unless unauthorized_command?(command)
|
465
487
|
if host_config = config[connect_url]
|
466
488
|
@local_username = host_config['username']
|
467
489
|
authorization = host_config['authorization']
|
468
490
|
end
|
469
491
|
end
|
470
492
|
|
471
|
-
unless authorization or (command
|
493
|
+
unless authorization or unauthorized_command?(command)
|
472
494
|
raise UbaloMessage, "No credentials found. Please run 'ubalo login'."
|
473
495
|
end
|
474
496
|
|
data/lib/ubalo.rb
CHANGED
@@ -62,7 +62,7 @@ class Ubalo
|
|
62
62
|
else
|
63
63
|
name = pod['name']
|
64
64
|
end
|
65
|
-
" #{name} - #{pod['
|
65
|
+
" #{name} - #{pod['language_name']}"
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
@@ -103,22 +103,22 @@ class Ubalo
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def get(action, params={})
|
106
|
-
url = "#{base_url}/#{action}"
|
106
|
+
url = "#{base_url}/api/#{action}"
|
107
107
|
url_get(url, params)
|
108
108
|
end
|
109
109
|
|
110
110
|
def url_get url, params={}
|
111
|
-
response = RestClient.get url,
|
111
|
+
response = RestClient.get url, add_headers(:params => params, :accept => :json)
|
112
112
|
parse(response)
|
113
113
|
end
|
114
114
|
|
115
115
|
def post(action, params={})
|
116
|
-
url = "#{base_url}/#{action}"
|
116
|
+
url = "#{base_url}/api/#{action}"
|
117
117
|
url_post(url, params)
|
118
118
|
end
|
119
119
|
|
120
120
|
def url_post(url, params={})
|
121
|
-
response = RestClient.post url, params,
|
121
|
+
response = RestClient.post url, params, add_headers(:accept => :json)
|
122
122
|
parse(response)
|
123
123
|
end
|
124
124
|
|
@@ -162,8 +162,8 @@ class Ubalo
|
|
162
162
|
post(:upload_key, :key => key)
|
163
163
|
end
|
164
164
|
|
165
|
-
def
|
166
|
-
post(:
|
165
|
+
def clear_key
|
166
|
+
post(:clear_key)
|
167
167
|
end
|
168
168
|
|
169
169
|
def download(name)
|
@@ -183,10 +183,9 @@ class Ubalo
|
|
183
183
|
get(:pods)
|
184
184
|
end
|
185
185
|
|
186
|
-
def ssh(username)
|
187
|
-
|
188
|
-
|
189
|
-
Process.spawn({'UBALO_DISTRIBUTION_OWNER' => username}, ssh_command)
|
186
|
+
def ssh(username, action)
|
187
|
+
ssh_command = "ssh -o SendEnv='UBALO_OWNER_NAME UBALO_ACTION TERM' -tq #{ssh_path}"
|
188
|
+
Process.spawn({'UBALO_OWNER_NAME' => username, 'UBALO_ACTION' => action}, ssh_command)
|
190
189
|
pid, status = Process.wait2
|
191
190
|
unless status.success?
|
192
191
|
abort "Error running ssh"
|
@@ -194,8 +193,8 @@ class Ubalo
|
|
194
193
|
end
|
195
194
|
|
196
195
|
def scp(username, opts, args)
|
197
|
-
scp_command = "scp -o SendEnv=
|
198
|
-
Process.spawn({'
|
196
|
+
scp_command = "scp -o SendEnv='UBALO_OWNER_NAME UBALO_ACTION' #{opts} #{args}"
|
197
|
+
Process.spawn({'UBALO_OWNER_NAME' => username, 'UBALO_ACTION' => 'edit-environment'}, scp_command)
|
199
198
|
pid, status = Process.wait2
|
200
199
|
unless status.success?
|
201
200
|
abort "Error running cp"
|
@@ -265,21 +264,23 @@ class Ubalo
|
|
265
264
|
end
|
266
265
|
|
267
266
|
def publish pod_name
|
268
|
-
|
267
|
+
url_post("#{base_url}/pods/#{pod_name}/publish")
|
269
268
|
end
|
270
269
|
|
271
270
|
def unpublish pod_name
|
272
|
-
|
271
|
+
url_post("#{base_url}/pods/#{pod_name}/unpublish")
|
273
272
|
end
|
274
273
|
|
275
274
|
private
|
276
275
|
|
277
|
-
def
|
276
|
+
def add_headers headers
|
277
|
+
# Add authorization headers.
|
278
278
|
if authorization
|
279
|
-
headers.merge(:authorization => authorization)
|
280
|
-
else
|
281
|
-
headers
|
279
|
+
headers.merge!(:authorization => authorization)
|
282
280
|
end
|
281
|
+
|
282
|
+
# Add version header.
|
283
|
+
headers.merge!('X-Ubalo-Version' => Ubalo::VERSION)
|
283
284
|
end
|
284
285
|
|
285
286
|
def parse(result)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubalo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
16
|
-
requirement: &
|
16
|
+
requirement: &70162737169520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70162737169520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &70162737168820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70162737168820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70162737168140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70162737168140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rest-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70162737167480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.6.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70162737167480
|
58
58
|
description: CLI and API client for Ubalo
|
59
59
|
email: dev@ubalo.com
|
60
60
|
executables:
|
@@ -62,6 +62,7 @@ executables:
|
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
+
- lib/ubalo/version.rb
|
65
66
|
- lib/ubalo.rb
|
66
67
|
- bin/ubalo
|
67
68
|
homepage: http://ubalo.com/
|