sct 0.1.20 → 0.1.25
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 +4 -4
- data/cluster/lib/cluster/commands_generator.rb +15 -1
- data/cluster/lib/cluster/runner.rb +59 -32
- data/sct/lib/sct/cli_tools_distributor.rb +4 -0
- data/sct/lib/sct/commands/hostfile.rb +4 -0
- data/sct/lib/sct/version.rb +1 -1
- data/sct_core/lib/sct_core.rb +1 -0
- data/sct_core/lib/sct_core/helper.rb +11 -3
- data/sct_core/lib/sct_core/update_checker/update_checker.rb +76 -0
- data/shell/lib/shell/docker/composer.rb +5 -5
- data/shell/lib/shell/docker/docker.rb +48 -29
- data/shell/lib/shell/docker/php.rb +45 -8
- data/shell/lib/shell/docker/yarn.rb +6 -6
- metadata +39 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0014f7b902a222679cab47e9a2595a52c6c037e7bb3c47c0ae03e3b69c9f8d7
|
4
|
+
data.tar.gz: 37cff1b39148c84cd7d4e626e5d55744017c2a1406183b0915fd0bf8013730dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 419ab66f62d5a1cd697b8a1ddd3a26a1bda26778d6be199b1424ac72d6c8a33854657a5ab2f80838ea25e3f456f0a33e81c5cf6b7418aa22e7869898a2ac72be
|
7
|
+
data.tar.gz: 9487da0833e8c581c5c036ecd270794a40f62eee44c80520ddbe89c19b9bd80098a02bb60c94f47f0f08acc2823a25a9d0b13b469e2511af2bb68f3424e2dac3
|
@@ -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
|
-
|
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
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cluster
|
2
2
|
class Runner
|
3
|
-
|
4
|
-
def launch
|
3
|
+
|
4
|
+
def launch
|
5
5
|
return UI.error("SCT has not been initialized. Run 'sct init' first.") unless SctCore::Config.exists
|
6
6
|
start_cluster
|
7
7
|
run_command "kubectl delete pod -n kube-system #{pods("kube-system").map { |pod| pod[:name] if pod[:name].start_with? "registry-creds" } .compact.join(" ")}"
|
@@ -11,11 +11,11 @@ module Cluster
|
|
11
11
|
|
12
12
|
def start_cluster
|
13
13
|
if SctCore::Helper.operatingSystem == SctCore::Helper::MAC_OS
|
14
|
-
run_command "#{minikube} start --cpus=$(sysctl -n hw.ncpu) --memory=8G"
|
14
|
+
run_command "#{SctCore::Helper.minikube} start --cpus=$(sysctl -n hw.ncpu) --memory=8G"
|
15
15
|
else
|
16
|
-
run_command "#{minikube} start --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=10G"
|
16
|
+
run_command "#{SctCore::Helper.minikube} start --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=10G"
|
17
17
|
end
|
18
|
-
run_command "#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'"
|
18
|
+
run_command "#{SctCore::Helper.minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'"
|
19
19
|
update_config
|
20
20
|
end
|
21
21
|
|
@@ -26,17 +26,14 @@ module Cluster
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def down
|
29
|
-
run_command "#{minikube} stop"
|
29
|
+
run_command "#{SctCore::Helper.minikube} stop"
|
30
30
|
end
|
31
31
|
|
32
32
|
def reset
|
33
|
-
run_command "#{minikube} delete"
|
33
|
+
run_command "#{SctCore::Helper.minikube} delete"
|
34
34
|
start_cluster
|
35
35
|
create_secrets
|
36
|
-
|
37
|
-
run_command "#{minikube} addons enable ingress"
|
38
|
-
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
39
|
-
run_command "kubectl rollout status -n kube-system deployment/nginx-ingress-controller"
|
36
|
+
enable_addons
|
40
37
|
wait_for_gcr_secret
|
41
38
|
run_command "kubectl apply -f ~/development/spend-cloud/k8s/ingress.yml"
|
42
39
|
wait_for_ingress_ip
|
@@ -46,6 +43,19 @@ module Cluster
|
|
46
43
|
post_start
|
47
44
|
end
|
48
45
|
|
46
|
+
def enable_addons
|
47
|
+
enable_addon "registry-creds"
|
48
|
+
enable_addon "ingress"
|
49
|
+
end
|
50
|
+
|
51
|
+
def enable_addon(addon)
|
52
|
+
run_command "#{SctCore::Helper.minikube} addons enable #{addon}"
|
53
|
+
|
54
|
+
deployment = deployments("kube-system").find { |deployment| deployment[:name].include? addon }
|
55
|
+
|
56
|
+
run_command "kubectl rollout status -n kube-system deployment/#{deployment[:name]}"
|
57
|
+
end
|
58
|
+
|
49
59
|
def wait_for_pods
|
50
60
|
UI.important("Waiting for pods to become ready...")
|
51
61
|
|
@@ -71,6 +81,18 @@ module Cluster
|
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
84
|
+
def delete_all_pods
|
85
|
+
run_command "kubectl delete pods --all"
|
86
|
+
end
|
87
|
+
|
88
|
+
def delete_pods(args)
|
89
|
+
run_command "kubectl delete pods #{args.join(" ")}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def apply_pods
|
93
|
+
run_command "kubectl apply -f ~/development/spend-cloud/k8s/"
|
94
|
+
end
|
95
|
+
|
74
96
|
def update_config
|
75
97
|
if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
|
76
98
|
windows_home_path = SctCore::Helper.windowsHomePath
|
@@ -93,12 +115,8 @@ module Cluster
|
|
93
115
|
run_command "kubectl rollout status -n kube-system deployment/coredns"
|
94
116
|
end
|
95
117
|
|
96
|
-
def
|
97
|
-
|
98
|
-
output = `kubectl get pods -n #{namespace}`
|
99
|
-
else
|
100
|
-
output = `kubectl get pods`
|
101
|
-
end
|
118
|
+
def deployments(namespace = "default")
|
119
|
+
output = `kubectl get deployments -n #{namespace}`
|
102
120
|
|
103
121
|
# split output lines
|
104
122
|
lines = output.split "\n"
|
@@ -106,9 +124,26 @@ module Cluster
|
|
106
124
|
# exclude first line (table header)
|
107
125
|
lines = lines[1..-1]
|
108
126
|
|
109
|
-
|
110
|
-
|
127
|
+
# get name and status of each pod
|
128
|
+
lines.map do |line|
|
129
|
+
columns = line.split(" ")
|
130
|
+
|
131
|
+
name = columns[0]
|
132
|
+
|
133
|
+
{
|
134
|
+
name: name
|
135
|
+
}
|
111
136
|
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def pods(namespace = "default")
|
140
|
+
output = `kubectl get pods -n #{namespace}`
|
141
|
+
|
142
|
+
# split output lines
|
143
|
+
lines = output.split "\n"
|
144
|
+
|
145
|
+
# exclude first line (table header)
|
146
|
+
lines = lines[1..-1]
|
112
147
|
|
113
148
|
# get name and status of each pod
|
114
149
|
lines.map do |line|
|
@@ -193,7 +228,7 @@ module Cluster
|
|
193
228
|
end
|
194
229
|
|
195
230
|
def get_minikube_status
|
196
|
-
output = `#{minikube} status`
|
231
|
+
output = `#{SctCore::Helper.minikube} status`
|
197
232
|
|
198
233
|
lines = output.split "\n"
|
199
234
|
|
@@ -204,12 +239,12 @@ module Cluster
|
|
204
239
|
end
|
205
240
|
end
|
206
241
|
|
207
|
-
def print_pods_status(namespace =
|
242
|
+
def print_pods_status(namespace = "default")
|
208
243
|
|
209
244
|
pods_list = pods(namespace)
|
210
245
|
|
211
246
|
if pods_list.to_a.empty?
|
212
|
-
return
|
247
|
+
return
|
213
248
|
end
|
214
249
|
|
215
250
|
rows = pods_list.map do |pod|
|
@@ -219,7 +254,7 @@ module Cluster
|
|
219
254
|
]
|
220
255
|
end
|
221
256
|
|
222
|
-
puts Terminal::Table.new title: "Pods (namespace: #{namespace
|
257
|
+
puts Terminal::Table.new title: "Pods (namespace: #{namespace})".green, headings: ['Name', 'Status'], rows: rows
|
223
258
|
end
|
224
259
|
|
225
260
|
def run_command command
|
@@ -227,13 +262,5 @@ module Cluster
|
|
227
262
|
raise command.red
|
228
263
|
end
|
229
264
|
end
|
230
|
-
|
231
|
-
def minikube
|
232
|
-
if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
|
233
|
-
return "minikube.exe"
|
234
|
-
else
|
235
|
-
return "minikube"
|
236
|
-
end
|
237
|
-
end
|
238
265
|
end
|
239
|
-
end
|
266
|
+
end
|
data/sct/lib/sct/version.rb
CHANGED
data/sct_core/lib/sct_core.rb
CHANGED
@@ -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'
|
@@ -35,10 +35,10 @@ module SctCore
|
|
35
35
|
def self.operatingSystem
|
36
36
|
proc = `uname -a`
|
37
37
|
|
38
|
-
case proc
|
39
|
-
when /
|
38
|
+
case proc.downcase
|
39
|
+
when /microsoft/
|
40
40
|
os = WINDOWS
|
41
|
-
when /
|
41
|
+
when /darwin/
|
42
42
|
os = MAC_OS
|
43
43
|
else
|
44
44
|
os = UBUNTU
|
@@ -86,5 +86,13 @@ module SctCore
|
|
86
86
|
def self.isSudo
|
87
87
|
return !ENV["SUDO_USER"].nil? && !ENV["SUDO_USER"].empty?
|
88
88
|
end
|
89
|
+
|
90
|
+
def self.minikube
|
91
|
+
if self.operatingSystem == WINDOWS
|
92
|
+
return "minikube.exe"
|
93
|
+
else
|
94
|
+
return "minikube"
|
95
|
+
end
|
96
|
+
end
|
89
97
|
end
|
90
98
|
end
|
@@ -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
|
@@ -6,11 +6,11 @@ module Shell
|
|
6
6
|
|
7
7
|
# Configure the Yarn command
|
8
8
|
def self.config
|
9
|
-
self.
|
10
|
-
self.
|
11
|
-
self.
|
12
|
-
self.
|
13
|
-
self.
|
9
|
+
self.set_image("eu.gcr.io/dev-pasc-vcdm/helpers-composer:latest", true)
|
10
|
+
self.set_pwd_as_volume("/app")
|
11
|
+
self.add_volume(SctCore::Helper.convertWSLToWindowsPath("#{SctCore::Helper.windowsHomePath || SctCore::Helper.homePath}/.composer") , "/tmp")
|
12
|
+
self.set_current_user_and_group()
|
13
|
+
self.set_entrypoint("composer")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -4,7 +4,7 @@ require "shell/ClassLevelInheritableAttributes"
|
|
4
4
|
module Shell
|
5
5
|
class Docker
|
6
6
|
include ClassLevelInheritableAttributes
|
7
|
-
inheritable_attributes :image, :is_private_registry, :entrypoint, :volumes, :ports, :extra_arguments
|
7
|
+
inheritable_attributes :image, :is_private_registry, :entrypoint, :volumes, :ports, :extra_arguments, :env_variables
|
8
8
|
|
9
9
|
@image = nil
|
10
10
|
@is_private_registry = false
|
@@ -14,6 +14,7 @@ module Shell
|
|
14
14
|
@ports = {}
|
15
15
|
@user_group = []
|
16
16
|
@extra_arguments = {}
|
17
|
+
@env_variables = {}
|
17
18
|
|
18
19
|
###
|
19
20
|
# The Docker command configuration. This has to be able to execute the command properly
|
@@ -27,28 +28,28 @@ module Shell
|
|
27
28
|
###
|
28
29
|
def self.exec(cli_arguments)
|
29
30
|
|
30
|
-
self.
|
31
|
+
self.add_extra_argument(cli_arguments)
|
31
32
|
|
32
|
-
self.config
|
33
|
+
self.config
|
33
34
|
|
34
35
|
# Check if the basic variables are set
|
35
36
|
if !@image || @image.empty?
|
36
37
|
raise LoadError, "The required image is not defined for this command"
|
37
38
|
end
|
38
39
|
|
39
|
-
if !self.
|
40
|
-
|
40
|
+
if !self.check_for_image && @is_private_registry
|
41
|
+
unless self.login_to_private_registry
|
41
42
|
raise RuntimeError, "Could not authenticate to GCR (" + $?.exitstatus + ")"
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
self.
|
46
|
+
self.run_command
|
46
47
|
end
|
47
48
|
|
48
49
|
###
|
49
50
|
# The image for this Docker command
|
50
51
|
###
|
51
|
-
def self.
|
52
|
+
def self.set_image(image, is_private_registry=false)
|
52
53
|
@image = image
|
53
54
|
@is_private_registry = is_private_registry
|
54
55
|
end
|
@@ -56,27 +57,27 @@ module Shell
|
|
56
57
|
###
|
57
58
|
# Set the current PWD as a volume on the specified path in the container
|
58
59
|
###
|
59
|
-
def self.
|
60
|
+
def self.set_pwd_as_volume(volume_path)
|
60
61
|
pwd = `pwd -P`
|
61
62
|
|
62
63
|
if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
|
63
64
|
pwd=SctCore::Helper.convertWSLToWindowsPath(pwd)
|
64
65
|
end
|
65
66
|
|
66
|
-
|
67
|
+
add_volume(pwd, volume_path)
|
67
68
|
end
|
68
69
|
|
69
70
|
###
|
70
71
|
# Add an extra volume in the container
|
71
72
|
###
|
72
|
-
def self.
|
73
|
-
@volumes[
|
73
|
+
def self.add_volume(local_path, volume_path)
|
74
|
+
@volumes[local_path] = volume_path
|
74
75
|
end
|
75
76
|
|
76
77
|
###
|
77
78
|
# Add a port mapping for the container
|
78
79
|
###
|
79
|
-
def self.
|
80
|
+
def self.map_port(external_port, container_port = nil)
|
80
81
|
|
81
82
|
external_port=String(external_port)
|
82
83
|
container_port=String(container_port)
|
@@ -91,7 +92,7 @@ module Shell
|
|
91
92
|
###
|
92
93
|
# Set the current user and group in the container
|
93
94
|
###
|
94
|
-
def self.
|
95
|
+
def self.set_current_user_and_group
|
95
96
|
@user_group = []
|
96
97
|
@user_group << `id -u`
|
97
98
|
@user_group << `id -g`
|
@@ -100,14 +101,14 @@ module Shell
|
|
100
101
|
###
|
101
102
|
# Set the entrypoint for the command in the container
|
102
103
|
###
|
103
|
-
def self.
|
104
|
+
def self.set_entrypoint(entrypoint)
|
104
105
|
@entrypoint=entrypoint
|
105
106
|
end
|
106
107
|
|
107
108
|
###
|
108
109
|
# Add extra arguments to be configured for the container
|
109
110
|
###
|
110
|
-
def self.
|
111
|
+
def self.add_extra_argument(argument, value=nil)
|
111
112
|
argument = String(argument)
|
112
113
|
|
113
114
|
if value
|
@@ -117,10 +118,17 @@ module Shell
|
|
117
118
|
self.extra_arguments[argument] = value
|
118
119
|
end
|
119
120
|
|
121
|
+
###
|
122
|
+
# Set environment variables for the container
|
123
|
+
###
|
124
|
+
def self.set_environment_variables(env_variables)
|
125
|
+
@env_variables = env_variables
|
126
|
+
end
|
127
|
+
|
120
128
|
###
|
121
129
|
# Check if the image is already present in the system
|
122
130
|
###
|
123
|
-
def self.
|
131
|
+
def self.check_for_image
|
124
132
|
image_list=`docker images -q #{@image} 2> /dev/null`
|
125
133
|
|
126
134
|
return image_list && !image_list.empty?
|
@@ -129,7 +137,7 @@ module Shell
|
|
129
137
|
###
|
130
138
|
# Login to the private container registry with the cloud credentials
|
131
139
|
###
|
132
|
-
def self.
|
140
|
+
def self.login_to_private_registry
|
133
141
|
`docker login -u oauth2accesstoken -p "$(gcloud auth application-default print-access-token)" https://eu.gcr.io &> /dev/null`
|
134
142
|
return $?.success?
|
135
143
|
end
|
@@ -137,8 +145,8 @@ module Shell
|
|
137
145
|
###
|
138
146
|
# Run the command
|
139
147
|
###
|
140
|
-
def self.
|
141
|
-
command = self.
|
148
|
+
def self.run_command
|
149
|
+
command = self.compile_command
|
142
150
|
|
143
151
|
SctCore::CommandExecutor.execute(command: command, print_all: true, suppress_output: false)
|
144
152
|
end
|
@@ -146,42 +154,53 @@ module Shell
|
|
146
154
|
###
|
147
155
|
# Compile the command with all options
|
148
156
|
###
|
149
|
-
def self.
|
157
|
+
def self.compile_command
|
150
158
|
# Basic docker run command
|
151
|
-
command = self.
|
159
|
+
command = self.add_to_command_string("" , "docker run --rm -it")
|
160
|
+
|
161
|
+
# Attach environment variables
|
162
|
+
if @env_variables
|
163
|
+
@env_variables.each do |key, value|
|
164
|
+
if value && !value.empty?
|
165
|
+
command = self.add_to_command_string(command, "-e " + key+"="+value)
|
166
|
+
else
|
167
|
+
command = self.add_to_command_string("-e " + key, value)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
152
171
|
|
153
172
|
# Attach configured volumes
|
154
173
|
if @volumes
|
155
174
|
@volumes.each do |local_path, container_path|
|
156
|
-
command = self.
|
175
|
+
command = self.add_to_command_string(command, "--volume " + local_path +":"+ container_path)
|
157
176
|
end
|
158
177
|
end
|
159
178
|
|
160
179
|
# Map configured ports
|
161
180
|
if @ports
|
162
181
|
@ports.each do |external_port, container_port|
|
163
|
-
command = self.
|
182
|
+
command = self.add_to_command_string(command, "-p " + external_port +":"+ container_port)
|
164
183
|
end
|
165
184
|
end
|
166
185
|
|
167
186
|
if @user_group
|
168
|
-
command = self.
|
187
|
+
command = self.add_to_command_string(command, "--user "+ String(@user_group.shift) +":"+ String(@user_group.shift))
|
169
188
|
end
|
170
189
|
|
171
190
|
# Add image to command
|
172
|
-
command = self.
|
191
|
+
command = self.add_to_command_string(command, @image)
|
173
192
|
|
174
193
|
if @entrypoint
|
175
|
-
command = self.
|
194
|
+
command = self.add_to_command_string(command, String(@entrypoint))
|
176
195
|
end
|
177
196
|
|
178
197
|
# Append arguments and options to command
|
179
198
|
if @extra_arguments
|
180
199
|
@extra_arguments.each do |argument, value|
|
181
200
|
if value && !value.empty?
|
182
|
-
command = self.
|
201
|
+
command = self.add_to_command_string(command, argument+"="+value)
|
183
202
|
else
|
184
|
-
command = self.
|
203
|
+
command = self.add_to_command_string(command, argument)
|
185
204
|
end
|
186
205
|
end
|
187
206
|
end
|
@@ -192,7 +211,7 @@ module Shell
|
|
192
211
|
###
|
193
212
|
# Append a part to the command string and remove any unwanted characters
|
194
213
|
###
|
195
|
-
def self.
|
214
|
+
def self.add_to_command_string(command_string, append)
|
196
215
|
return command_string + append.gsub(/\r?\n/, "") + " "
|
197
216
|
end
|
198
217
|
end
|
@@ -1,15 +1,52 @@
|
|
1
1
|
require "sct_core"
|
2
|
+
|
2
3
|
require_relative "docker"
|
3
4
|
|
4
5
|
module Shell
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
class Php < Docker
|
7
|
+
|
8
|
+
attr_accessor :make
|
9
|
+
|
10
|
+
# Configure the Yarn command
|
11
|
+
def self.config
|
12
|
+
self.set_image("eu.gcr.io/dev-pasc-vcdm/proactive-base:latest", true)
|
13
|
+
self.set_pwd_as_volume("/var/www")
|
14
|
+
self.set_current_user_and_group
|
15
|
+
self.set_entrypoint("php")
|
16
|
+
self.set_environment_variables(get_service_ip_and_port)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get_service_ip_and_port
|
20
|
+
service_names = %w[mysql-service redis-service]
|
21
|
+
environment_variables = {}
|
22
|
+
|
23
|
+
minikube_status
|
24
|
+
|
25
|
+
service_names.each { |service_name|
|
26
|
+
url = `#{SctCore::Helper.minikube} service #{service_name} --url`
|
27
|
+
|
28
|
+
ip_and_port = url.match /(?<ip>[0-9]+(?:\.[0-9]+){3}):(?<port>[0-9]+)/
|
29
|
+
|
30
|
+
case service_name
|
31
|
+
when "mysql-service"
|
32
|
+
environment_variables.store("DB_HOST", ip_and_port[:ip])
|
33
|
+
environment_variables.store("DB_PORT", ip_and_port[:port])
|
34
|
+
when "redis-service"
|
35
|
+
environment_variables.store("REDIS_HOST", ip_and_port[:ip])
|
36
|
+
environment_variables.store("REDIS_PORT", ip_and_port[:port])
|
13
37
|
end
|
38
|
+
}
|
39
|
+
|
40
|
+
return environment_variables
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.minikube_status
|
44
|
+
output = `#{SctCore::Helper.minikube} status`
|
45
|
+
|
46
|
+
if output.scan(/Running/).length != 3 && output.scan(/Configured/).length != 1
|
47
|
+
UI.important("Please check your minikube status. If all services are stopped you should start the minikube first.")
|
48
|
+
exit
|
49
|
+
end
|
14
50
|
end
|
51
|
+
end
|
15
52
|
end
|
@@ -6,12 +6,12 @@ module Shell
|
|
6
6
|
|
7
7
|
# Configure the Yarn command
|
8
8
|
def self.config
|
9
|
-
self.
|
10
|
-
self.
|
11
|
-
self.
|
12
|
-
self.
|
13
|
-
self.
|
14
|
-
self.
|
9
|
+
self.set_image("eu.gcr.io/dev-pasc-vcdm/helpers-yarn:latest", true)
|
10
|
+
self.set_pwd_as_volume("/app")
|
11
|
+
self.add_volume(SctCore::Helper.convertWSLToWindowsPath("#{SctCore::Helper.windowsHomePath || SctCore::Helper.homePath}/.cache") , "/.cache")
|
12
|
+
self.map_port(8081, 8080)
|
13
|
+
self.map_port(9001)
|
14
|
+
self.set_current_user_and_group()
|
15
15
|
end
|
16
16
|
end
|
17
17
|
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.
|
4
|
+
version: 0.1.25
|
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-
|
11
|
+
date: 2020-08-20 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
|
@@ -214,9 +249,9 @@ post_install_message:
|
|
214
249
|
rdoc_options: []
|
215
250
|
require_paths:
|
216
251
|
- cluster/lib
|
217
|
-
- shell/lib
|
218
252
|
- sct/lib
|
219
253
|
- sct_core/lib
|
254
|
+
- shell/lib
|
220
255
|
required_ruby_version: !ruby/object:Gem::Requirement
|
221
256
|
requirements:
|
222
257
|
- - ">="
|
@@ -228,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
263
|
- !ruby/object:Gem::Version
|
229
264
|
version: '0'
|
230
265
|
requirements: []
|
231
|
-
rubygems_version: 3.0.
|
266
|
+
rubygems_version: 3.0.6
|
232
267
|
signing_key:
|
233
268
|
specification_version: 4
|
234
269
|
summary: Spend Cloud Tool.
|