civo_cli 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -3
- data/README.md +57 -2
- data/civo_cli.gemspec +1 -1
- data/lib/apikey.rb +2 -3
- data/lib/civo_cli.rb +4 -0
- data/lib/civo_cli/version.rb +1 -1
- data/lib/instance.rb +22 -6
- data/lib/kubernetes.rb +172 -0
- data/lib/namegenerator.rb +1 -1
- data/lib/spinner.rb +61 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7490809da82e850e68b3f4bb27241b8f87048ab372a5a5d5a59f8f7000e7d672
|
4
|
+
data.tar.gz: 5e5f15459e0bbdcb994274bb5d8b69bbb91d03d754d681131c20029fccd183b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e612c8f5dd8db26e1a7a6032bc49caddb908432871427d7f21c87376b7cd35b01f4655c9f3bdb1f9dc9a21aece3e9dc233f2b2a211f743b88884064585f98c58
|
7
|
+
data.tar.gz: 1846b570f31e6fc4e66195eb6ee45a7852e7b00311c481653882567aebcf3ef368bce4d9a28937e981f6419d172e5e41580e346167b740b17a4ced8d21864df9
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ All notable changes to the Civo CLI will be documented in this file.
|
|
3
3
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
## [0.2.4] - 2019-06-28
|
7
|
+
### Added
|
8
|
+
- Added Kubernetes endpoints for when the service launches
|
9
|
+
|
6
10
|
## [0.2.3] - 2019-06-21
|
7
11
|
### Added
|
8
12
|
- Instance name generator
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
civo_cli (0.2.
|
5
|
-
civo (>= 1.1
|
4
|
+
civo_cli (0.2.4)
|
5
|
+
civo (>= 1.2.1)
|
6
6
|
colorize
|
7
7
|
json
|
8
8
|
terminal-table
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
tzinfo (~> 1.1)
|
19
19
|
addressable (2.6.0)
|
20
20
|
public_suffix (>= 2.0.2, < 4.0)
|
21
|
-
civo (1.1
|
21
|
+
civo (1.2.1)
|
22
22
|
commander
|
23
23
|
flexirest (>= 1.4.6)
|
24
24
|
toml
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Civo CLI is a tool to manage your [Civo.com](https://www.civo.com) account from
|
|
8
8
|
- [Set-Up](#set-up)
|
9
9
|
- [API Keys](#api-keys)
|
10
10
|
- [Instances](#instances)
|
11
|
+
- [Kubernetes clusters](#kubernetes-clusters)
|
11
12
|
- [Domains and Domain Records](#domains-and-domain-records)
|
12
13
|
- [Firewalls](#firewalls)
|
13
14
|
- [Networks](#networks)
|
@@ -75,6 +76,7 @@ You can create an instance by running `civo instance create` with a hostname par
|
|
75
76
|
* `initial_user` - The name of the initial user created on the server. If not provided, will default to the template's `default_username` and fallback to `civo`.
|
76
77
|
* `ssh_key_id` - The ID of an already [uploaded SSH public key](#ssh-keys) to use for login to the default user. Optional; if one isn't provided a random password will be set and returned in the `initial_password` field.
|
77
78
|
* `tags` - A space-separated list of tags in `'quotation marks'` to be used freely as required. Optional.
|
79
|
+
* `wait` - a simple flag (e.g. `--wait`) that will cause the CLI to spin and wait for the instance to be `ACTIVE`.
|
78
80
|
|
79
81
|
Example usage:
|
80
82
|
```
|
@@ -233,6 +235,59 @@ Hello, world!
|
|
233
235
|
```
|
234
236
|
Please note that resizing can take a few minutes.
|
235
237
|
|
238
|
+
## Kubernetes clusters
|
239
|
+
#### Introduction
|
240
|
+
*IMPORTANT:* Kubernetes is in closed-access only at the moment, during testing. The endpoints here will be rejected unless you are one of the closed set of users that can launch them.
|
241
|
+
|
242
|
+
#### List clusters
|
243
|
+
To see your created domains, simply call `civo kubernetes list`:
|
244
|
+
|
245
|
+
```
|
246
|
+
$ civo kubernetes list
|
247
|
+
+--------------------------------------+------+---------+-----------+--------+
|
248
|
+
| ID | Name | # Nodes | Size | Status |
|
249
|
+
+--------------------------------------+------+---------+-----------+--------+
|
250
|
+
| f13e3f64-d657-40dd-8449-c42c6e341208 | test | 3 | g2.medium | ACTIVE |
|
251
|
+
+--------------------------------------+------+---------+-----------+--------+
|
252
|
+
```
|
253
|
+
|
254
|
+
#### Create a cluster
|
255
|
+
You can create an instance by running `civo kubernetes create` with a cluster name parameter, as well as any options you provide:
|
256
|
+
|
257
|
+
* `size` - The size of nodes to create, from the current list of sizes available at [`civo sizes`](#sizes). Defaults to `g2.medium`.
|
258
|
+
* `nodes` - The number of nodes to create (the master also acts as a node).
|
259
|
+
* `wait` - a simple flag (e.g. `--wait`) that will cause the CLI to spin and wait for the cluster to be `ACTIVE`.
|
260
|
+
|
261
|
+
```
|
262
|
+
$ civo kubernetes create my-first-cluster
|
263
|
+
Created Kubernetes cluster my-first-cluster
|
264
|
+
```
|
265
|
+
|
266
|
+
#### Scaling the cluster
|
267
|
+
You can change the total number of nodes in the cluster (obviously 1 is the minimum) live while the cluster is running. It takes the name of the cluster (or the ID) and a parameter of `--nodes` which is the new number of nodes to run
|
268
|
+
|
269
|
+
```
|
270
|
+
civo kubernetes scale my-first-cluster --nodes=4
|
271
|
+
Kubernetes cluster my-first-cluster will now have 4 nodes
|
272
|
+
```
|
273
|
+
|
274
|
+
#### Renaming the cluster
|
275
|
+
Although the name isn't used anywhere except for in the list of clusters (e.g. it's not in any way written in to the cluster), if you wish to rename a cluster you can do so with:
|
276
|
+
|
277
|
+
```
|
278
|
+
civo kubernetes rename my-first-cluster --name="Production"
|
279
|
+
Kubernetes cluster my-first-cluster is now named Production
|
280
|
+
```
|
281
|
+
|
282
|
+
#### Removing the cluster
|
283
|
+
If you're completely finished with a cluster you can delete it with:
|
284
|
+
|
285
|
+
```
|
286
|
+
civo kubernetes remove my-first-cluster
|
287
|
+
Removing Kubernetes cluster my-first-cluster
|
288
|
+
```
|
289
|
+
|
290
|
+
|
236
291
|
## Domains and Domain Records
|
237
292
|
#### Introduction
|
238
293
|
We host reverse DNS for all instances automatically. If you'd like to manage forward (normal) DNS for your domains, you can do that for free within your account.
|
@@ -250,7 +305,7 @@ Created a domain called civoclidemo.xyz with ID 418181b2-fcd2-46a2-ba7f-c843c331
|
|
250
305
|
```
|
251
306
|
You can then proceed to add DNS records to this domain.
|
252
307
|
|
253
|
-
#### List Domain
|
308
|
+
#### List Domain Names
|
254
309
|
To see your created domains, simply call `civo domain list`:
|
255
310
|
```
|
256
311
|
$ civo domain list
|
@@ -635,4 +690,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/civo/c
|
|
635
690
|
|
636
691
|
## License
|
637
692
|
|
638
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
693
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/civo_cli.gemspec
CHANGED
@@ -49,6 +49,6 @@ Gem::Specification.new do |spec|
|
|
49
49
|
spec.add_runtime_dependency 'terminal-table'
|
50
50
|
spec.add_runtime_dependency 'thor'
|
51
51
|
spec.add_runtime_dependency 'colorize'
|
52
|
-
spec.add_runtime_dependency 'civo', ">= 1.1
|
52
|
+
spec.add_runtime_dependency 'civo', ">= 1.2.1"
|
53
53
|
spec.add_runtime_dependency 'json'
|
54
54
|
end
|
data/lib/apikey.rb
CHANGED
@@ -28,12 +28,10 @@ module CivoCLI
|
|
28
28
|
if keys.keys.include?(name)
|
29
29
|
CivoCLI::Config.delete_apikey(name)
|
30
30
|
puts "Removed the API Key #{name.colorize(:green)}"
|
31
|
-
else
|
31
|
+
else
|
32
32
|
puts "The API Key #{name.colorize(:red)} couldn't be found."
|
33
33
|
exit 1
|
34
34
|
end
|
35
|
-
|
36
|
-
|
37
35
|
end
|
38
36
|
map "delete" => "remove", "rm" => "remove"
|
39
37
|
|
@@ -52,6 +50,7 @@ module CivoCLI
|
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
53
|
+
map "use" => "current"
|
55
54
|
|
56
55
|
default_task :list
|
57
56
|
end
|
data/lib/civo_cli.rb
CHANGED
@@ -35,6 +35,10 @@ module CivoCLI
|
|
35
35
|
subcommand "instance", CivoCLI::Instance
|
36
36
|
map "instances" => "instance"
|
37
37
|
|
38
|
+
desc "kubernetes", "manage kubernetess"
|
39
|
+
subcommand "kubernetes", CivoCLI::Kubernetes
|
40
|
+
map "k8s" => "kubernetes"
|
41
|
+
|
38
42
|
desc "network", "manage networks"
|
39
43
|
subcommand "network", CivoCLI::Network
|
40
44
|
map "networks" => "network"
|
data/lib/civo_cli/version.rb
CHANGED
data/lib/instance.rb
CHANGED
@@ -89,6 +89,7 @@ module CivoCLI
|
|
89
89
|
option :snapshot, banner: 'snapshot_id'
|
90
90
|
option :ssh_key, banner: 'ssh_key_id'
|
91
91
|
option :tags, banner: "'tag1 tag2 tag3...'"
|
92
|
+
option :wait, type: :boolean
|
92
93
|
long_desc <<-LONGDESC
|
93
94
|
Create a new instance with hostname (randomly assigned if blank), instance size (default: g2.small),
|
94
95
|
\x5template or snapshot ID (default: Ubuntu 18.04 template).
|
@@ -101,23 +102,37 @@ module CivoCLI
|
|
101
102
|
\x5 --ssh_key=<ssh_key_id> - for specifying a SSH login key for the default user. Random password assigned if blank, visible by calling `civo instance show hostname`
|
102
103
|
\x5 --region=<regioncode> from available Civo regions. Randomly assigned if blank
|
103
104
|
\x5 --tags=<'tag1 tag2 tag3...'> - space-separated tag(s)
|
105
|
+
\x5 --wait - wait for build to complete and show status. Off by default.
|
104
106
|
LONGDESC
|
105
107
|
def create(hostname = CivoCLI::NameGenerator.create, *args)
|
106
|
-
# {ENV["CIVO_API_VERSION"] || "1"}/instances", requires: [:hostname, :size, :region],
|
107
|
-
# defaults: {public_ip: true, initial_user: "civo"}
|
108
108
|
CivoCLI::Config.set_api_auth
|
109
109
|
if options[:template] && options[:snapshot] || !options[:template] && !options[:snapshot]
|
110
110
|
puts "Please provide either template OR snapshot ID".colorize(:red)
|
111
111
|
exit 1
|
112
112
|
end
|
113
|
+
|
113
114
|
if options[:template]
|
114
|
-
Civo::Instance.create(hostname: hostname, size: options[:size], template: options[:template], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
|
115
|
+
@instance = Civo::Instance.create(hostname: hostname, size: options[:size], template: options[:template], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
|
116
|
+
elsif options[:snapshot]
|
117
|
+
@instance = Civo::Instance.create(hostname: hostname, size: options[:size], snapshot_id: options[:snapshot], initial_user: options[:initial_user], region: options[:region], ssh_key_id: options[:ssh_key], tags: options[:tags])
|
115
118
|
end
|
116
119
|
|
117
|
-
if options[:
|
118
|
-
|
120
|
+
if options[:wait]
|
121
|
+
print "Building new instance #{hostname}: "
|
122
|
+
|
123
|
+
spinner = CivoCLI::Spinner.spin(instance: @instance) do |s|
|
124
|
+
Civo::Instance.all.items.each do |instance|
|
125
|
+
if instance.id == @instance.id && instance.status == 'ACTIVE'
|
126
|
+
s[:final_instance] = instance
|
127
|
+
end
|
128
|
+
end
|
129
|
+
s[:final_instance]
|
130
|
+
end
|
131
|
+
|
132
|
+
puts "\b Done\nCreated instance #{spinner[:final_instance].hostname.colorize(:green)} - #{spinner[:final_instance].initial_user}@#{spinner[:final_instance].public_ip}"
|
133
|
+
else
|
134
|
+
puts "Created instance #{hostname.colorize(:green)}"
|
119
135
|
end
|
120
|
-
puts "Created instance #{hostname.colorize(:green)}"
|
121
136
|
rescue Flexirest::HTTPException => e
|
122
137
|
puts e.result.reason.colorize(:red)
|
123
138
|
exit 1
|
@@ -171,6 +186,7 @@ module CivoCLI
|
|
171
186
|
puts e.result.reason.colorize(:red)
|
172
187
|
exit 1
|
173
188
|
end
|
189
|
+
map "delete" => "remove"
|
174
190
|
|
175
191
|
desc "reboot ID/HOSTNAME", "reboots instance with ID/hostname entered"
|
176
192
|
def reboot(id)
|
data/lib/kubernetes.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
module CivoCLI
|
2
|
+
class Kubernetes < Thor
|
3
|
+
desc "list", "list all kubernetes clusters"
|
4
|
+
def list
|
5
|
+
CivoCLI::Config.set_api_auth
|
6
|
+
rows = []
|
7
|
+
Civo::Kubernetes.all.items.each do |cluster|
|
8
|
+
rows << [cluster.id, cluster.name, cluster.num_target_nodes, cluster.target_nodes_size, cluster.status]
|
9
|
+
end
|
10
|
+
puts Terminal::Table.new headings: ['ID', 'Name', '# Nodes', 'Size', 'Status'], rows: rows
|
11
|
+
rescue Flexirest::HTTPForbiddenClientException
|
12
|
+
reject_user_access
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "show ID/NAME", "show a Kubernetes cluster by ID or name"
|
16
|
+
def show(id)
|
17
|
+
CivoCLI::Config.set_api_auth
|
18
|
+
rows = []
|
19
|
+
cluster = detect_cluster_id(id)
|
20
|
+
|
21
|
+
puts " ID : #{cluster.id}"
|
22
|
+
puts " Name : #{cluster.name}"
|
23
|
+
puts " # Nodes : #{cluster.num_target_nodes}"
|
24
|
+
puts " Size : #{cluster.target_nodes_size}"
|
25
|
+
case cluster.status
|
26
|
+
when "ACTIVE"
|
27
|
+
puts " Status : #{cluster.status.colorize(:green)}"
|
28
|
+
when /ING$/
|
29
|
+
puts " Status : #{cluster.status.colorize(:orange)}"
|
30
|
+
else
|
31
|
+
puts " Status : #{cluster.status.colorize(:red)}"
|
32
|
+
end
|
33
|
+
puts " Version : #{cluster.kubernetes_version}"
|
34
|
+
puts " API Endpoint : #{cluster.kubeconfig[/https:\/\/(\d+.)*:6443/]}"
|
35
|
+
#<Civo::Kubernetes id: "9f1cf43c-a924-468f-baa7-38dbe0e98ff0", name: "chris-edward", version: "1", status: "ACTIVE", num_target_nodes: 3, target_nodes_size: "g2.medium", built_at: "2019-06-27 16:56:25", kubeconfig: "apiVersion: v1\nclusters:\n- cluster:\n certificate...", kubernetes_version: "0.6.1", created_at: "2019-06-27 16:52:10", instances: #<Flexirest::ResultIterator:0x00007fc43847d958 @_status=nil, @_headers=nil, @items=[#<Civo::Kubernetes hostname: "k8s-node-acf8", size: "g2.medium", region: "lon1", created_at: "2019-06-27 16:52:11", status: "ACTIVE", firewall_id: "fdf99ced-e257-4ddf-9c81-da81a1dea4ff", public_ip: "185.136.234.35">, #<Civo::Kubernetes hostname: "k8s-node-3615", size: "g2.medium", region: "lon1", created_at: "2019-06-27 16:52:11", status: "ACTIVE", firewall_id: "fdf99ced-e257-4ddf-9c81-da81a1dea4ff", public_ip: "185.136.232.85">, #<Civo::Kubernetes hostname: "k8s-master-4f46", size: "g2.medium", region: "lon1", created_at: "2019-06-27 16:52:11", status: "ACTIVE", firewall_id: "fdf99ced-e257-4ddf-9c81-da81a1dea4ff", public_ip: "185.136.232.240">]>>
|
36
|
+
|
37
|
+
puts ""
|
38
|
+
rows = []
|
39
|
+
cluster.instances.each do |instance|
|
40
|
+
rows << [instance.hostname, instance.public_ip, instance.status]
|
41
|
+
end
|
42
|
+
puts Terminal::Table.new headings: ['Name', 'IP', 'Status'], rows: rows
|
43
|
+
rescue Flexirest::HTTPException => e
|
44
|
+
puts e.result.reason.colorize(:red)
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "config ID/NAME", "get the ~/.kube/config for a Kubernetes cluster by ID or name"
|
49
|
+
def config(id)
|
50
|
+
CivoCLI::Config.set_api_auth
|
51
|
+
rows = []
|
52
|
+
cluster = detect_cluster_id(id)
|
53
|
+
puts cluster.kubeconfig
|
54
|
+
rescue Flexirest::HTTPException => e
|
55
|
+
puts e.result.reason.colorize(:red)
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "create [NAME] [...]", "create a new kubernetes cluster with the specified name and provided options"
|
60
|
+
option :size, default: 'g2.medium', banner: 'size'
|
61
|
+
option :nodes, default: '3', banner: 'node_count'
|
62
|
+
option :wait, type: :boolean
|
63
|
+
long_desc <<-LONGDESC
|
64
|
+
Create a new Kubernetes cluster with name (randomly assigned if blank), instance size (default: g2.medium),
|
65
|
+
\x5\x5Optional parameters are as follows:
|
66
|
+
\x5 --size=<instance_size> - 'g2.medium' if blank. List of sizes and codes to use can be found through `civo sizes`
|
67
|
+
\x5 --nodes=<count> - '3' if blank
|
68
|
+
\x5 --wait - wait for build to complete and show status. Off by default.
|
69
|
+
LONGDESC
|
70
|
+
def create(name = CivoCLI::NameGenerator.create, *args)
|
71
|
+
CivoCLI::Config.set_api_auth
|
72
|
+
@cluster = Civo::Kubernetes.create(name: name, target_nodes_size: options[:size], num_target_nodes: options[:nodes])
|
73
|
+
|
74
|
+
if options[:wait]
|
75
|
+
print "Building new Kubernetes cluster #{name.colorize(:green)}: "
|
76
|
+
|
77
|
+
spinner = CivoCLI::Spinner.spin(instance: @instance) do |s|
|
78
|
+
Civo::Kubernetes.all.items.each do |cluster|
|
79
|
+
if cluster.id == @cluster.id && cluster.status == 'ACTIVE'
|
80
|
+
s[:final_cluster] = cluster
|
81
|
+
end
|
82
|
+
end
|
83
|
+
s[:final_cluster]
|
84
|
+
end
|
85
|
+
|
86
|
+
puts "\b Done\nCreated Kubernetes cluster #{spinner[:final_cluster].name.colorize(:green)}"
|
87
|
+
else
|
88
|
+
puts "Created Kubernetes cluster #{name.colorize(:green)}"
|
89
|
+
end
|
90
|
+
rescue Flexirest::HTTPException => e
|
91
|
+
puts e.result.reason.colorize(:red)
|
92
|
+
exit 1
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "rename ID/NAME [--name]", "rename Kubernetes cluster"
|
96
|
+
option :name
|
97
|
+
long_desc <<-LONGDESC
|
98
|
+
Use --name=new_host_name to specify the new name you wish to use.
|
99
|
+
LONGDESC
|
100
|
+
def rename(id)
|
101
|
+
CivoCLI::Config.set_api_auth
|
102
|
+
cluster = detect_cluster_id(id)
|
103
|
+
|
104
|
+
if options[:name]
|
105
|
+
Civo::Kubernetes.update(id: cluster.id, name: options[:name])
|
106
|
+
puts "Kubernetes cluster #{cluster.id} is now named #{options[:name].colorize(:green)}"
|
107
|
+
end
|
108
|
+
rescue Flexirest::HTTPException => e
|
109
|
+
puts e.result.reason.colorize(:red)
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "scale ID/NAME [--nodes]", "rescale the Kubernetes cluster to a new node count"
|
114
|
+
option :nodes
|
115
|
+
long_desc <<-LONGDESC
|
116
|
+
Use --nodes=count to specify the new number of nodes to run.
|
117
|
+
LONGDESC
|
118
|
+
def scale(id)
|
119
|
+
CivoCLI::Config.set_api_auth
|
120
|
+
cluster = detect_cluster_id(id)
|
121
|
+
|
122
|
+
if options[:nodes]
|
123
|
+
Civo::Kubernetes.update(id: cluster.id, num_target_nodes: options[:nodes])
|
124
|
+
puts "Kubernetes cluster #{cluster.name.colorize(:green)} will now have #{options[:nodes].colorize(:green)} nodes"
|
125
|
+
end
|
126
|
+
rescue Flexirest::HTTPException => e
|
127
|
+
puts e.result.reason.colorize(:red)
|
128
|
+
exit 1
|
129
|
+
end
|
130
|
+
map "rescale" => "scale"
|
131
|
+
|
132
|
+
desc "remove ID/NAME", "removes an entire Kubernetes cluster with ID/name entered (use with caution!)"
|
133
|
+
def remove(id)
|
134
|
+
CivoCLI::Config.set_api_auth
|
135
|
+
cluster = detect_cluster_id(id)
|
136
|
+
|
137
|
+
puts "Removing Kubernetes cluster #{cluster.name.colorize(:red)}"
|
138
|
+
cluster.remove
|
139
|
+
rescue Flexirest::HTTPException => e
|
140
|
+
puts e.result.reason.colorize(:red)
|
141
|
+
exit 1
|
142
|
+
end
|
143
|
+
map "delete" => "remove", "destroy" => "remove"
|
144
|
+
|
145
|
+
default_task :list
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def detect_cluster_id(id)
|
150
|
+
result = []
|
151
|
+
Civo::Kubernetes.all.items.each do |cluster|
|
152
|
+
result << cluster
|
153
|
+
end
|
154
|
+
result.select! { |cluster| cluster.name.include?(id) }
|
155
|
+
|
156
|
+
if result.count.zero?
|
157
|
+
puts "No Kubernetes clusters found for '#{id}'. Please check your query."
|
158
|
+
exit 1
|
159
|
+
elsif result.count > 1
|
160
|
+
puts "Multiple possible Kubernetes clusters found for '#{id}'. Please try with a more specific query."
|
161
|
+
exit 1
|
162
|
+
else
|
163
|
+
result[0]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def reject_user_access
|
168
|
+
puts "Sorry, this functionality is currently in closed beta and not available to the public yet"
|
169
|
+
exit(1)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
data/lib/namegenerator.rb
CHANGED
data/lib/spinner.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module CivoCLI
|
2
|
+
print "\033[?25l"
|
3
|
+
class Spinner
|
4
|
+
SPINNER_SHAPES = ['|', '/', '-', '\\'].freeze
|
5
|
+
DELAY = 0.1
|
6
|
+
|
7
|
+
attr_accessor :data
|
8
|
+
|
9
|
+
def self.spin(data = {}, &block)
|
10
|
+
new(data, &block).spin
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(data = {}, &block)
|
14
|
+
@data = data
|
15
|
+
@spinner_frame = 0
|
16
|
+
@counter = 20
|
17
|
+
@total = 3600 / DELAY
|
18
|
+
@block = block
|
19
|
+
spin
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(name)
|
23
|
+
@data[name] if @data.keys.include?(name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def [](key)
|
27
|
+
@data[key] if @data.keys.include?(key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def []=(key, value)
|
31
|
+
@data[key] = value
|
32
|
+
end
|
33
|
+
|
34
|
+
def spin
|
35
|
+
print "\033[?25l"
|
36
|
+
while(@total > 0) do
|
37
|
+
sleep(DELAY)
|
38
|
+
print SPINNER_SHAPES[@spinner_frame] + "\b"
|
39
|
+
@spinner_frame += 1
|
40
|
+
@spinner_frame = 0 if @spinner_frame == SPINNER_SHAPES.length
|
41
|
+
@counter -= 1
|
42
|
+
@total -= 1
|
43
|
+
next unless @counter == 0
|
44
|
+
|
45
|
+
@counter = 20
|
46
|
+
if result = @block.call(self)
|
47
|
+
self.data[:result] = result
|
48
|
+
print "\033[?25h"
|
49
|
+
return self
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
print "\033[?25h"
|
54
|
+
rescue Interrupt
|
55
|
+
print "\b\b" + "Exiting.\n"
|
56
|
+
exit 1
|
57
|
+
ensure
|
58
|
+
print "\033[?25h"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: civo_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-06-
|
13
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -158,14 +158,14 @@ dependencies:
|
|
158
158
|
requirements:
|
159
159
|
- - ">="
|
160
160
|
- !ruby/object:Gem::Version
|
161
|
-
version: 1.1
|
161
|
+
version: 1.2.1
|
162
162
|
type: :runtime
|
163
163
|
prerelease: false
|
164
164
|
version_requirements: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version: 1.1
|
168
|
+
version: 1.2.1
|
169
169
|
- !ruby/object:Gem::Dependency
|
170
170
|
name: json
|
171
171
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,12 +213,14 @@ files:
|
|
213
213
|
- lib/domain_record.rb
|
214
214
|
- lib/firewall.rb
|
215
215
|
- lib/instance.rb
|
216
|
+
- lib/kubernetes.rb
|
216
217
|
- lib/namegenerator.rb
|
217
218
|
- lib/network.rb
|
218
219
|
- lib/quota.rb
|
219
220
|
- lib/region.rb
|
220
221
|
- lib/size.rb
|
221
222
|
- lib/snapshot.rb
|
223
|
+
- lib/spinner.rb
|
222
224
|
- lib/sshkey.rb
|
223
225
|
- lib/sub_command_base.rb
|
224
226
|
- lib/template.rb
|