sct 0.1.17 → 0.1.18

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb3124f71d7225fc1c88fb1385b1de8c308b3cb9dcd3621c57d82c681b90ea10
4
- data.tar.gz: bdc089394ec064af60751b213a57f491752bb3184e6eacdc11d8367ed65d7658
3
+ metadata.gz: c9a10c8fd025fd2f32f82840295ef14bd7da4604ab7f90e4d0f0f107b902ab0c
4
+ data.tar.gz: a719ae52d73c95fdff15652350046e75e6fe1bf99f3f893d85a577ed2f78efa5
5
5
  SHA512:
6
- metadata.gz: a8a45d11bc4c50a627a913a8a38cd602eadd4520c2064a14801b9c31bc5e3943f6cb0c2cf2487bc8e191096b81a9797f12790a73267e46758fb6403ea5c1cec3
7
- data.tar.gz: 696c6ae0977971f48f9460113b11aca055a6687f884adb70606eab9d2d6822bfb37c33c8cc45bd66e8bc216b601b750fa24d45babef9a0e0c638bd32f8e17f31
6
+ metadata.gz: 3777d0a28ceab88ebc43d3442068d55c5e95c6a2eaef141be7e71a81851e22e5feaf676c282e58fa662f65875fe9333a62b64211bee00a0b87b5b2e4c35aceb3
7
+ data.tar.gz: 04a36128ed9daf630791e025877800337a21efb0ddd9c374535878cc74c734c5fc502ff676ddeae57bc12888bccaeb7ae3777dcf4b2bf79db8c4e69af3109629
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sct (0.1.15)
4
+ sct (0.1.16)
5
5
  class_interface (~> 0.1.1)
6
6
  colored (~> 1.2)
7
7
  commander (~> 4.4.7)
8
8
  highline (>= 1.7.2)
9
+ terminal-table (~> 1.8)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -30,6 +31,9 @@ GEM
30
31
  diff-lcs (>= 1.2.0, < 2.0)
31
32
  rspec-support (~> 3.9.0)
32
33
  rspec-support (3.9.2)
34
+ terminal-table (1.8.0)
35
+ unicode-display_width (~> 1.1, >= 1.1.1)
36
+ unicode-display_width (1.7.0)
33
37
 
34
38
  PLATFORMS
35
39
  ruby
@@ -6,11 +6,11 @@ module Sct
6
6
  class ClusterCommand
7
7
 
8
8
  IS_PUBLIC_COMMAND = true
9
- SYNTAX = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods'
9
+ SYNTAX = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods | sct cluster status'
10
10
  SUMMARY = 'Perform actions on the minikube cluster.'
11
- EXAMPLE = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods'
11
+ EXAMPLE = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods | sct cluster status'
12
12
  EXAMPLE_DESCRIPTION = 'Perform actions on the minikube cluster.'
13
- DESCRIPTION = "sct cluster allows you to start, stop, setup/reset, update the config, or delete the stalled pods of the Spend Cloud minikube cluster."
13
+ DESCRIPTION = "sct cluster allows you to start, stop, setup/reset, update the config, delete the stalled pods, or status of the Spend Cloud minikube cluster."
14
14
 
15
15
  OPTIONS = []
16
16
 
@@ -31,7 +31,7 @@ module Sct
31
31
  when "status"
32
32
  status
33
33
  else
34
- puts "Unknown or missing argument. Please run 'sct cluster up', 'sct cluster down', 'sct cluster setup', 'sct cluster reset', 'sct cluster update-config', or 'sct cluster delete-stalled-pods'.".red
34
+ puts "Unknown or missing argument. Please run 'sct cluster --help'.".red
35
35
  end
36
36
  end
37
37
 
@@ -155,58 +155,60 @@ module Sct
155
155
  end
156
156
 
157
157
  def status
158
- minikube_status
159
- pods_status
160
- system_pods
161
- current_contexts
162
- end
158
+ print_contexts
159
+ print_minikube_status
163
160
 
164
- def pods_status
165
- rows = []
166
- pods.map do |pod|
167
- status = pod[:status] == "Running" ? pod[:status].green : pod[:status].red
168
- rows << [pod[:name], status]
169
- end
170
- puts Terminal::Table.new :title => "Pods Status".green, :headings => ['Name', 'Status'], :rows => rows
171
- end
172
-
173
- def system_pods
174
- rows = []
175
- pods("kube-system").map do |pod|
176
- status = pod[:status] == "Running" ? pod[:status].green : pod[:status].red
177
- rows << [pod[:name], status]
178
- end
179
- puts Terminal::Table.new :title => "System pods Status".green, :headings => ['Name', 'Status'], :rows => rows
161
+ if get_minikube_status.find_all { |status| status[1] == 'Stopped' }.count == 0
162
+ print_pods_status("kube-system")
163
+ print_pods_status
164
+ else
165
+ puts "Please check your minikube status. If all services are stopped you should start the minikube first.".yellow
166
+ end
180
167
  end
181
168
 
182
- def current_contexts
169
+ def print_contexts
183
170
  output = `kubectl config get-contexts`
184
171
 
185
172
  lines = output.split "\n"
186
173
  lines = lines[1..-1]
187
174
 
188
- rows = []
189
- lines.map do |line|
190
- columns = line.split(" ")
175
+ rows = lines.map do |line|
176
+ columns = line.split(" ")
177
+
178
+ current_context = columns[0] == "*" ? "Yes".green : "No".red
191
179
 
192
- current_context = columns[0] == "*" ? "Yes".green : "No".red
193
- rows << [columns[2], current_context]
180
+ [columns[2], current_context]
194
181
  end
195
- puts Terminal::Table.new :title => "Contexts".green, :headings => ['Cluster', 'Using context'], :rows => rows
182
+
183
+ puts Terminal::Table.new title: "Contexts".green, headings: ['Cluster', 'Using context'], rows: rows
184
+ end
185
+
186
+ def print_minikube_status
187
+
188
+ puts Terminal::Table.new title: "Minikube status".green, headings: ['Name', 'Status'], rows: get_minikube_status
196
189
  end
197
190
 
198
- def minikube_status
191
+ def get_minikube_status
199
192
  output = `#{minikube} status`
200
193
 
201
194
  lines = output.split "\n"
202
195
 
203
- rows = []
204
- lines.map do |line|
196
+ rows = lines.map do |line|
205
197
  columns = line.split(" ")
206
198
 
207
- rows << [columns[0], columns[1]]
199
+ [columns[0][0..-2], columns[1]]
208
200
  end
209
- puts Terminal::Table.new :title => "Minikube Status".green, :headings => ['Name', 'Status'], :rows => rows
201
+ end
202
+
203
+ def print_pods_status(namespace = nil)
204
+ rows = pods(namespace).map do |pod|
205
+ [
206
+ pod[:name],
207
+ pod[:status] == "Running" ? pod[:status].green : pod[:status].red
208
+ ]
209
+ end
210
+
211
+ puts Terminal::Table.new title: "Pods (namespace: #{namespace || "default"})".green, headings: ['Name', 'Status'], rows: rows
210
212
  end
211
213
 
212
214
  def pods(namespace = nil)
data/lib/sct/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sct
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reshad Farid
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.0.6
193
+ rubygems_version: 3.0.3
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Spend Cloud Tool.