oc 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oc/version.rb +1 -1
- data/lib/system/run/commands/info.rb +3 -2
- data/lib/system/run/commands/ssh.rb +35 -30
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d074a9487fcacce6033c9a6ffa5c796f6bb378f
|
4
|
+
data.tar.gz: c5f1094f985d74bd5f8cbf87bce07b79320788b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 672e890f29dab2511e06d64ac7bbac933210015e6d9e5417b0384fbb8f48d2a7293da4fbe78ef749c8a5f4f5c5b478e67ee44e377fbae2f8446f87b07d4087a3
|
7
|
+
data.tar.gz: 5f1f9492e0493830937ba15ab7ca913c1d1a04d39a512dabcafecf4cbac281c5bd0ba52c20c48dbb7d0f3b4c08880fa8b5070d20f80cd666eb8ddfbdf643989b
|
data/lib/oc/version.rb
CHANGED
@@ -8,12 +8,13 @@ module Oc::Run
|
|
8
8
|
|
9
9
|
description "Change your API information"
|
10
10
|
def change(*args)
|
11
|
-
config = Netrc.read("#{(ENV["HOME"] || "./")}/
|
11
|
+
config = Netrc.read("#{(ENV["HOME"] || "./")}/oc.netrc")
|
12
12
|
api_key = [(print 'Access Tokens: '), STDIN.gets.rstrip][1]
|
13
|
+
client_id = "empty"
|
13
14
|
if api_key.empty?
|
14
15
|
puts "Please fill all fields".red
|
15
16
|
else
|
16
|
-
config["api.digitalocean.com"] = api_key
|
17
|
+
config["api.digitalocean.com"] = api_key, client_id
|
17
18
|
config.save
|
18
19
|
puts "Informations is changed".red
|
19
20
|
end
|
@@ -8,8 +8,8 @@ module Oc::Run
|
|
8
8
|
description "This method lists all the available public SSH keys in your account that can be added to a droplet."
|
9
9
|
syntax "oc ssh keys"
|
10
10
|
def keys
|
11
|
-
result =
|
12
|
-
if result
|
11
|
+
result = barge.key.all
|
12
|
+
if !result.success?
|
13
13
|
puts "Error: Please check your information".red
|
14
14
|
else
|
15
15
|
puts "Your SSH Keys".yellow
|
@@ -20,7 +20,7 @@ module Oc::Run
|
|
20
20
|
'Name'
|
21
21
|
]
|
22
22
|
|
23
|
-
result
|
23
|
+
result.ssh_keys.each do |key|
|
24
24
|
rows << [
|
25
25
|
key["id"],
|
26
26
|
key["name"].red,
|
@@ -36,16 +36,18 @@ module Oc::Run
|
|
36
36
|
|
37
37
|
def add(*args)
|
38
38
|
name = args[0]
|
39
|
-
|
40
|
-
pub_key = args[2]
|
39
|
+
pub_key = args[1]
|
41
40
|
if name.nil? or pub_key.nil?
|
42
41
|
puts "Argument Error".red
|
43
42
|
puts "Usage".yellow
|
44
43
|
puts "$ oc ssh add [KEY_NAME] [KEY_EMAIL] [KEY_PUB]".yellow
|
45
44
|
else
|
46
|
-
result =
|
47
|
-
|
48
|
-
|
45
|
+
result = barge.key.create({
|
46
|
+
:name => name,
|
47
|
+
:public_key => pub_key
|
48
|
+
})
|
49
|
+
if !result.success?
|
50
|
+
puts "#{result.message}".red
|
49
51
|
else
|
50
52
|
puts "SSH Key Added".green
|
51
53
|
end
|
@@ -62,23 +64,22 @@ module Oc::Run
|
|
62
64
|
puts "$ oc ssh show [KEY_ID]".yellow
|
63
65
|
else
|
64
66
|
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
65
|
-
result =
|
66
|
-
if result
|
67
|
-
puts "#{result
|
67
|
+
result = barge.key.show(id)
|
68
|
+
if !result.success?
|
69
|
+
puts "#{result.message}".red
|
68
70
|
else
|
69
71
|
puts "SSH Keys".yellow
|
70
72
|
rows = []
|
71
73
|
|
72
74
|
rows << [
|
73
75
|
'ID',
|
74
|
-
'Name'
|
75
|
-
'SSH Pub Key'
|
76
|
+
'Name'
|
76
77
|
]
|
77
78
|
|
79
|
+
key = result.ssh_key
|
78
80
|
rows << [
|
79
|
-
|
80
|
-
|
81
|
-
result["ssh_key"]["ssh_pub_key"].red
|
81
|
+
key.id,
|
82
|
+
key.name.to_s.red
|
82
83
|
]
|
83
84
|
|
84
85
|
table = Terminal::Table.new :rows => rows
|
@@ -91,22 +92,23 @@ module Oc::Run
|
|
91
92
|
description "This method allows you to modify an existing public SSH key in your account."
|
92
93
|
syntax "oc ssh edit [KEY_ID] [KEY_NAME] [KEY_EMAIL] [KEY_PUB]"
|
93
94
|
|
94
|
-
def
|
95
|
+
def update(*args)
|
95
96
|
id = args[0]
|
96
97
|
name = args[1]
|
97
|
-
|
98
|
-
pub_key = args[3]
|
98
|
+
pub_key = args[2]
|
99
99
|
|
100
|
-
if id.nil? or name.nil? or
|
100
|
+
if id.nil? or name.nil? or pub_key.nil?
|
101
101
|
puts "Argument Error".red
|
102
102
|
puts "Usage".yellow
|
103
|
-
puts "$ oc ssh edit [KEY_ID] [KEY_NAME] [
|
103
|
+
puts "$ oc ssh edit [KEY_ID] [KEY_NAME] [KEY_PUB]".yellow
|
104
104
|
else
|
105
105
|
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
result = barge.key.update(id, {
|
107
|
+
:name => name,
|
108
|
+
:public_key => pub_key
|
109
|
+
})
|
110
|
+
if !result.success?
|
111
|
+
puts "#{result.message}".red
|
110
112
|
else
|
111
113
|
puts "SSH Key Edited".green
|
112
114
|
end
|
@@ -124,10 +126,9 @@ module Oc::Run
|
|
124
126
|
puts "$ oc ssh destroy [KEY_ID]".yellow
|
125
127
|
else
|
126
128
|
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
127
|
-
|
128
|
-
result
|
129
|
-
|
130
|
-
puts "#{result["message"]}".red
|
129
|
+
result = barge.key.destroy(id)
|
130
|
+
if !result.success?
|
131
|
+
puts "#{result.message}".red
|
131
132
|
else
|
132
133
|
puts "SSH Key Deleted".green
|
133
134
|
end
|
@@ -139,7 +140,11 @@ module Oc::Run
|
|
139
140
|
@config ||=value
|
140
141
|
end
|
141
142
|
|
142
|
-
|
143
|
+
def barge
|
144
|
+
puts "I'm thinking, please wait..".blue
|
145
|
+
Oc::Get.get_barge
|
146
|
+
end
|
147
|
+
|
143
148
|
def new_key_request name, pub_key
|
144
149
|
|
145
150
|
end
|