civo_cli 0.5.5 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e90ffc780245b77b913a2a5e314a47e0a0b7b3374cdfe9d648f84b8f66b414c8
4
- data.tar.gz: 63f17fd2007eedb6087efbcbb04a55fbbff126faebec1fec820699fa3f161e73
3
+ metadata.gz: 0cb0eaf57e97a29880d3cb97eef482d0695e456ad4f47e3a86612ff9225668c6
4
+ data.tar.gz: c0605d8fbd5cf9d8f2a166279d860601c5d0f91860dede1628f0aa0e687d8c03
5
5
  SHA512:
6
- metadata.gz: 6b6d6e5d96356fe3320a08242b1b1c32e4a512f8c594e8fe363666baff30df91c7d90d4ef8ecb718f6098bfd60530bfdfd100cdc977bfee8b39da1ffe93a813b
7
- data.tar.gz: 659852675b07e85f4a9886df8e9ac8ded3faf85e9f3bebe4879e5fcc2ff64f102f28c726c5d0bb852d8863759e7ded3701642dc5a2fc6e4c4ae2966b0c7d00c6
6
+ metadata.gz: df6e03b13cfa8205c614cc86ab508f73dd03e5e579151ab80b00b2932245c3ef88c4be30618b67486e4ebf99ba8b4672574d9d6092e5f86c162d1fa0a22fdc5e
7
+ data.tar.gz: 319da3e9971b7fa6d85e4c9352a358213f95adf4e1de0456b1e1238f8000d052a826ee42e5beb20fccce317b634ed5102423e09d191ee939c9b6fd3790edacde
@@ -3,6 +3,23 @@ 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.5.9] - 2020-04-08
7
+ ### Fixed
8
+ - Issues with Windows merging KUBECONFIG should be resolved (thanks to Johannes Tegnér for the PR)
9
+ - Allowed overriding of the KUBECONFIG file when merging (thanks to Jetchko Jekov for the suggestion)
10
+
11
+ ## [0.5.8] - 2020-02-14
12
+ ### Fixed
13
+ - Fix error with k3s versioning having plus signs
14
+
15
+ ## [0.5.7] - 2019-12-04
16
+ ### Fixed
17
+ - Set a minimum version of activesupport to fix https://github.com/civo/cli/issues/51 (thanks to Dr Nic Williams for the bug report)
18
+
19
+ ## [0.5.6] - 2019-11-13
20
+ ### Added
21
+ - Support for not installing default applications using `--remove-applications` during k3s cluster creation
22
+
6
23
  ## [0.5.5] - 2019-11-12
7
24
  ### Fixed
8
25
  - Support for `development` version k3s clusters when showing the details
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civo_cli (0.5.5)
4
+ civo_cli (0.5.10)
5
+ activesupport (>= 6.0.0)
5
6
  bundler (>= 1.17)
6
7
  civo (>= 1.2.9)
7
8
  colorize
@@ -12,30 +13,30 @@ PATH
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- activesupport (6.0.1)
16
+ activesupport (6.0.3.1)
16
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
18
  i18n (>= 0.7, < 2)
18
19
  minitest (~> 5.1)
19
20
  tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2)
21
+ zeitwerk (~> 2.2, >= 2.2.2)
21
22
  addressable (2.6.0)
22
23
  public_suffix (>= 2.0.2, < 4.0)
23
- civo (1.2.9)
24
+ civo (1.3.3)
24
25
  commander
25
26
  flexirest (>= 1.4.6)
26
27
  toml
27
28
  coderay (1.1.2)
28
29
  colorize (0.8.1)
29
- commander (4.4.7)
30
+ commander (4.5.2)
30
31
  highline (~> 2.0.0)
31
- concurrent-ruby (1.1.5)
32
+ concurrent-ruby (1.1.6)
32
33
  crack (0.4.3)
33
34
  safe_yaml (~> 1.0.0)
34
35
  diff-lcs (1.3)
35
- faraday (0.17.0)
36
+ faraday (1.0.1)
36
37
  multipart-post (>= 1.2, < 3)
37
38
  ffi (1.11.1)
38
- flexirest (1.8.6)
39
+ flexirest (1.9.15)
39
40
  activesupport
40
41
  crack
41
42
  faraday
@@ -58,19 +59,19 @@ GEM
58
59
  rspec (>= 2.99.0, < 4.0)
59
60
  hashdiff (1.0.0)
60
61
  highline (2.0.3)
61
- i18n (1.7.0)
62
+ i18n (1.8.3)
62
63
  concurrent-ruby (~> 1.0)
63
- json (2.2.0)
64
+ json (2.3.0)
64
65
  listen (3.1.5)
65
66
  rb-fsevent (~> 0.9, >= 0.9.4)
66
67
  rb-inotify (~> 0.9, >= 0.9.7)
67
68
  ruby_dep (~> 1.2)
68
69
  lumberjack (1.0.13)
69
70
  method_source (0.9.2)
70
- mime-types (3.3)
71
+ mime-types (3.3.1)
71
72
  mime-types-data (~> 3.2015)
72
- mime-types-data (3.2019.1009)
73
- minitest (5.13.0)
73
+ mime-types-data (3.2020.0512)
74
+ minitest (5.14.1)
74
75
  multi_json (1.14.1)
75
76
  multipart-post (2.1.1)
76
77
  nenv (0.3.0)
@@ -82,7 +83,7 @@ GEM
82
83
  coderay (~> 1.1.0)
83
84
  method_source (~> 0.9.0)
84
85
  public_suffix (3.1.1)
85
- rake (10.5.0)
86
+ rake (13.0.1)
86
87
  rb-fsevent (0.10.3)
87
88
  rb-inotify (0.10.0)
88
89
  ffi (~> 1.0)
@@ -109,14 +110,14 @@ GEM
109
110
  thread_safe (0.3.6)
110
111
  toml (0.2.0)
111
112
  parslet (~> 1.8.0)
112
- tzinfo (1.2.5)
113
+ tzinfo (1.2.7)
113
114
  thread_safe (~> 0.1)
114
- unicode-display_width (1.6.0)
115
+ unicode-display_width (1.7.0)
115
116
  webmock (3.7.0)
116
117
  addressable (>= 2.3.6)
117
118
  crack (>= 0.3.2)
118
119
  hashdiff (>= 0.4.0, < 2.0.0)
119
- zeitwerk (2.2.1)
120
+ zeitwerk (2.3.0)
120
121
 
121
122
  PLATFORMS
122
123
  ruby
@@ -125,10 +126,10 @@ DEPENDENCIES
125
126
  civo_cli!
126
127
  guard
127
128
  guard-rspec
128
- rake (~> 10.0)
129
+ rake (~> 13.0)
129
130
  rspec (~> 3.0)
130
131
  terminal-notifier-guard
131
132
  webmock
132
133
 
133
134
  BUNDLED WITH
134
- 1.17.3
135
+ 2.1.4
data/README.md CHANGED
@@ -7,7 +7,8 @@ Civo CLI is a tool to manage your [Civo.com](https://www.civo.com) account from
7
7
 
8
8
  ## Table of contents
9
9
  - [Introduction](#introduction)
10
- - [Set-Up](#set-up)
10
+ - [Set-Up](#set-up)
11
+ - [Docker Usage](#docker-usage)
11
12
  - [API Keys](#api-keys)
12
13
  - [Instances](#instances)
13
14
  - [Kubernetes clusters](#kubernetes-clusters)
@@ -46,24 +47,45 @@ To run the tool, simply run `civo` with your chosen options. You can find contex
46
47
  `civo instance help create`
47
48
  and so on. The main components of Civo CLI are outlined in the following sections.
48
49
 
50
+ ## Docker Usage
51
+ Civo's CLI utilty can also run within a Docker container, which avoids the need to maintain a Ruby environment on the main system.
52
+
53
+ To run, you generally will want to map the API key for persistence.
54
+
55
+ ```
56
+ touch $HOME/.civo.json
57
+ docker run -it --rm -v $HOME/.civo.json:/home/user/.civo.json civo/cli:latest
58
+ ```
59
+
60
+ To make usage easier, an alias is recommended. Here's an example how to set one to the same command as would be used if installed directly on the system, and using the Docker image:
61
+
62
+ ```
63
+ alias civo="docker run -it --rm -v $HOME/.civo.json:/home/user/.civo.json civo/cli:latest"
64
+ # Maybe put the above line in ~/.bash_profile or ~/.zshrc
65
+ civo sshkey list
66
+ civo instance list
67
+ civo instance create --size g2.xsmall
68
+ civo k8s list
69
+ ```
70
+
49
71
  ## API Keys
50
72
  #### Introduction
51
- In order to use the command-line tool, you will need to authenticate yourself to the Civo API using a special key. You can find an automatically-generated API key or regenerate a new key at [https://www.civo.com/api](https://www.civo.com/api).
73
+ In order to use the command-line tool, you will need to authenticate yourself to the Civo API using a special key. You can find an automatically-generated API key or regenerate a new key at [https://www.civo.com/api](https://www.civo.com/api).
52
74
 
53
75
  #### Adding a current API Key to your account
54
76
  You can add the API Key to the CLI tool through the API Keys command.
55
- `civo apikey add apikey_name apikey` such as:
77
+ `civo apikey add apikey_name apikey` such as:
56
78
 
57
79
  ```
58
80
  $ civo apikey add Demo_Test_Key DAb75oyqVeaE7BI6Aa74FaRSP0E2tMZXkDWLC9wNQdcpGfH51r
59
81
  Saved the API Key DAb75oyqVeaE7BI6Aa74FaRSP0E2tMZXkDWLC9wNQdcpGfH51r as Demo_Test_Key
60
82
  ```
61
- As you can have multiple API keys stored to handle multiple accounts, you will need to tell which key the tool is to authenticate with `civo apikey current [apikey_name]`. This sets your chosen API key as the default key to use for any subsequent commands:
83
+ As you can have multiple API keys stored to handle multiple accounts, you will need to tell which key the tool should use to authenticate with `civo apikey current [apikey_name]`. This sets your chosen API key as the default key to use for any subsequent commands:
62
84
  ```
63
85
  $ civo apikey current Demo_Test_Key
64
86
  The current API Key is now Demo_Test_Key
65
87
  ```
66
- #### Managing and listing API keys
88
+ #### Managing and listing API keys
67
89
  You can list all stored API keys in your configuration by invoking `civo apikey list` or remove one by name by using `civo apikey remove apikey_name`.
68
90
 
69
91
  ## Instances
@@ -107,7 +129,7 @@ $ civo instance show api-demo.test
107
129
 
108
130
  ----------------------------- NOTES -----------------------------
109
131
 
110
-
132
+
111
133
  ```
112
134
 
113
135
  You will be able to see the instance's details by running `civo instance show api-demo.test` as above.
@@ -234,7 +256,7 @@ Provided you have room in your Civo quota, you can upgrade any instance up in si
234
256
  ```
235
257
  $ civo instance upgrade api-demo-renamed.test g2.medium
236
258
  Resizing api-demo-renamed.test to g2.medium. Use 'civo instance show api-demo-renamed.test' to see the current status.
237
-
259
+
238
260
  $ civo instance show api-demo-renamed.test
239
261
  ID : 715f95d1-3cee-4a3c-8759-f9b49eec34c4
240
262
  Hostname : api-demo-renamed.test
@@ -263,7 +285,7 @@ Please note that resizing can take a few minutes.
263
285
  *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.
264
286
 
265
287
  #### List clusters
266
- To see your created domains, simply call `civo kubernetes list`:
288
+ To see your created clusters, simply call `civo kubernetes list`:
267
289
 
268
290
  ```
269
291
  $ civo kubernetes list
@@ -275,10 +297,11 @@ $ civo kubernetes list
275
297
  ```
276
298
 
277
299
  #### Create a cluster
278
- You can create an instance by running `civo kubernetes create` with a cluster name parameter, as well as any options you provide:
300
+ You can create a cluster by running `civo kubernetes create` with a cluster name parameter, as well as any options you provide:
279
301
 
280
302
  * `size` - The size of nodes to create, from the current list of sizes available at [`civo sizes`](#sizes). Defaults to `g2.medium`.
281
303
  * `nodes` - The number of nodes to create (the master also acts as a node).
304
+ * `version` - the `k3s` version to use on the cluster. Defaults to the latest.
282
305
  * `wait` - a simple flag (e.g. `--wait`) that will cause the CLI to spin and wait for the cluster to be `ACTIVE`.
283
306
  * `save` - a flag used in conjunction with `--wait` (i.e. `--wait --save`) to save the configuration to your local `~/.kube/config` file.
284
307
 
@@ -314,6 +337,13 @@ civo kubernetes rename my-first-cluster --name="Production"
314
337
  Kubernetes cluster my-first-cluster is now named Production
315
338
  ```
316
339
 
340
+ #### Starting a cluster without default applications
341
+ By default, `traefik` is bundled in with `k3s` to act as the ingress controller. If you want to set up a cluster without `traefik`, you can use the `remove-applications` option in the creation command to start a cluster without it:
342
+
343
+ ```
344
+ civo kubernetes create --remove-applications=traefik --nodes=2 --wait --save
345
+ ```
346
+
317
347
  #### Removing the cluster
318
348
  If you're completely finished with a cluster you can delete it with:
319
349
 
@@ -324,9 +354,9 @@ Removing Kubernetes cluster my-first-cluster
324
354
 
325
355
  ## Kubernetes Applications
326
356
  #### Introduction
327
- You can install applications from the [Applications Marketplace](https://github.com/civo/kubernetes-marketplace/) through the command-line interface. The installation depends on if you are creating a new cluster or adding applications to an existing cluster.
357
+ You can install applications from the [Applications Marketplace](https://github.com/civo/kubernetes-marketplace/) through the command-line interface. The installation depends on whether you are creating a new cluster or adding applications to an existing cluster.
328
358
 
329
- #### Listing Available Applications
359
+ #### Listing Available Applications
330
360
  To get an up-to-date list of available applications on the Marketplace, run `civo apps list`. At the time of writing, the list looked like this:
331
361
  ```
332
362
  +---------------------+------------+--------------+-----------------+--------------+
@@ -447,7 +477,7 @@ $ civo domainrecord create civoclidemo.xyz mx 10.0.0.1 -p=10 -t=1000
447
477
 
448
478
  #<Civo::DnsRecord id: "2079e6e1-0633-4cd0-b883-e82a8991a91a", created_at: "2019-06-17 12:38:02", updated_at: "2019-06-17 12:38:02", account_id: nil, domain_id: "418181b2-fcd2-46a2-ba7f-c843c331e79b", name: "@", value: "10.0.0.1", type: "mx", priority: 10, ttl: 1000, ETag: "187cf7e849ce53336a889b2bde7ed061", Status: 200>
449
479
  Created MX record civoclidemo.xyz for civoclidemo.xyz with a TTL of 1000 seconds and with a priority of 10 with ID 2079e6e1-0633-4cd0-b883-e82a8991a91a
450
- ```
480
+ ```
451
481
  #### Listing DNS Records
452
482
  You can get an overview of all records you have created for a particular domain by requesting `civo domainrecord list domain.name`:
453
483
  ```
@@ -482,7 +512,7 @@ You will then be able to **configure rules** that allow connections to and from
482
512
  * `start_port` - The starting port that the rule applies to. Required.
483
513
  * `end_port` - The end of the port range that the rule applies to. Optional; if not specified, the rule will only apply to `start_port` specified.
484
514
  * `protocol` - The protocol for the rule (`TCP, UDP, ICMP`). If not provided, defaults to `TCP`.
485
- * `cidr` - The IP address of the other end (i.e. not your instance) to affect, or a valid network CIDR. Defaults to being globally applied, i.e. `0.0.0.0/0`.
515
+ * `cidr` - The IP address of the other end (i.e. not your instance) to affect, or a valid network CIDR. Defaults to being globally applied, i.e. `0.0.0.0/0`.
486
516
  * `direction` - Will this rule affect `inbound` or `outbound` traffic? Defaults to `inbound`.
487
517
  * `label` - A label for your own reference for this rule. Optional.
488
518
 
@@ -521,7 +551,7 @@ You can remove a firewall rule simply by calling `civo firewall delete_rule fire
521
551
  ```
522
552
  $ civo firewall delete_rule 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 4070f87b-e6c6-4208-91c5-fc4bc72c1587
523
553
  Removed Firewall rule 4070f87b-e6c6-4208-91c5-fc4bc72c1587
524
-
554
+
525
555
  $ civo firewall list_rules 09f8d85b-0cf1-4dcf-a472-ba247fb4be21
526
556
  +-------+----------+------------+----------+------+-------+
527
557
  | Firewall rules for 09f8d85b-0cf1-4dcf-a472-ba247fb4be21 |
@@ -565,7 +595,7 @@ Removed the network cli-demo with ID 74b69006-ea59-46a0-96c4-63f5bfa290e1
565
595
 
566
596
  ## Load Balancers
567
597
  #### Introduction
568
- Civo supports load balancing for your instances, allowing you to spread web traffic between them to maximise availability. You can view details about load balancers you may have running, create new oness, update information and even remove them from the command line.
598
+ Civo supports load balancing for your instances, allowing you to spread web traffic between them to maximise availability. You can view details about load balancers you may have running, create new oness, update information and even remove them from the command line.
569
599
 
570
600
  #### Viewing Load Balancers
571
601
  You can list currently-active load balancers by calling `civo loadbalancer list`. This will draw a table detailing the unique ID, hostname, protocol, port, TLS certificate information, backend check path and connection information.
@@ -742,7 +772,7 @@ Detailed information about a template can be obtained via the CLI using `civo te
742
772
  #### Creating a Template
743
773
  You can convert a **bootable** Volume (virtual disk) of an instance, or alternatively use an existing image ID, to create a template. The options for the `civo template create` command are:
744
774
  ```
745
- Options:
775
+ Options:
746
776
  -c, [--cloud-init-file=CLOUD_INIT_FILENAME] # The filename of a file to be used as user-data/cloud-init
747
777
  -d, [--description=DESCRIPTION] # A full/long multiline description (optional)
748
778
  -i, [--image-id=IMAGE_ID] # The glance ID of the base filesystem image
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.required_ruby_version = '~> 2.0'
40
40
 
41
- spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rake", "~> 13.0"
42
42
  spec.add_development_dependency "rspec", "~> 3.0"
43
43
  spec.add_development_dependency "guard"
44
44
  spec.add_development_dependency "guard-rspec"
@@ -51,4 +51,5 @@ Gem::Specification.new do |spec|
51
51
  spec.add_runtime_dependency "bundler", ">= 1.17"
52
52
  spec.add_runtime_dependency 'civo', ">= 1.2.9"
53
53
  spec.add_runtime_dependency 'json'
54
+ spec.add_runtime_dependency 'activesupport', ">= 6.0.0"
54
55
  end
@@ -0,0 +1,6 @@
1
+ FROM ruby:alpine
2
+ MAINTAINER Steve Miller <me@r15cookie.com>
3
+ RUN gem install civo_cli
4
+ RUN adduser -S user
5
+ USER user
6
+ ENTRYPOINT ["civo"]
@@ -0,0 +1,21 @@
1
+ # Civo CLI in Docker
2
+
3
+ Build a Docker container embedded with the latest `civo` command. Note that it does NOT yet build from source;
4
+ it simply pulls the latest Civo CLI from RubyGems. Usage is in the main repo's README. The Docker that builds
5
+ from source is a work in progress and available at https://github.com/ssmiller25/cli/tree/dockerbuild
6
+
7
+ ## Pushing to Civo's official DockerHub
8
+
9
+ For Civo staff only: from the cloned repository, build it with the current version and "latest" tags:
10
+
11
+ ```
12
+ docker build -t civo/cli:latest -f docker/Dockerfile .
13
+ docker build -t civo/cli:0.x.y -f docker/Dockerfile .
14
+ ```
15
+
16
+ Then after running `docker login` to authenticate to the Civo organisation you can do:
17
+
18
+ ```
19
+ docker push civo/cli:latest
20
+ docker push civo/cli:0.x.y
21
+ ```
@@ -21,14 +21,16 @@ module CivoCLI
21
21
  def add(name, key)
22
22
  CivoCLI::Config.set_apikey(name, key)
23
23
  puts "Saved the API Key #{key.colorize(:green)} as #{name.colorize(:green)}"
24
+ current(name)
24
25
  end
25
26
 
26
27
  desc "remove NAME", "Remove the API Key with a label of 'NAME'"
27
28
  def remove(name)
28
- keys = CivoCLI::Config.get_apikeys
29
+ keys = CivoCLI::Config.get_apikeys
29
30
  if keys.keys.include?(name)
30
31
  CivoCLI::Config.delete_apikey(name)
31
32
  puts "Removed the API Key #{name.colorize(:green)}"
33
+ current(nil)
32
34
  else
33
35
  puts "The API Key #{name.colorize(:red)} couldn't be found."
34
36
  exit 1
@@ -37,9 +39,12 @@ module CivoCLI
37
39
  map "delete" => "remove", "rm" => "remove"
38
40
 
39
41
  desc "current [NAME]", "Either return the name of the current API key or set the current key to be the one with a label of 'NAME'"
40
- def current(name=nil)
41
- if name.nil?
42
- puts "The current API Key is #{CivoCLI::Config.get_current_apikey_name.colorize(:green)}"
42
+ def current(name = nil)
43
+ currentkey = CivoCLI::Config.get_current_apikey_name
44
+ if name.nil? && currentkey
45
+ puts "The current API Key is #{currentkey.colorize(:green)}"
46
+ elsif name.nil? && !currentkey
47
+ puts "No current API Key set".colorize(:red)
43
48
  else
44
49
  keys = CivoCLI::Config.get_apikeys
45
50
  if keys.keys.include?(name)
@@ -12,6 +12,10 @@ module CivoCLI
12
12
  class Error < StandardError; end
13
13
 
14
14
  class Main < Thor
15
+ puts "This Ruby-based CLI is officially deprecated and won't be maintained going forward"
16
+ puts "For a supported version please visit: https://github.com/civo/cli/releases"
17
+ puts
18
+
15
19
  check_unknown_options!
16
20
 
17
21
  desc "apikey", "manage API keys stored in the client"
@@ -93,22 +97,10 @@ module CivoCLI
93
97
 
94
98
  desc "version", "show the version of Civo CLI used"
95
99
  def version
96
- gem_details = Civo::Base._request("https://rubygems.org/api/v1/gems/civo_cli.json")
97
- gem_version = Gem::Version.new(gem_details.version)
98
- this_version = Gem::Version.new(CivoCLI::VERSION)
99
- if this_version > gem_version
100
- puts "You are running an #{"unreleased v#{CivoCLI::VERSION}".colorize(:green)} of Civo CLI"
101
- elsif this_version == gem_version
102
- puts "You are running the #{"current".colorize(:green)} v#{CivoCLI::VERSION} of Civo CLI"
103
- else
104
- puts "You are running v#{CivoCLI::VERSION} of Civo CLI, but are out of date because #{"v#{gem_details.version}".colorize(:red)} is available"
105
-
106
- end
107
100
  end
108
101
 
109
102
  desc "volume", "manage volumes"
110
103
  subcommand "volume", CivoCLI::Volume
111
104
  map "volumes" => "volume"
112
-
113
105
  end
114
106
  end
@@ -1,3 +1,3 @@
1
1
  module CivoCLI
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.10"
3
3
  end
@@ -16,10 +16,15 @@ module CivoCLI
16
16
  rows = []
17
17
  Civo::Kubernetes.all.items.each do |cluster|
18
18
  version = cluster.kubernetes_version
19
- if Gem::Version.new(latest_version) > Gem::Version.new(version)
20
- upgrade_available = true
21
- version = "#{version} *".colorize(:red)
19
+
20
+ if cluster.kubernetes_version != "development"
21
+ latest_version = get_latest_k3s_version.gsub!(/[+]/, "")
22
+ if Gem::Version.new(latest_version) > Gem::Version.new(version)
23
+ upgrade_available = true
24
+ version = "#{version} *".colorize(:red)
25
+ end
22
26
  end
27
+
23
28
  rows << [cluster.id, cluster.name, cluster.num_target_nodes, cluster.target_nodes_size, version, cluster.status]
24
29
  end
25
30
  puts Terminal::Table.new headings: ['ID', 'Name', '# Nodes', 'Size', 'Version', 'Status'], rows: rows
@@ -164,6 +169,7 @@ module CivoCLI
164
169
  option :save, type: :boolean
165
170
  option :switch, type: :boolean
166
171
  option :applications, type: :string, aliases: %w{apps app application}
172
+ option :remove_applications, type: :string
167
173
  long_desc <<-LONGDESC
168
174
  Create a new Kubernetes cluster with name (randomly assigned if blank), instance size (default: g2.medium),
169
175
  \x5\x5Optional parameters are as follows:
@@ -171,6 +177,7 @@ module CivoCLI
171
177
  \x5 --nodes=<count> - '3' if blank
172
178
  \x5 --version=<version> - our latest k3s version if blank
173
179
  \x5 --applications=name1,name2 - optional, use names shown by running `civo applications`
180
+ \x5 --remove-applications=name1,name2 - optional, remove default application names shown by running `civo applications`
174
181
  \x5 --wait - wait for build to complete and show status. Off by default.
175
182
  \x5 --save - save resulting configuration to ~/.kube/config (requires kubectl and the --wait option)
176
183
  \x5 --switch - switch context to newly-created cluster (requires kubectl and the --wait and --save options, as well as existing kubeconfig file)
@@ -207,6 +214,14 @@ module CivoCLI
207
214
  end
208
215
  end
209
216
 
217
+ (options[:remove_applications] || "").split(",").map(&:chomp).each do |name|
218
+ app = Finder.detect_app(name)
219
+ unless app.default # Not a default application, no need to remove
220
+ next
221
+ end
222
+ applications << "-#{app.name}"
223
+ end
224
+
210
225
  @cluster = Civo::Kubernetes.create(name: name, target_nodes_size: options[:size], num_target_nodes: options[:nodes], applications: applications.join(","), version: options[:version])
211
226
 
212
227
  if options[:wait]
@@ -315,33 +330,33 @@ module CivoCLI
315
330
  end
316
331
 
317
332
  def save_config(cluster)
318
- config_file_exists = File.exist?("#{ENV["HOME"]}/.kube/config")
333
+ config_file_exists = File.exist?(ENV['KUBECONFIG'] || "#{Dir.home}/.kube/config")
319
334
  tempfile = Tempfile.new('import_kubeconfig')
320
335
  begin
321
336
  tempfile.write(cluster.kubeconfig)
322
337
  tempfile.size
323
338
  if windows?
324
- home = `echo %HOMEPATH%`.chomp
325
339
  if options[:switch]
326
- ENV['KUBECONFIG'] = "#{tempfile.path};#{home}\\.kube\\config"
340
+ ENV['KUBECONFIG'] = "#{tempfile.path};" + (ENV['KUBECONFIG'] ? ENV['KUBECONFIG'] : "#{Dir.home}\\.kube\\config")
327
341
  else
328
- ENV['KUBECONFIG'] = "#{home}\\.kube\\config;#{tempfile.path}"
342
+ ENV['KUBECONFIG'] = (ENV['KUBECONFIG'] ? ENV['KUBECONFIG'] : "#{Dir.home}\\.kube\\config") + ";#{tempfile.path}"
329
343
  end
330
344
  result = `kubectl config view --flatten`
331
345
  else
332
346
  if options[:switch]
333
- result = `KUBECONFIG=#{tempfile.path}:~/.kube/config kubectl config view --flatten`
347
+ result = `KUBECONFIG=#{tempfile.path}:#{ENV['KUBECONFIG'] || "~/.kube/config"} kubectl config view --flatten`
334
348
  else
335
- result = `KUBECONFIG=~/.kube/config:#{tempfile.path} kubectl config view --flatten`
349
+ puts "KUBECONFIG=#{ENV['KUBECONFIG'] || "~/.kube/config"}:#{tempfile.path} kubectl config view --flatten"
350
+ result = `KUBECONFIG=#{ENV['KUBECONFIG'] || "~/.kube/config"}:#{tempfile.path} kubectl config view --flatten`
336
351
  end
337
352
  end
338
353
  write_file(result)
339
354
  if config_file_exists && options[:switch]
340
- puts "Merged".colorize(:green) + " config into ~/.kube/config and switched context to #{cluster.name}"
355
+ puts "Merged".colorize(:green) + " config into #{ENV['KUBECONFIG'] || "~/.kube/config"} and switched context to #{cluster.name}"
341
356
  elsif config_file_exists && !options[:switch]
342
- puts "Merged".colorize(:green) + " config into ~/.kube/config"
357
+ puts "Merged".colorize(:green) + " config into #{ENV['KUBECONFIG'] || "~/.kube/config"}"
343
358
  else
344
- puts "Saved".colorize(:green) + " config to ~/.kube/config"
359
+ puts "Saved".colorize(:green) + " config to #{ENV['KUBECONFIG'] || "~/.kube/config"}"
345
360
  end
346
361
  ensure
347
362
  tempfile.close
@@ -350,8 +365,12 @@ module CivoCLI
350
365
  end
351
366
 
352
367
  def write_file(result)
353
- Dir.mkdir("#{ENV['HOME']}/.kube/") unless Dir.exist?("#{ENV["HOME"]}/.kube/")
354
- File.write("#{ENV['HOME']}/.kube/config", result)
368
+ if ENV['KUBECONFIG']
369
+ File.write(ENV["KUBECONFIG"], result)
370
+ else
371
+ Dir.mkdir("#{Dir.home}/.kube/") unless Dir.exist?("#{Dir.home}/.kube/")
372
+ File.write("#{Dir.home}/.kube/config", result)
373
+ end
355
374
  end
356
375
 
357
376
  def reject_user_access
@@ -371,7 +390,7 @@ module CivoCLI
371
390
  else
372
391
  k3s = available_versions.detect {|v| v.default}
373
392
  k3s ||= available_versions.first
374
- k3s.version
393
+ k3s.version.gsub(/[+]/, "")
375
394
  end
376
395
  end
377
396
  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.5.5
4
+ version: 0.5.10
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-11-12 00:00:00.000000000 Z
13
+ date: 2020-06-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '10.0'
21
+ version: '13.0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '10.0'
28
+ version: '13.0'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +180,20 @@ dependencies:
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
+ - !ruby/object:Gem::Dependency
184
+ name: activesupport
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: 6.0.0
190
+ type: :runtime
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: 6.0.0
183
197
  description: The official command line client for interacting with Civo's API
184
198
  email:
185
199
  - andy@civo.com
@@ -203,6 +217,8 @@ files:
203
217
  - bin/console
204
218
  - bin/setup
205
219
  - civo_cli.gemspec
220
+ - docker/Dockerfile
221
+ - docker/README.md
206
222
  - exe/civo
207
223
  - lib/apikey.rb
208
224
  - lib/ask_service.rb
@@ -252,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
268
  - !ruby/object:Gem::Version
253
269
  version: '0'
254
270
  requirements: []
255
- rubygems_version: 3.0.6
271
+ rubygems_version: 3.1.2
256
272
  signing_key:
257
273
  specification_version: 4
258
274
  summary: CLI for interacting with Civo.com