sct 0.1.20 → 0.1.21

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: 886dba5184c321ede1c67d28d391bdea4c65c91d2039113c6efcd19271af52d5
4
- data.tar.gz: 1a0d8b618938924eb2b5fb5bb2009e71cfdf066e42e6bc125845c9a272715e37
3
+ metadata.gz: fd0c29ef1fa29ea92d1ecd0e5190b72a10a6b8253c93e3cdea79c6cf02093bc8
4
+ data.tar.gz: 987dcdf7f07e610c7c1f5dadf0096dbd006bd4a8da601cdeb59919c5b8fb95ac
5
5
  SHA512:
6
- metadata.gz: 999c86de5b963c310cd538bf216ff8a4efa60390674a579e8c62b5f8b5e3b366203e0970180ffca104803e381826261be7902b6bd881dcb38086def2b871f8b4
7
- data.tar.gz: f0dcfa20601a483a703f0c9f40ea64ecfd12e68251d63bafd77f77fcdf6bee9c97f93d1fe66446ec0cd66624ff8e1fa3f80386a6fde0fabdda76bcba13baca11
6
+ metadata.gz: 7cef3c668d1ff1bf1e92a0d1363582f6310af7f639c15983168cd5ee03e5885d05a4c409c518d90b53b74fedf3f1ac71945e201772dd131fc97ee3e652b062fe
7
+ data.tar.gz: 98ed6109ff77991041a559db372a2a74e45b6693725025e258c020f506df77c355505af0510050fb2269566b994e42e6a247a03ac08f4538e70833904fd6014d
@@ -83,7 +83,21 @@ module Cluster
83
83
  c.action do |args, options|
84
84
 
85
85
  Cluster::Runner.new.delete_stalled_pods if options.stalled
86
- UI.important("Currently its not possible to delete all pods") if options.all
86
+ Cluster::Runner.new.delete_all_pods if options.all
87
+
88
+ Cluster::Runner.new.delete_pods(args) if !args.empty?
89
+
90
+ end
91
+ end
92
+
93
+ command :'apply pods' do |c|
94
+ c.syntax = 'sct cluster apply pods'
95
+ c.description = 'apply pods from the k8s folder'
96
+
97
+ c.action do |args, options|
98
+
99
+ Cluster::Runner.new.apply_pods
100
+
87
101
  end
88
102
  end
89
103
 
@@ -71,6 +71,18 @@ module Cluster
71
71
  end
72
72
  end
73
73
 
74
+ def delete_all_pods
75
+ run_command "kubectl delete pods --all"
76
+ end
77
+
78
+ def delete_pods(args)
79
+ run_command "kubectl delete pods #{args.join(" ")}"
80
+ end
81
+
82
+ def apply_pods
83
+ run_command "kubectl apply -f ~/development/spend-cloud/k8s/"
84
+ end
85
+
74
86
  def update_config
75
87
  if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
76
88
  windows_home_path = SctCore::Helper.windowsHomePath
@@ -40,7 +40,11 @@ module Sct
40
40
  require "sct/commands_generator"
41
41
  Sct::CommandsGenerator.start
42
42
  end
43
+ ensure
44
+ SctCore::UpdateChecker.start_looking_for_update('sct')
45
+ SctCore::UpdateChecker.show_update_status('sct', Sct::VERSION)
43
46
  end
47
+
44
48
  end
45
49
  end
46
50
  end
@@ -1,3 +1,3 @@
1
1
  module Sct
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require_relative 'sct_core/core_ext/string'
2
2
  require_relative 'sct_core/config'
3
3
  require_relative 'sct_core/helper'
4
+ require_relative 'sct_core/update_checker/update_checker'
4
5
  require_relative 'sct_core/command_executor'
5
6
  require_relative 'sct_core/ui/ui'
6
7
  require_relative 'sct_core/sct_pty'
@@ -0,0 +1,76 @@
1
+
2
+ require 'excon'
3
+ require 'json'
4
+
5
+ module SctCore
6
+ class UpdateChecker
7
+ def self.start_looking_for_update(gem_name)
8
+ begin
9
+ server_results[gem_name] = fetch_latest(gem_name)
10
+ rescue => e
11
+ # ignore possible exceptions
12
+ UI.verbose("error occured fetching latest version #{e.message}")
13
+ end
14
+ end
15
+
16
+ def self.server_results
17
+ @results ||= {}
18
+ end
19
+
20
+ def self.update_available?(gem_name, current_version)
21
+ latest = server_results[gem_name]
22
+ return (latest and Gem::Version.new(latest) > Gem::Version.new(current_version))
23
+ end
24
+
25
+ def self.show_update_status(gem_name, current_version)
26
+ if update_available?(gem_name, current_version)
27
+ show_update_message(gem_name, current_version)
28
+ end
29
+ end
30
+
31
+ def self.show_update_message(gem_name, current_version)
32
+ available = server_results[gem_name]
33
+ puts("")
34
+ UI.important('#######################################################################')
35
+ if available
36
+ UI.important("# #{gem_name} #{available} is available. You are on #{current_version}.")
37
+ else
38
+ UI.important("# An update for #{gem_name} is available. You are on #{current_version}.")
39
+ end
40
+ UI.important("# You should use the latest version.")
41
+ UI.important("# Please update using `#{self.update_command(gem_name: gem_name)}`.")
42
+
43
+ UI.important('#######################################################################')
44
+ UI.important("# Run `sudo gem cleanup` from time to time to speed up sct.")
45
+
46
+ UI.important('#######################################################################')
47
+
48
+ ensure_rubygems_source
49
+ end
50
+
51
+ # Check if RubyGems is set as a gem source
52
+ # on some machines that might not be the case
53
+ # and then users can't find the update when
54
+ # running the specified command
55
+ def self.ensure_rubygems_source
56
+ return if `gem sources`.include?("https://rubygems.org")
57
+ puts("")
58
+ UI.error("RubyGems is not listed as your Gem source")
59
+ UI.error("You can run `gem sources` to see all your sources")
60
+ UI.error("Please run the following command to fix this:")
61
+ UI.command("gem sources --add https://rubygems.org")
62
+ end
63
+
64
+ def self.update_command(gem_name: "sct")
65
+ "sudo gem install #{gem_name.downcase}"
66
+ end
67
+
68
+ def self.fetch_latest(gem_name)
69
+ JSON.parse(Excon.get(generate_fetch_url(gem_name)).body)["version"]
70
+ end
71
+
72
+ def self.generate_fetch_url(gem_name)
73
+ "https://rubygems.org/api/v1/gems/#{gem_name}.json"
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reshad Farid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -66,6 +66,40 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: excon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.71.0
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: 1.0.0
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.71.0
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.0.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: json
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: 3.0.0
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: 3.0.0
69
103
  - !ruby/object:Gem::Dependency
70
104
  name: tty-screen
71
105
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +226,7 @@ files:
192
226
  - sct_core/lib/sct_core/ui/implementations/shell.rb
193
227
  - sct_core/lib/sct_core/ui/interface.rb
194
228
  - sct_core/lib/sct_core/ui/ui.rb
229
+ - sct_core/lib/sct_core/update_checker/update_checker.rb
195
230
  - shell/README.md
196
231
  - shell/lib/shell.rb
197
232
  - shell/lib/shell/ClassLevelInheritableAttributes.rb