sct 0.1.7 → 0.1.8

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: 7da46c8483060b85fda39a7ee5a274be457f7f8a08aeddaa62d508e38f8aff92
4
- data.tar.gz: 7185c99600e9fb1e382c4d70915e133e07d2a3bf9bbfa9302705a0e0f57b03d9
3
+ metadata.gz: f8ab8255d7a935a7d17cdd0899db8148030bd63f9e3e924449478ec318a6e098
4
+ data.tar.gz: 23f6cc5663676295d56c3df144dbc41612691fd1d020d3dbaec05c23b090ec9c
5
5
  SHA512:
6
- metadata.gz: 4ee29b0cf5bbb7d1aa1f0b588783846709b56529b39663a7c864819de4a0e54e280a55f1f41ef6437ecc947ed99599ad9fc4358d1daa7e54f705a9274e295818
7
- data.tar.gz: 75c5939844adba62b837ed12ac8abe949b4f17a412d750eb1f28f12ba1b951ce6efaffbdcb26232e1ba47625e6a7309e74f612ba492f04d6a0bd86abc0374aeb
6
+ metadata.gz: f750b739e23e6559260ee3f3c04a0a506e190493c61a30ecbff5e00f57c3e54bd0db3efad57a0a97cafb00aa01dcdbe1936b6b6c7b1116cc8a58032fcb1cd036
7
+ data.tar.gz: b6c30e4e6dac2bd145adbe068cf08daeddc72046a350f02e96e3615ddf4f11af24c9c870a9762f9a696d69e326aab1b5b282e191eed1c120cda3bb773aaf42be
data/.DS_Store CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/lib/.DS_Store CHANGED
File without changes
data/lib/sct/.DS_Store CHANGED
File without changes
File without changes
data/lib/sct/command.rb CHANGED
File without changes
File without changes
File without changes
@@ -5,35 +5,43 @@ module Sct
5
5
  class ClusterCommand
6
6
 
7
7
  IS_PUBLIC_COMMAND = true
8
- SYNTAX = 'sct cluster up | sct cluster down'
9
- SUMMARY = 'Starts or stops the minikube cluster'
10
- EXAMPLE = 'sct cluster up | sct cluster down'
11
- EXAMPLE_DESCRIPTION = 'Starts or stops the spend cloud cluster'
12
- DESCRIPTION = "Sct cluster allows you to start and stop the Spend Cloud minikube cluster"
8
+ SYNTAX = 'sct cluster up | sct cluster down | sct cluster update-config'
9
+ SUMMARY = 'Starts/stops or updates the config of the minikube cluster'
10
+ EXAMPLE = 'sct cluster up | sct cluster down | sct cluster update-config'
11
+ EXAMPLE_DESCRIPTION = 'Starts/stops or updates the config of the minikube cluster'
12
+ DESCRIPTION = "Sct cluster allows you to start, stop or update the config of the Spend Cloud minikube cluster"
13
13
 
14
14
  OPTIONS = []
15
15
 
16
16
  def execute(args, options)
17
17
  return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
18
18
 
19
- if `uname -a`.match?("Microsoft")
20
- minikube = "minikube.exe"
21
- else
22
- minikube = "minikube"
23
- end
24
-
25
19
  case args[0]
26
20
  when "up"
27
- system("#{minikube} start")
28
- system("#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
29
- system("kubectl config use-context minikube")
30
- system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')")
31
- system("sudo sct hostfile")
32
- puts "\n✔️ You can now visit your environment at 👉 https://spend-cloud.spend.cloud.local 👌"
21
+ system("minikube start")
22
+ system("minikube ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
23
+ system("sct cluster update-config")
24
+ system("kubectl config use-context minikube")
25
+ system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')")
26
+ system("sudo sct hostfile")
27
+ puts "\n✔️ You can now visit your environment at 👉 https://spend-cloud.spend.cloud.local 👌"
33
28
  when "down"
34
- system("#{minikube} stop")
29
+ system("minikube stop")
30
+ when "update-config"
31
+ return puts "Skipping minikube config ( only needed for windows )".yellow unless Sct::Config.operatingSystem == Sct::Config::WINDOWS
32
+
33
+ windows_home_path = Sct::Config.getTrueHomePath
34
+ kube_file_path = windows_home_path+"/.kube/config"
35
+
36
+ if !File.exists?(kube_file_path)
37
+ return puts "#{kube_file_path} doesn't exist".red
38
+ end
39
+
40
+ system("sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config")
41
+
42
+ return puts "Windows minikube config copied to ~/.kube/minikube-config".green
35
43
  else
36
- puts "Unknown or missing argument. Please run 'sct cluster up' or 'sct cluster down'"
44
+ puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red
37
45
  end
38
46
  end
39
47
 
data/lib/sct/config.rb CHANGED
@@ -8,7 +8,7 @@ module Sct
8
8
  def self.dir
9
9
  user = ENV["SUDO_USER"] || ENV["USER"]
10
10
 
11
- if `uname -a`.match?("Darwin")
11
+ if self.operatingSystem == MAC_OS
12
12
  home = "/Users"
13
13
  else
14
14
  home = "/home"
@@ -59,5 +59,33 @@ module Sct
59
59
 
60
60
  return os
61
61
  end
62
+
63
+ ###
64
+ # Get the actual home path of the user. This may be different depending on the operating system
65
+ ###
66
+ def self.getTrueHomePath
67
+ home_path = `echo ~`
68
+ if self.operatingSystem == WINDOWS
69
+ home_path = self.convertWindowsToWSLPath(`cmd.exe /c echo %userprofile%`)
70
+ end
71
+
72
+ return home_path
73
+ end
74
+
75
+ def self.convertWindowsToWSLPath(path)
76
+ if self.operatingSystem == WINDOWS
77
+ return path.gsub(/C:\\/, '/mnt/c/').gsub(/\\\\/, "/").gsub(/\\/, '/').gsub(/\r\n?/, '')
78
+ end
79
+
80
+ return path
81
+ end
82
+
83
+ def self.convertWSLToWindowsPath(path)
84
+ if self.operatingSystem == WINDOWS
85
+ return path.gsub(/\/mnt\/c/, 'C:/').gsub(/\/\//, '/').gsub(/\\\\/, "/").gsub(/\r\n?/, '')
86
+ end
87
+
88
+ return path
89
+ end
62
90
  end
63
91
  end
@@ -7,7 +7,7 @@ module Sct
7
7
  def self.config
8
8
  self.setImage("eu.gcr.io/dev-pasc-vcdm/helpers-composer:latest", true)
9
9
  self.setPwdAsVolume("/app")
10
- self.addVolume(self.convertPath(self.getTrueHomePath()+"/.composer") , "/tmp")
10
+ self.addVolume(Sct::Config.convertWSLToWindowsPath(Sct::Config.getTrueHomePath()+"/.composer") , "/tmp")
11
11
  self.setCurrentUserAndGroup()
12
12
  self.setEntrypoint("composer")
13
13
  end
@@ -61,7 +61,7 @@ module Sct
61
61
  pwd = `pwd -P`
62
62
 
63
63
  if Sct::Config.operatingSystem == Sct::Config::WINDOWS
64
- pwd=self.convertPath(pwd)
64
+ pwd=Sct::Config.convertWSLToWindowsPath(pwd)
65
65
  end
66
66
 
67
67
  addVolume(pwd, volume_path)
@@ -198,28 +198,5 @@ module Sct
198
198
  def self.addToCommandString(command_string, append)
199
199
  return command_string + append.gsub(/\r?\n/, "") + " "
200
200
  end
201
-
202
- ###
203
- # Get the actual home path of the user. This may be different depending on the operating system
204
- ###
205
- def self.getTrueHomePath
206
- home_path = `echo ~`
207
- if Sct::Config.operatingSystem == Sct::Config::WINDOWS
208
- home_path = self.convertPath(`cmd.exe /c echo %userprofile%`, false)
209
- end
210
-
211
- return home_path
212
- end
213
-
214
- ###
215
- # Convert the unix paths to Windows paths for Windows systems
216
- ###
217
- def self.convertPath(path, to_native=true)
218
- if Sct::Config.operatingSystem == Sct::Config::WINDOWS && to_native
219
- return path.gsub(/\/mnt\/c/, 'C:/').gsub(/\/\//, '/').gsub(/\\\\/, "/").gsub(/\r\n?/, '')
220
- else
221
- return path.gsub(/C:\\/, '/mnt/c').gsub(/\\\\/, "/").gsub(/\\/, '/').gsub(/\r\n?/, '')
222
- end
223
- end
224
201
  end
225
202
  end
File without changes
@@ -7,7 +7,7 @@ module Sct
7
7
  def self.config
8
8
  self.setImage("eu.gcr.io/dev-pasc-vcdm/helpers-yarn:latest", true)
9
9
  self.setPwdAsVolume("/app")
10
- self.addVolume(self.convertPath(self.getTrueHomePath()+"/.cache") , "/.cache")
10
+ self.addVolume(Sct::Config.convertWSLToWindowsPath(Sct::Config.getTrueHomePath()+"/.cache") , "/.cache")
11
11
  self.mapPort(8081, 8080)
12
12
  self.mapPort(9001)
13
13
  self.setCurrentUserAndGroup()
File without changes
data/lib/sct/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sct
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/sct.gemspec CHANGED
File without changes
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.7
4
+ version: 0.1.8
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-01-31 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: class_interface
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.0.6
191
+ rubygems_version: 3.1.2
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Spend Cloud Tool.