sct 0.1.27 → 0.1.33

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/cluster/lib/.DS_Store +0 -0
  3. data/cluster/lib/cluster.rb +0 -0
  4. data/cluster/lib/cluster/commands_generator.rb +38 -50
  5. data/cluster/lib/cluster/module.rb +2 -2
  6. data/cluster/lib/cluster/resources/.DS_Store +0 -0
  7. data/cluster/lib/cluster/resources/corefile.yml +0 -0
  8. data/cluster/lib/cluster/runner.rb +173 -96
  9. data/sct/lib/.DS_Store +0 -0
  10. data/sct/lib/sct.rb +0 -0
  11. data/sct/lib/sct/.DS_Store +0 -0
  12. data/sct/lib/sct/cli_tools_distributor.rb +0 -0
  13. data/sct/lib/sct/command.rb +0 -0
  14. data/sct/lib/sct/commands/hostfile.rb +17 -13
  15. data/sct/lib/sct/commands/init.rb +0 -0
  16. data/sct/lib/sct/commands/mysqlproxy.rb +0 -0
  17. data/sct/lib/sct/commands_generator.rb +8 -8
  18. data/sct/lib/sct/tools.rb +0 -0
  19. data/sct/lib/sct/version.rb +1 -1
  20. data/sct_core/lib/.DS_Store +0 -0
  21. data/sct_core/lib/sct_core.rb +0 -0
  22. data/sct_core/lib/sct_core/.DS_Store +0 -0
  23. data/sct_core/lib/sct_core/command_executor.rb +0 -0
  24. data/sct_core/lib/sct_core/config.rb +0 -0
  25. data/sct_core/lib/sct_core/core_ext/string.rb +0 -0
  26. data/sct_core/lib/sct_core/helper.rb +29 -30
  27. data/sct_core/lib/sct_core/module.rb +0 -0
  28. data/sct_core/lib/sct_core/sct_pty.rb +0 -0
  29. data/sct_core/lib/sct_core/ui/implementations/shell.rb +0 -0
  30. data/sct_core/lib/sct_core/ui/interface.rb +0 -0
  31. data/sct_core/lib/sct_core/ui/ui.rb +0 -0
  32. data/sct_core/lib/sct_core/update_checker/update_checker.rb +2 -6
  33. data/shell/lib/shell.rb +1 -2
  34. data/shell/lib/shell/commands_generator.rb +2 -2
  35. data/shell/lib/shell/module.rb +2 -2
  36. data/shell/lib/shell/runner.rb +75 -26
  37. metadata +3 -10
  38. data/shell/README.md +0 -0
  39. data/shell/lib/shell/ClassLevelInheritableAttributes.rb +0 -25
  40. data/shell/lib/shell/docker/composer.rb +0 -16
  41. data/shell/lib/shell/docker/docker.rb +0 -218
  42. data/shell/lib/shell/docker/php.rb +0 -60
  43. data/shell/lib/shell/docker/yarn.rb +0 -17
  44. data/shell/lib/shell/tools.rb +0 -7
File without changes
@@ -1,25 +0,0 @@
1
- module ClassLevelInheritableAttributes
2
- def self.included(base)
3
- base.extend(ClassMethods)
4
- end
5
-
6
- module ClassMethods
7
- def inheritable_attributes(*args)
8
- @inheritable_attributes ||= [:inheritable_attributes]
9
- @inheritable_attributes += args
10
- args.each do |arg|
11
- class_eval %(
12
- class << self; attr_accessor :#{arg} end
13
- )
14
- end
15
- @inheritable_attributes
16
- end
17
-
18
- def inherited(subclass)
19
- @inheritable_attributes.each do |inheritable_attribute|
20
- instance_var = "@#{inheritable_attribute}"
21
- subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
22
- end
23
- end
24
- end
25
- end
@@ -1,16 +0,0 @@
1
- require "sct_core"
2
- require_relative "docker"
3
-
4
- module Shell
5
- class Composer < Docker
6
-
7
- # Configure the Yarn command
8
- def self.config
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
- end
15
- end
16
- end
@@ -1,218 +0,0 @@
1
- require "sct_core"
2
- require "shell/ClassLevelInheritableAttributes"
3
-
4
- module Shell
5
- class Docker
6
- include ClassLevelInheritableAttributes
7
- inheritable_attributes :image, :is_private_registry, :entrypoint, :volumes, :ports, :extra_arguments, :env_variables
8
-
9
- @image = nil
10
- @is_private_registry = false
11
- @entrypoint = nil
12
-
13
- @volumes = {}
14
- @ports = {}
15
- @user_group = []
16
- @extra_arguments = {}
17
- @env_variables = {}
18
-
19
- ###
20
- # The Docker command configuration. This has to be able to execute the command properly
21
- ###
22
- def self.config
23
- # Run some initialization commands
24
- end
25
-
26
- ###
27
- # Execute the configured command
28
- ###
29
- def self.exec(cli_arguments)
30
-
31
- self.add_extra_argument(cli_arguments)
32
-
33
- self.config
34
-
35
- # Check if the basic variables are set
36
- if !@image || @image.empty?
37
- raise LoadError, "The required image is not defined for this command"
38
- end
39
-
40
- if !self.check_for_image && @is_private_registry
41
- unless self.login_to_private_registry
42
- raise RuntimeError, "Could not authenticate to GCR (" + $?.exitstatus + ")"
43
- end
44
- end
45
-
46
- self.run_command
47
- end
48
-
49
- ###
50
- # The image for this Docker command
51
- ###
52
- def self.set_image(image, is_private_registry=false)
53
- @image = image
54
- @is_private_registry = is_private_registry
55
- end
56
-
57
- ###
58
- # Set the current PWD as a volume on the specified path in the container
59
- ###
60
- def self.set_pwd_as_volume(volume_path)
61
- pwd = `pwd -P`
62
-
63
- if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
64
- pwd=SctCore::Helper.convertWSLToWindowsPath(pwd)
65
- end
66
-
67
- add_volume(pwd, volume_path)
68
- end
69
-
70
- ###
71
- # Add an extra volume in the container
72
- ###
73
- def self.add_volume(local_path, volume_path)
74
- @volumes[local_path] = volume_path
75
- end
76
-
77
- ###
78
- # Add a port mapping for the container
79
- ###
80
- def self.map_port(external_port, container_port = nil)
81
-
82
- external_port=String(external_port)
83
- container_port=String(container_port)
84
-
85
- if container_port.empty?
86
- container_port = external_port
87
- end
88
-
89
- @ports[external_port] = container_port
90
- end
91
-
92
- ###
93
- # Set the current user and group in the container
94
- ###
95
- def self.set_current_user_and_group
96
- @user_group = []
97
- @user_group << `id -u`
98
- @user_group << `id -g`
99
- end
100
-
101
- ###
102
- # Set the entrypoint for the command in the container
103
- ###
104
- def self.set_entrypoint(entrypoint)
105
- @entrypoint=entrypoint
106
- end
107
-
108
- ###
109
- # Add extra arguments to be configured for the container
110
- ###
111
- def self.add_extra_argument(argument, value=nil)
112
- argument = String(argument)
113
-
114
- if value
115
- value = String(value)
116
- end
117
-
118
- self.extra_arguments[argument] = value
119
- end
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
-
128
- ###
129
- # Check if the image is already present in the system
130
- ###
131
- def self.check_for_image
132
- image_list=`docker images -q #{@image} 2> /dev/null`
133
-
134
- return image_list && !image_list.empty?
135
- end
136
-
137
- ###
138
- # Login to the private container registry with the cloud credentials
139
- ###
140
- def self.login_to_private_registry
141
- `docker login -u oauth2accesstoken -p "$(gcloud auth application-default print-access-token)" https://eu.gcr.io &> /dev/null`
142
- return $?.success?
143
- end
144
-
145
- ###
146
- # Run the command
147
- ###
148
- def self.run_command
149
- command = self.compile_command
150
-
151
- SctCore::CommandExecutor.execute(command: command, print_all: true, suppress_output: false)
152
- end
153
-
154
- ###
155
- # Compile the command with all options
156
- ###
157
- def self.compile_command
158
- # Basic docker run command
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
171
-
172
- # Attach configured volumes
173
- if @volumes
174
- @volumes.each do |local_path, container_path|
175
- command = self.add_to_command_string(command, "--volume " + local_path +":"+ container_path)
176
- end
177
- end
178
-
179
- # Map configured ports
180
- if @ports
181
- @ports.each do |external_port, container_port|
182
- command = self.add_to_command_string(command, "-p " + external_port +":"+ container_port)
183
- end
184
- end
185
-
186
- if @user_group
187
- command = self.add_to_command_string(command, "--user "+ String(@user_group.shift) +":"+ String(@user_group.shift))
188
- end
189
-
190
- # Add image to command
191
- command = self.add_to_command_string(command, @image)
192
-
193
- if @entrypoint
194
- command = self.add_to_command_string(command, String(@entrypoint))
195
- end
196
-
197
- # Append arguments and options to command
198
- if @extra_arguments
199
- @extra_arguments.each do |argument, value|
200
- if value && !value.empty?
201
- command = self.add_to_command_string(command, argument+"="+value)
202
- else
203
- command = self.add_to_command_string(command, argument)
204
- end
205
- end
206
- end
207
-
208
- return command
209
- end
210
-
211
- ###
212
- # Append a part to the command string and remove any unwanted characters
213
- ###
214
- def self.add_to_command_string(command_string, append)
215
- return command_string + append.gsub(/\r?\n/, "") + " "
216
- end
217
- end
218
- end
@@ -1,60 +0,0 @@
1
- require "sct_core"
2
-
3
- require_relative "docker"
4
-
5
- module Shell
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(self.get_environment_variables)
17
- end
18
-
19
- def self.get_environment_variables
20
- environment_variables = {}
21
- environment_variables.store("ENVIRONMENT", "local")
22
-
23
- environment_variables = self.add_service_ip_and_port(environment_variables)
24
-
25
- return environment_variables
26
- end
27
-
28
- def self.add_service_ip_and_port(environment_variables)
29
- service_names = %w[mysql-service redis-service]
30
-
31
- minikube_status
32
-
33
- service_names.each { |service_name|
34
- url = `#{SctCore::Helper.minikube} service #{service_name} --url`
35
-
36
- ip_and_port = url.match /(?<ip>[0-9]+(?:\.[0-9]+){3}):(?<port>[0-9]+)/
37
-
38
- case service_name
39
- when "mysql-service"
40
- environment_variables.store("DB_HOST", ip_and_port[:ip])
41
- environment_variables.store("DB_PORT", ip_and_port[:port])
42
- when "redis-service"
43
- environment_variables.store("REDIS_HOST", ip_and_port[:ip])
44
- environment_variables.store("REDIS_PORT", ip_and_port[:port])
45
- end
46
- }
47
-
48
- return environment_variables
49
- end
50
-
51
- def self.minikube_status
52
- output = `#{SctCore::Helper.minikube} status`
53
-
54
- if output.scan(/Running/).length != 3 && output.scan(/Configured/).length != 1
55
- UI.important("Please check your minikube status. If all services are stopped you should start the minikube first.")
56
- exit
57
- end
58
- end
59
- end
60
- end
@@ -1,17 +0,0 @@
1
- require "sct_core"
2
- require_relative "docker"
3
-
4
- module Shell
5
- class Yarn < Docker
6
-
7
- # Configure the Yarn command
8
- def self.config
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
- end
16
- end
17
- end
@@ -1,7 +0,0 @@
1
- module Shell
2
- TOOLS = [
3
- :yarn,
4
- :composer,
5
- :php
6
- ]
7
- end