civo_cli 0.3.14 → 0.3.15
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 +1 -1
- data/lib/ask_service.rb +22 -0
- data/lib/civo_cli/version.rb +1 -1
- data/lib/finder.rb +1 -1
- data/lib/kubernetes.rb +34 -2
- data/lib/kubernetes_applications.rb +28 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aabcc396a2225eb28d5f2f79c73478007b634bb6de5d69f43db7c6f40318f84
|
4
|
+
data.tar.gz: 7098b73a6754c32efdd137416bebf318867843875cbb5a2c31ba980d37b20488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24d185d2934e3138ae7c0bd4eb50b5c5580f684216bf9c4cb03d7cfc016713e0a3a14314643c97c16b52d9307af4dc4831d0550eb842d9b04ee8a7adca437ded
|
7
|
+
data.tar.gz: 6a1d5caa05c0792fcc768aadef6c36984aea1faeaacf84748d3e1df4498995162dab7aa8a55049d0e0b60a10246f40610baaa835ad9fc586999ebe5d389dceea
|
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.3.15] - 2019-08-30
|
7
|
+
### Add
|
8
|
+
- Added plan support to the Kubernetes marketplace
|
9
|
+
|
6
10
|
## [0.3.14] - 2019-08-28
|
7
11
|
### Fixed
|
8
12
|
- Removed debug level logging for Kubernetes marketplace applications commands
|
data/Gemfile.lock
CHANGED
data/lib/ask_service.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class AskService
|
2
|
+
def self.available?
|
3
|
+
STDIN.tty?
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.choose(label, options)
|
7
|
+
result = options.first
|
8
|
+
printf "#{label} (#{options.join(", ")}) [#{options.first}]: "
|
9
|
+
input = STDIN.gets.chomp
|
10
|
+
result = input unless input.empty?
|
11
|
+
unless options.include?(result)
|
12
|
+
puts "That wasn't one of the available options.".colorize(:red) + " Please try again."
|
13
|
+
result = choose(label, options)
|
14
|
+
end
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
trap "SIGINT" do
|
20
|
+
puts "Exiting..."
|
21
|
+
exit 2
|
22
|
+
end
|
data/lib/civo_cli/version.rb
CHANGED
data/lib/finder.rb
CHANGED
data/lib/kubernetes.rb
CHANGED
@@ -55,7 +55,12 @@ module CivoCLI
|
|
55
55
|
puts "Installed marketplace applications:"
|
56
56
|
rows = []
|
57
57
|
cluster.installed_applications.each do |application|
|
58
|
-
|
58
|
+
name = application.application
|
59
|
+
if application.plan
|
60
|
+
name += " #{application.plan}"
|
61
|
+
end
|
62
|
+
installed = application.installed ? "Yes" : "Not yet"
|
63
|
+
rows << [name, application.version, installed, application.category]
|
59
64
|
end
|
60
65
|
puts Terminal::Table.new headings: ['Name', 'Version', 'Installed', 'Category'], rows: rows
|
61
66
|
end
|
@@ -94,6 +99,7 @@ module CivoCLI
|
|
94
99
|
option :wait, type: :boolean, banner: 'wait until cluster is running'
|
95
100
|
option :save, type: :boolean
|
96
101
|
option :switch, type: :boolean
|
102
|
+
option :applications, type: :string
|
97
103
|
long_desc <<-LONGDESC
|
98
104
|
Create a new Kubernetes cluster with name (randomly assigned if blank), instance size (default: g2.medium),
|
99
105
|
\x5\x5Optional parameters are as follows:
|
@@ -106,7 +112,33 @@ module CivoCLI
|
|
106
112
|
LONGDESC
|
107
113
|
def create(name = CivoCLI::NameGenerator.create, *args)
|
108
114
|
CivoCLI::Config.set_api_auth
|
109
|
-
|
115
|
+
|
116
|
+
applications = []
|
117
|
+
options[:applications].split(",").map(&:chomp).each do |name|
|
118
|
+
name, plan = name.split(":")
|
119
|
+
app = Finder.detect_app(name)
|
120
|
+
plans = app.plans&.items
|
121
|
+
|
122
|
+
if app && plans.present? && plan.blank?
|
123
|
+
if AskService.available?
|
124
|
+
plan = AskService.choose("You requested to add #{app.name} but didn't select a plan. Please choose one...", plans.map(&:label))
|
125
|
+
if plan.present?
|
126
|
+
puts "Thank you, next time you could use \"#{app.name}:#{plan}\" to choose automatically"
|
127
|
+
end
|
128
|
+
else
|
129
|
+
puts "You need to specify a plan".colorize(:red) + " from those available (#{plans.join(", ")} using the syntax \"#{app.name}:plan\""
|
130
|
+
exit 1
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
if plan.present?
|
135
|
+
applications << "#{app.name}:#{plan}"
|
136
|
+
else
|
137
|
+
applications << app.name
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
@cluster = Civo::Kubernetes.create(name: name, target_nodes_size: options[:size], num_target_nodes: options[:nodes], applications: applications.join(","))
|
110
142
|
|
111
143
|
if options[:wait]
|
112
144
|
timer = CivoCLI::Timer.new
|
@@ -13,9 +13,16 @@ module CivoCLI
|
|
13
13
|
else
|
14
14
|
rows = []
|
15
15
|
Civo::Kubernetes.applications.items.each do |app|
|
16
|
-
|
16
|
+
plans = app.plans&.items
|
17
|
+
if plans.present?
|
18
|
+
plans = plans.map {|p| p.label}.join(", ")
|
19
|
+
else
|
20
|
+
plans = "Not applicable"
|
21
|
+
end
|
22
|
+
|
23
|
+
rows << [app.name, app.version, app.category, plans]
|
17
24
|
end
|
18
|
-
puts Terminal::Table.new headings: ['Name', 'Version', 'Category'], rows: rows
|
25
|
+
puts Terminal::Table.new headings: ['Name', 'Version', 'Category', 'Plans'], rows: rows
|
19
26
|
end
|
20
27
|
rescue Flexirest::HTTPForbiddenClientException
|
21
28
|
reject_user_access
|
@@ -49,10 +56,28 @@ module CivoCLI
|
|
49
56
|
LONGDESC
|
50
57
|
def add(name)
|
51
58
|
CivoCLI::Config.set_api_auth
|
59
|
+
name, plan = name.split(":")
|
52
60
|
app = Finder.detect_app(name)
|
53
61
|
cluster = Finder.detect_cluster(options[:cluster])
|
62
|
+
plans = app.plans&.items
|
63
|
+
|
64
|
+
if app && plans.present? && plan.blank?
|
65
|
+
if AskService.available?
|
66
|
+
plan = AskService.choose("You requested to add #{app.name} but didn't select a plan. Please choose one...", plans.map(&:label))
|
67
|
+
if plan.present?
|
68
|
+
puts "Thank you, next time you could use \"#{app.name}:#{plan}\" to choose automatically"
|
69
|
+
end
|
70
|
+
else
|
71
|
+
puts "You need to specify a plan".colorize(:red) + " from those available (#{plans.join(", ")} using the syntax \"#{app.name}:plan\""
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
end
|
54
75
|
|
55
|
-
|
76
|
+
if plan.present?
|
77
|
+
Civo::Kubernetes.update(id: cluster.id, applications: "#{app.name}:#{plan}")
|
78
|
+
else
|
79
|
+
Civo::Kubernetes.update(id: cluster.id, applications: app.name)
|
80
|
+
end
|
56
81
|
puts "Added #{app.name.colorize(:green)} #{app.version} to Kubernetes cluster #{cluster.name.colorize(:green)}"
|
57
82
|
rescue Flexirest::HTTPException => e
|
58
83
|
puts e.result.reason.colorize(:red)
|
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.3.
|
4
|
+
version: 0.3.15
|
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-08-
|
13
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- civo_cli.gemspec
|
206
206
|
- exe/civo
|
207
207
|
- lib/apikey.rb
|
208
|
+
- lib/ask_service.rb
|
208
209
|
- lib/blueprint.rb
|
209
210
|
- lib/civo_cli.rb
|
210
211
|
- lib/civo_cli/version.rb
|