sct 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/sct/.DS_Store +0 -0
- data/lib/sct/ClassLevelInheritableAttributes.rb +0 -0
- data/lib/sct/command.rb +0 -0
- data/lib/sct/command_interface.rb +0 -0
- data/lib/sct/command_option.rb +0 -0
- data/lib/sct/commands/cluster.rb +17 -13
- data/lib/sct/commands/hostfile.rb +22 -23
- data/lib/sct/commands/init.rb +0 -6
- data/lib/sct/config.rb +1 -56
- data/lib/sct/docker/composer.rb +1 -1
- data/lib/sct/docker/docker.rb +3 -3
- data/lib/sct/docker/php.rb +0 -0
- data/lib/sct/docker/yarn.rb +1 -1
- data/lib/sct/setup/helpers.rb +77 -9
- data/lib/sct/version.rb +1 -1
- data/sct.gemspec +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4a9c05109327130b6c1b08f44e0658be4db63e1c8402118ee9b7c7a14463cf
|
4
|
+
data.tar.gz: 88e20c8c3e6ff0fac970955b03ae2d95010544cd158c733507cba312b5507499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b153495574021b51ee936580da13b4a177a22e0e8c5ad8e74be877e21cbb65be0570bfa24945941599807f1658786ffbe7d8d68002cb7759e8ce07f6cb3628b7
|
7
|
+
data.tar.gz: 3b2dba1bd88a72519a8043fae447568b9d8927e6c5e26ce40ba45c35275927ea18949371e88011f195af2dae2986df83d0110c2aa39a43dcadc45e6395bbbbef
|
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
|
data/lib/sct/command_option.rb
CHANGED
File without changes
|
data/lib/sct/commands/cluster.rb
CHANGED
@@ -16,7 +16,7 @@ module Sct
|
|
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 Sct::
|
19
|
+
if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
20
20
|
minikube = "minikube.exe"
|
21
21
|
else
|
22
22
|
minikube = "minikube"
|
@@ -26,7 +26,7 @@ module Sct
|
|
26
26
|
when "up"
|
27
27
|
system("#{minikube} start")
|
28
28
|
system("#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'")
|
29
|
-
|
29
|
+
update_config
|
30
30
|
system("kubectl config use-context minikube")
|
31
31
|
system("kubectl delete pod -n kube-system $(kubectl get pods -n kube-system | grep registry-creds | awk '{print $1}')")
|
32
32
|
system("sudo sct hostfile")
|
@@ -34,21 +34,25 @@ module Sct
|
|
34
34
|
when "down"
|
35
35
|
system("#{minikube} stop")
|
36
36
|
when "update-config"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
update_config
|
38
|
+
else
|
39
|
+
puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red
|
40
|
+
end
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
43
|
+
def update_config
|
44
|
+
return puts "Skipping minikube config (only needed for Windows)".yellow unless Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
45
45
|
|
46
|
-
|
46
|
+
windows_home_path = Sct::Helpers.windowsHomePath
|
47
|
+
kube_file_path = windows_home_path+"/.kube/config"
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
puts "Unknown or missing argument. Please run 'sct cluster up','sct cluster down' or 'sct cluster update-config'".red
|
49
|
+
if !File.exists?(kube_file_path)
|
50
|
+
return puts "#{kube_file_path} doesn't exist".red
|
51
51
|
end
|
52
|
+
|
53
|
+
system("sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config")
|
54
|
+
|
55
|
+
return puts "Windows minikube config copied to ~/.kube/minikube-config".green
|
52
56
|
end
|
53
57
|
|
54
58
|
implements CommandInterface
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'hosts'
|
1
2
|
require 'sct/command_interface'
|
2
3
|
|
3
4
|
module Sct
|
@@ -16,34 +17,36 @@ module Sct
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def execute(args, options)
|
19
|
-
|
20
20
|
return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
|
21
21
|
|
22
|
-
|
22
|
+
return puts "This command needs to be run with sudo.".red unless Sct::Helpers.isSudo
|
23
23
|
|
24
|
-
return unless
|
24
|
+
return unless Sct::Helpers.ingressAddress
|
25
25
|
|
26
|
-
|
27
|
-
host_path = Sct::Config.get("host-path")
|
26
|
+
ingressAddress = Sct::Helpers.ingressAddress
|
28
27
|
|
29
|
-
if
|
30
|
-
|
31
|
-
elsif host_path
|
32
|
-
hosts = Hosts::File.read(host_path)
|
28
|
+
if options.path
|
29
|
+
hosts_paths = [options.path]
|
33
30
|
else
|
34
|
-
|
35
|
-
hosts = Hosts::File.read('/etc/hosts')
|
36
|
-
end
|
31
|
+
hosts_paths = ["/etc/hosts"]
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
validate_if_exist(hosts)
|
42
|
-
add_entry(url, hosts)
|
43
|
-
hosts.write
|
44
|
-
puts "patched: #{url}".green
|
33
|
+
if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
34
|
+
hosts_paths << "/mnt/c/Windows/System32/drivers/etc/hosts"
|
35
|
+
end
|
45
36
|
end
|
46
37
|
|
38
|
+
hosts_paths.each do |hosts_path|
|
39
|
+
hosts = Hosts::File.read(hosts_path)
|
40
|
+
|
41
|
+
if ([ingressAddress].any? { |ip| hosts.to_s =~ /#{ip}/ })
|
42
|
+
puts "Skipped patching #{hosts_path} (already up to date)".green
|
43
|
+
else
|
44
|
+
validate_if_exist(hosts)
|
45
|
+
add_entry(ingressAddress, hosts)
|
46
|
+
hosts.write
|
47
|
+
puts "Patched #{hosts_path} with #{ingressAddress}".green
|
48
|
+
end
|
49
|
+
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def add_entry(url, hosts)
|
@@ -100,10 +103,6 @@ module Sct
|
|
100
103
|
|
101
104
|
end
|
102
105
|
|
103
|
-
def ingressUrl
|
104
|
-
return Sct::Helpers.ingressUrl
|
105
|
-
end
|
106
|
-
|
107
106
|
implements CommandInterface
|
108
107
|
|
109
108
|
end
|
data/lib/sct/commands/init.rb
CHANGED
@@ -31,15 +31,9 @@ module Sct
|
|
31
31
|
q.default = "~/.config/gcloud/application_default_credentials.json"
|
32
32
|
}
|
33
33
|
|
34
|
-
host_path = "/etc/hosts"
|
35
|
-
if Sct::Config.operatingSystem == Sct::Config::WINDOWS
|
36
|
-
host_path = "/mnt/c/Windows/System32/drivers/etc/hosts"
|
37
|
-
end
|
38
|
-
|
39
34
|
contents = ""
|
40
35
|
contents << "email=#{email}\n"
|
41
36
|
contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n"
|
42
|
-
contents << "host-path=#{File.expand_path(host_path)}\n"
|
43
37
|
|
44
38
|
if !File.directory?(Sct::Config.dir)
|
45
39
|
FileUtils.mkdir_p(Sct::Config.dir)
|
data/lib/sct/config.rb
CHANGED
@@ -1,20 +1,8 @@
|
|
1
1
|
module Sct
|
2
2
|
class Config
|
3
3
|
|
4
|
-
WINDOWS = "Windows"
|
5
|
-
MAC_OS = "MacOS"
|
6
|
-
UBUNTU = "Ubuntu"
|
7
|
-
|
8
4
|
def self.dir
|
9
|
-
|
10
|
-
|
11
|
-
if self.operatingSystem == MAC_OS
|
12
|
-
home = "/Users"
|
13
|
-
else
|
14
|
-
home = "/home"
|
15
|
-
end
|
16
|
-
|
17
|
-
return "#{home}/#{user}/.config/sct"
|
5
|
+
return "#{Sct::Helpers.homePath}/.config/sct"
|
18
6
|
end
|
19
7
|
|
20
8
|
def self.path
|
@@ -44,48 +32,5 @@ module Sct
|
|
44
32
|
|
45
33
|
return Sct::Helpers.to_hash(contents)
|
46
34
|
end
|
47
|
-
|
48
|
-
def self.operatingSystem
|
49
|
-
proc = `uname -a`
|
50
|
-
|
51
|
-
case proc
|
52
|
-
when /Microsoft/
|
53
|
-
os = WINDOWS
|
54
|
-
when /Darwin/
|
55
|
-
os = MAC_OS
|
56
|
-
else
|
57
|
-
os = UBUNTU
|
58
|
-
end
|
59
|
-
|
60
|
-
return os
|
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
|
90
35
|
end
|
91
36
|
end
|
data/lib/sct/docker/composer.rb
CHANGED
@@ -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(Sct::
|
10
|
+
self.addVolume(Sct::Helpers.convertWSLToWindowsPath("#{Sct::Helpers.windowsHomePath || Sct::Helpers.homePath}/.composer") , "/tmp")
|
11
11
|
self.setCurrentUserAndGroup()
|
12
12
|
self.setEntrypoint("composer")
|
13
13
|
end
|
data/lib/sct/docker/docker.rb
CHANGED
@@ -60,8 +60,8 @@ module Sct
|
|
60
60
|
def self.setPwdAsVolume(volume_path)
|
61
61
|
pwd = `pwd -P`
|
62
62
|
|
63
|
-
if Sct::
|
64
|
-
pwd=Sct::
|
63
|
+
if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
64
|
+
pwd=Sct::Helpers.convertWSLToWindowsPath(pwd)
|
65
65
|
end
|
66
66
|
|
67
67
|
addVolume(pwd, volume_path)
|
@@ -131,7 +131,7 @@ module Sct
|
|
131
131
|
# Login to the private container registry with the cloud credentials
|
132
132
|
###
|
133
133
|
def self.loginToPrivateRegistry
|
134
|
-
`docker login -u oauth2accesstoken -p "$(gcloud auth application-default print-access-token)" https://eu.gcr.io &>
|
134
|
+
`docker login -u oauth2accesstoken -p "$(gcloud auth application-default print-access-token)" https://eu.gcr.io &> /dev/null`
|
135
135
|
return $?.success?
|
136
136
|
end
|
137
137
|
|
data/lib/sct/docker/php.rb
CHANGED
File without changes
|
data/lib/sct/docker/yarn.rb
CHANGED
@@ -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(Sct::
|
10
|
+
self.addVolume(Sct::Helpers.convertWSLToWindowsPath("#{Sct::Helpers.windowsHomePath || Sct::Helpers.homePath}/.cache") , "/.cache")
|
11
11
|
self.mapPort(8081, 8080)
|
12
12
|
self.mapPort(9001)
|
13
13
|
self.setCurrentUserAndGroup()
|
data/lib/sct/setup/helpers.rb
CHANGED
@@ -1,16 +1,29 @@
|
|
1
1
|
module Sct
|
2
2
|
class Helpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
WINDOWS = "Windows"
|
5
|
+
MAC_OS = "MacOS"
|
6
|
+
UBUNTU = "Ubuntu"
|
7
|
+
|
8
|
+
def self.ingressAddress
|
9
|
+
if self.operatingSystem == WINDOWS
|
10
|
+
kubeconfig_file = "minikube-config"
|
11
|
+
else
|
12
|
+
kubeconfig_file = "config"
|
13
|
+
end
|
14
|
+
|
15
|
+
kubeconfig_path= "#{self.homePath}/.kube/#{kubeconfig_file}"
|
16
|
+
|
17
|
+
ip = `KUBECONFIG="#{kubeconfig_path}" kubectl get ingress`
|
18
|
+
|
19
|
+
if ip.nil? || ip.empty?
|
20
|
+
puts "Can't fetch IP from kubectl".yellow
|
9
21
|
return nil
|
10
22
|
end
|
11
|
-
|
12
|
-
match = ip.scan(/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})/)
|
13
|
-
|
23
|
+
|
24
|
+
match = ip.scan(/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})/)
|
25
|
+
|
26
|
+
return match.first.first
|
14
27
|
end
|
15
28
|
|
16
29
|
def self.to_hash(str)
|
@@ -18,5 +31,60 @@ module Sct
|
|
18
31
|
str.split("\n").map{|i|i.split('=')}
|
19
32
|
]
|
20
33
|
end
|
34
|
+
|
35
|
+
def self.operatingSystem
|
36
|
+
proc = `uname -a`
|
37
|
+
|
38
|
+
case proc
|
39
|
+
when /Microsoft/
|
40
|
+
os = WINDOWS
|
41
|
+
when /Darwin/
|
42
|
+
os = MAC_OS
|
43
|
+
else
|
44
|
+
os = UBUNTU
|
45
|
+
end
|
46
|
+
|
47
|
+
return os
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.homePath
|
51
|
+
user = ENV["SUDO_USER"] || ENV["USER"]
|
52
|
+
|
53
|
+
if self.operatingSystem == MAC_OS
|
54
|
+
home = "/Users"
|
55
|
+
else
|
56
|
+
home = "/home"
|
57
|
+
end
|
58
|
+
|
59
|
+
return "#{home}/#{user}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.windowsHomePath
|
63
|
+
if self.operatingSystem == WINDOWS
|
64
|
+
return self.convertWindowsToWSLPath(`cmd.exe /c echo %userprofile%`)
|
65
|
+
end
|
66
|
+
|
67
|
+
return nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.convertWindowsToWSLPath(path)
|
71
|
+
if self.operatingSystem == WINDOWS
|
72
|
+
return path.gsub(/C:\\/, '/mnt/c/').gsub(/\\\\/, "/").gsub(/\\/, '/').gsub(/\r\n?/, '')
|
73
|
+
end
|
74
|
+
|
75
|
+
return path
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.convertWSLToWindowsPath(path)
|
79
|
+
if self.operatingSystem == WINDOWS
|
80
|
+
return path.gsub(/\/mnt\/c/, 'C:/').gsub(/\/\//, '/').gsub(/\\\\/, "/").gsub(/\r\n?/, '')
|
81
|
+
end
|
82
|
+
|
83
|
+
return path
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.isSudo
|
87
|
+
return !ENV["SUDO_USER"].nil? && !ENV["SUDO_USER"].empty?
|
88
|
+
end
|
21
89
|
end
|
22
|
-
end
|
90
|
+
end
|
data/lib/sct/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.12
|
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-02-
|
11
|
+
date: 2020-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_interface
|