kuber_kit 0.3.10 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/TODO.md +3 -3
- data/example/configurations/review.rb +1 -0
- data/example/infrastructure/artifacts.rb +1 -1
- data/example/services/docker_app.rb +12 -0
- data/lib/kuber_kit.rb +6 -4
- data/lib/kuber_kit/actions/configuration_loader.rb +11 -11
- data/lib/kuber_kit/actions/env_file_reader.rb +1 -0
- data/lib/kuber_kit/actions/image_compiler.rb +12 -6
- data/lib/kuber_kit/actions/service_deployer.rb +24 -11
- data/lib/kuber_kit/actions/template_reader.rb +1 -0
- data/lib/kuber_kit/artifacts_sync/artifacts_updater.rb +3 -2
- data/lib/kuber_kit/cli.rb +29 -21
- data/lib/kuber_kit/container.rb +5 -1
- data/lib/kuber_kit/core/configuration.rb +26 -24
- data/lib/kuber_kit/core/configuration_definition.rb +17 -10
- data/lib/kuber_kit/core/configuration_factory.rb +10 -9
- data/lib/kuber_kit/core/configuration_store.rb +2 -2
- data/lib/kuber_kit/core/image_store.rb +2 -2
- data/lib/kuber_kit/core/service_store.rb +2 -2
- data/lib/kuber_kit/image_compiler/compiler.rb +3 -1
- data/lib/kuber_kit/image_compiler/image_builder.rb +9 -1
- data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +3 -1
- data/lib/kuber_kit/service_deployer/strategies/docker.rb +20 -7
- data/lib/kuber_kit/service_deployer/strategies/docker_compose.rb +4 -4
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +3 -1
- data/lib/kuber_kit/shell/commands/docker_commands.rb +51 -10
- data/lib/kuber_kit/shell/local_shell.rb +5 -5
- data/lib/kuber_kit/shell/ssh_shell.rb +4 -4
- data/lib/kuber_kit/tools/logger_factory.rb +1 -1
- data/lib/kuber_kit/ui/api.rb +48 -0
- data/lib/kuber_kit/ui/debug.rb +31 -0
- data/lib/kuber_kit/ui/interactive.rb +15 -0
- data/lib/kuber_kit/ui/simple.rb +34 -5
- data/lib/kuber_kit/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f88af58c1a98432ce14e5527ea39dda750b641c80deeddb76b281dc861b1814f
|
4
|
+
data.tar.gz: 4b60492fae06a45b460d022ae540eb4e442e4aec65194791ba2e7306502612a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205b900fc00004c918108da19680c83f433b79d87b727421abdfec8680b7a0aef5ec0ad474605e7aa34e6370c047a8bbe20c1b81c4639684c8c6919a040e2ed4
|
7
|
+
data.tar.gz: a18edd776b63ffca524819a06adad9031c47272e12f69e66006fc0220e43510cc01f7697d225516c0861dde37523b0293cbe51b004f1336c3ffdbcc0673fca86
|
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
- https://ttytoolkit.org/
|
2
|
+
- do not show result for images list, if list is too large
|
2
3
|
- kit status should show the list of services and their status, with ability to select & view logs
|
3
|
-
- list services and require confirmation before deployment
|
4
|
-
- add kit logs support, should work similar to kit attach
|
5
4
|
- allow deploying only services enabled for specific configuration
|
6
5
|
- find a way to always deploy some service, e.g. for migrations and env_files
|
7
6
|
- template should be able to set default attributes
|
8
|
-
- template should be able to depend on image?
|
7
|
+
- template should be able to depend on image?
|
8
|
+
- cleanup image builds older than some date
|
data/lib/kuber_kit.rb
CHANGED
@@ -177,6 +177,8 @@ module KuberKit
|
|
177
177
|
module UI
|
178
178
|
autoload :Interactive, 'ui/interactive'
|
179
179
|
autoload :Simple, 'ui/simple'
|
180
|
+
autoload :Debug, 'ui/debug'
|
181
|
+
autoload :Api, 'ui/api'
|
180
182
|
end
|
181
183
|
|
182
184
|
autoload :CLI, 'cli'
|
@@ -205,12 +207,12 @@ module KuberKit
|
|
205
207
|
@current_configuration = nil
|
206
208
|
end
|
207
209
|
|
208
|
-
def
|
209
|
-
@
|
210
|
+
def set_ui_mode(value)
|
211
|
+
@ui_mode = value
|
210
212
|
end
|
211
213
|
|
212
|
-
def
|
213
|
-
|
214
|
+
def ui_mode
|
215
|
+
@ui_mode
|
214
216
|
end
|
215
217
|
|
216
218
|
def deprecation_warnings_disabled?
|
@@ -5,7 +5,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
5
5
|
"core.service_store",
|
6
6
|
"core.configuration_store",
|
7
7
|
"artifacts_sync.artifacts_updater",
|
8
|
-
"tools.logger",
|
9
8
|
"shell.local_shell",
|
10
9
|
"ui",
|
11
10
|
"configs"
|
@@ -18,20 +17,20 @@ class KuberKit::Actions::ConfigurationLoader
|
|
18
17
|
services_path = options[:services_path] || File.join(root_path, configs.services_dirname)
|
19
18
|
infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
|
20
19
|
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
21
|
-
configuration_name =
|
20
|
+
configuration_name = options[:configuration] || ENV["KUBER_KIT_CONFIGURATION"]
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
ui.print_debug "ConfigurationLoader", "Launching kuber_kit with:"
|
23
|
+
ui.print_debug "ConfigurationLoader", " Root path: #{root_path.to_s.yellow}"
|
24
|
+
ui.print_debug "ConfigurationLoader", " Images path: #{images_path.to_s.yellow}"
|
25
|
+
ui.print_debug "ConfigurationLoader", " Services path: #{services_path.to_s.yellow}"
|
26
|
+
ui.print_debug "ConfigurationLoader", " Infrastructure path: #{infra_path.to_s.yellow}"
|
27
|
+
ui.print_debug "ConfigurationLoader", " Configurations path: #{configurations_path.to_s.yellow}"
|
28
|
+
ui.print_debug "ConfigurationLoader", " Configuration name: #{configuration_name.to_s.yellow}"
|
30
29
|
|
31
30
|
ui.print_info("Logs", "See logs at: #{configs.log_file_path}")
|
32
31
|
|
33
32
|
unless File.exists?(root_path)
|
34
|
-
ui.print_warning "
|
33
|
+
ui.print_warning "ConfigurationLoader", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
35
34
|
end
|
36
35
|
|
37
36
|
if Gem::Version.new(KuberKit::VERSION) < Gem::Version.new(configs.kuber_kit_min_version)
|
@@ -65,6 +64,7 @@ class KuberKit::Actions::ConfigurationLoader
|
|
65
64
|
true
|
66
65
|
rescue KuberKit::Error => e
|
67
66
|
ui.print_error("Error", e.message)
|
67
|
+
|
68
68
|
false
|
69
69
|
end
|
70
70
|
|
@@ -97,6 +97,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
97
97
|
require(path)
|
98
98
|
end
|
99
99
|
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
100
|
-
|
100
|
+
ui.print_warning("ConfigurationLoader", "Directory with infrastructure not found: #{infra_path}")
|
101
101
|
end
|
102
102
|
end
|
@@ -3,7 +3,7 @@ class KuberKit::Actions::ImageCompiler
|
|
3
3
|
"image_compiler.image_dependency_resolver",
|
4
4
|
"image_compiler.build_server_pool_factory",
|
5
5
|
"shell.local_shell",
|
6
|
-
"
|
6
|
+
"configs",
|
7
7
|
"ui",
|
8
8
|
image_compiler: "image_compiler.action_handler",
|
9
9
|
]
|
@@ -13,14 +13,18 @@ class KuberKit::Actions::ImageCompiler
|
|
13
13
|
build_id = generate_build_id
|
14
14
|
build_server_pool = build_server_pool_factory.create()
|
15
15
|
|
16
|
+
compiled_images = []
|
17
|
+
compilation_result = {}
|
16
18
|
image_dependency_resolver.each_with_deps(image_names) do |dep_image_names|
|
19
|
+
ui.print_debug("ImageCompiler", "Scheduling to compile: #{dep_image_names.inspect}. Limit: #{configs.compile_simultaneous_limit}")
|
17
20
|
result = compile_simultaneously(dep_image_names, build_id, build_server_pool)
|
18
|
-
|
21
|
+
compiled_images += dep_image_names
|
22
|
+
compilation_result = compilation_result.merge(result)
|
19
23
|
end
|
20
24
|
|
21
25
|
build_server_pool.disconnect_all
|
22
26
|
|
23
|
-
|
27
|
+
{ images: compiled_images, compilation: compilation_result }
|
24
28
|
rescue KuberKit::Error => e
|
25
29
|
ui.print_error("Error", e.message)
|
26
30
|
|
@@ -30,20 +34,22 @@ class KuberKit::Actions::ImageCompiler
|
|
30
34
|
private
|
31
35
|
def compile_simultaneously(image_names, build_id, build_server_pool)
|
32
36
|
task_group = ui.create_task_group
|
37
|
+
compiler_result = {}
|
33
38
|
image_names.map do |image_name|
|
34
39
|
|
35
|
-
|
40
|
+
ui.print_debug("ImageCompiler", "Started compiling: #{image_name.to_s.green}")
|
36
41
|
task_group.add("Compiling #{image_name.to_s.yellow}") do |task|
|
37
42
|
shell = build_server_pool.get_shell
|
38
43
|
|
39
|
-
image_compiler.call(shell, image_name, build_id)
|
44
|
+
compiler_result[image_name] = image_compiler.call(shell, image_name, build_id)
|
40
45
|
|
41
46
|
task.update_title("Compiled #{image_name.to_s.green}")
|
42
|
-
|
47
|
+
ui.print_debug("ImageCompiler", "Finished compiling: #{image_name}")
|
43
48
|
end
|
44
49
|
|
45
50
|
end
|
46
51
|
task_group.wait
|
52
|
+
compiler_result
|
47
53
|
end
|
48
54
|
|
49
55
|
def generate_build_id
|
@@ -4,17 +4,17 @@ class KuberKit::Actions::ServiceDeployer
|
|
4
4
|
"service_deployer.service_list_resolver",
|
5
5
|
"core.service_store",
|
6
6
|
"shell.local_shell",
|
7
|
-
"tools.logger",
|
8
7
|
"ui",
|
9
8
|
service_deployer: "service_deployer.action_handler",
|
10
9
|
]
|
11
10
|
|
12
11
|
Contract KeywordArgs[
|
13
|
-
services:
|
14
|
-
tags:
|
15
|
-
skip_compile:
|
12
|
+
services: Maybe[ArrayOf[String]],
|
13
|
+
tags: Maybe[ArrayOf[String]],
|
14
|
+
skip_compile: Maybe[Bool],
|
15
|
+
require_confirmation: Maybe[Bool],
|
16
16
|
] => Any
|
17
|
-
def call(services:, tags:, skip_compile: false)
|
17
|
+
def call(services:, tags:, skip_compile: false, require_confirmation: false)
|
18
18
|
if services.empty? && tags.empty?
|
19
19
|
services, tags = show_tags_selection
|
20
20
|
end
|
@@ -25,7 +25,16 @@ class KuberKit::Actions::ServiceDeployer
|
|
25
25
|
)
|
26
26
|
|
27
27
|
unless service_names.any?
|
28
|
-
ui.print_warning "
|
28
|
+
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
services_list = service_names.map(&:to_s).map(&:yellow).join(", ")
|
33
|
+
ui.print_info "ServiceDeployer", "The following services will be deployed: #{services_list}"
|
34
|
+
|
35
|
+
if require_confirmation
|
36
|
+
result = ui.prompt("Please confirm to continue deployment", ["confirm".green, "cancel".red])
|
37
|
+
return false unless result == "confirm".green
|
29
38
|
end
|
30
39
|
|
31
40
|
services = service_names.map do |service_name|
|
@@ -35,9 +44,9 @@ class KuberKit::Actions::ServiceDeployer
|
|
35
44
|
images_names = services.map(&:images).flatten.uniq
|
36
45
|
|
37
46
|
compile_images(images_names) unless skip_compile
|
38
|
-
deploy_services(service_names)
|
47
|
+
deployment_result = deploy_services(service_names)
|
39
48
|
|
40
|
-
|
49
|
+
{ services: service_names, deployment: deployment_result }
|
41
50
|
rescue KuberKit::Error => e
|
42
51
|
ui.print_error("Error", e.message)
|
43
52
|
|
@@ -47,18 +56,22 @@ class KuberKit::Actions::ServiceDeployer
|
|
47
56
|
def deploy_services(service_names)
|
48
57
|
task_group = ui.create_task_group
|
49
58
|
|
59
|
+
deployer_result = {}
|
60
|
+
|
50
61
|
service_names.each do |service_name|
|
51
62
|
|
52
|
-
|
63
|
+
ui.print_debug("ServiceDeployer", "Started deploying: #{service_name.to_s.green}")
|
53
64
|
task_group.add("Deploying #{service_name.to_s.yellow}") do |task|
|
54
|
-
service_deployer.call(local_shell, service_name.to_sym)
|
65
|
+
deployer_result[service_name] = service_deployer.call(local_shell, service_name.to_sym)
|
55
66
|
|
56
67
|
task.update_title("Deployed #{service_name.to_s.green}")
|
57
|
-
|
68
|
+
ui.print_debug("ServiceDeployer", "Finished deploying: #{service_name.to_s.green}")
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
61
72
|
task_group.wait
|
73
|
+
|
74
|
+
deployer_result
|
62
75
|
end
|
63
76
|
|
64
77
|
def compile_images(images_names)
|
@@ -4,7 +4,8 @@ class KuberKit::ArtifactsSync::ArtifactsUpdater
|
|
4
4
|
include KuberKit::Import[
|
5
5
|
"artifacts_sync.git_artifact_resolver",
|
6
6
|
"artifacts_sync.null_artifact_resolver",
|
7
|
-
|
7
|
+
|
8
|
+
"ui"
|
8
9
|
]
|
9
10
|
|
10
11
|
def use_resolver(artifact_resolver, artifact_class:)
|
@@ -23,7 +24,7 @@ class KuberKit::ArtifactsSync::ArtifactsUpdater
|
|
23
24
|
artifacts.each do |artifact|
|
24
25
|
resolver = @@resolvers[artifact.class]
|
25
26
|
|
26
|
-
|
27
|
+
ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
|
27
28
|
|
28
29
|
raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
|
29
30
|
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -7,6 +7,7 @@ class KuberKit::CLI < Thor
|
|
7
7
|
class_option :images_path, :type => :string
|
8
8
|
class_option :infra_path, :type => :string
|
9
9
|
class_option :configurations_path, :type => :string
|
10
|
+
class_option :ui, :type => :string, :desc => "UI mode (interactive|debug|simple)"
|
10
11
|
class_option :debug, :type => :boolean, aliases: ["-d"]
|
11
12
|
class_option :configuration, :type => :string, aliases: ["-C"]
|
12
13
|
|
@@ -14,48 +15,47 @@ class KuberKit::CLI < Thor
|
|
14
15
|
def compile(image_names_str)
|
15
16
|
setup(options)
|
16
17
|
|
18
|
+
started_at = Time.now.to_i
|
17
19
|
image_names = image_names_str.split(",").map(&:strip).map(&:to_sym)
|
18
20
|
|
19
21
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
20
22
|
result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
|
21
23
|
end
|
22
24
|
|
23
|
-
logger = KuberKit::Container['tools.logger']
|
24
25
|
if result
|
25
|
-
|
26
|
-
|
27
|
-
logger.info("---------------------------")
|
26
|
+
time = (Time.now.to_i - started_at)
|
27
|
+
print_result("Image compilation finished! (#{time}s)", result: result)
|
28
28
|
else
|
29
|
-
|
30
|
-
logger.info("Image compilation failed!".red)
|
31
|
-
logger.info("-------------------------".red)
|
29
|
+
exit 1
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
33
|
desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
|
36
|
-
method_option :services,
|
37
|
-
method_option :tags,
|
38
|
-
method_option :skip_compile,
|
34
|
+
method_option :services, :type => :array, aliases: ["-s"]
|
35
|
+
method_option :tags, :type => :array, aliases: ["-t"]
|
36
|
+
method_option :skip_compile, :type => :boolean, aliases: ["-B"]
|
37
|
+
method_option :require_confirmation, :type => :boolean, aliases: ["-r"]
|
39
38
|
def deploy
|
40
39
|
setup(options)
|
41
40
|
|
42
41
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
42
|
+
require_confirmation = options[:require_confirmation] ||
|
43
|
+
KuberKit.current_configuration.deployer_require_confirimation ||
|
44
|
+
false
|
45
|
+
started_at = Time.now.to_i
|
43
46
|
result = KuberKit::Container['actions.service_deployer'].call(
|
44
|
-
services:
|
45
|
-
tags:
|
46
|
-
skip_compile:
|
47
|
+
services: options[:services] || [],
|
48
|
+
tags: options[:tags] || [],
|
49
|
+
skip_compile: options[:skip_compile] || false,
|
50
|
+
require_confirmation: require_confirmation
|
47
51
|
)
|
48
52
|
end
|
49
53
|
|
50
|
-
logger = KuberKit::Container['tools.logger']
|
51
54
|
if result
|
52
|
-
|
53
|
-
|
54
|
-
logger.info("---------------------------")
|
55
|
+
time = (Time.now.to_i - started_at)
|
56
|
+
print_result("Service deployment finished! (#{time}s)", result: result)
|
55
57
|
else
|
56
|
-
|
57
|
-
logger.info("Service deployment failed!".red)
|
58
|
-
logger.info("-------------------------".red)
|
58
|
+
exit 1
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -134,7 +134,11 @@ class KuberKit::CLI < Thor
|
|
134
134
|
|
135
135
|
private
|
136
136
|
def setup(options)
|
137
|
-
|
137
|
+
if options[:debug]
|
138
|
+
KuberKit.set_ui_mode(:debug)
|
139
|
+
elsif options[:ui]
|
140
|
+
KuberKit.set_ui_mode(options[:ui].to_sym)
|
141
|
+
end
|
138
142
|
|
139
143
|
# We should load config before loading any bean, to make sure that bean won't be built with default config
|
140
144
|
root_path = options[:path] || File.join(Dir.pwd, KuberKit::Container['configs'].kuber_kit_dirname)
|
@@ -143,4 +147,8 @@ class KuberKit::CLI < Thor
|
|
143
147
|
require config_file_path
|
144
148
|
end
|
145
149
|
end
|
150
|
+
|
151
|
+
def print_result(message, data = {})
|
152
|
+
KuberKit::Container['ui'].print_result(message, data)
|
153
|
+
end
|
146
154
|
end
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -258,8 +258,12 @@ class KuberKit::Container
|
|
258
258
|
end
|
259
259
|
|
260
260
|
register "ui" do
|
261
|
-
if KuberKit.
|
261
|
+
if KuberKit.ui_mode == :debug
|
262
|
+
KuberKit::UI::Debug.new
|
263
|
+
elsif KuberKit.ui_mode == :simple
|
262
264
|
KuberKit::UI::Simple.new
|
265
|
+
elsif KuberKit.ui_mode == :api
|
266
|
+
KuberKit::UI::Api.new
|
263
267
|
else
|
264
268
|
KuberKit::UI::Interactive.new
|
265
269
|
end
|
@@ -1,35 +1,37 @@
|
|
1
1
|
class KuberKit::Core::Configuration
|
2
2
|
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
|
3
|
-
:
|
4
|
-
:
|
3
|
+
:services_attributes, :build_servers, :global_build_vars,
|
4
|
+
:deployer_strategy, :deployer_namespace, :deployer_require_confirimation
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
7
|
-
name:
|
8
|
-
artifacts:
|
9
|
-
registries:
|
10
|
-
env_files:
|
11
|
-
templates:
|
12
|
-
kubeconfig_path:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
name: Symbol,
|
8
|
+
artifacts: Hash,
|
9
|
+
registries: Hash,
|
10
|
+
env_files: Hash,
|
11
|
+
templates: Hash,
|
12
|
+
kubeconfig_path: Maybe[String],
|
13
|
+
services_attributes: HashOf[Symbol => Hash],
|
14
|
+
build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
|
15
|
+
global_build_vars: HashOf[Symbol => Any],
|
16
|
+
deployer_strategy: Symbol,
|
17
|
+
deployer_namespace: Maybe[Symbol],
|
18
|
+
deployer_require_confirimation: Bool,
|
18
19
|
] => Any
|
19
20
|
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
|
20
|
-
|
21
|
-
|
22
|
-
@name
|
23
|
-
@artifacts
|
24
|
-
@registries
|
25
|
-
@env_files
|
26
|
-
@templates
|
27
|
-
@kubeconfig_path
|
28
|
-
@
|
29
|
-
@deployer_namespace = deployer_namespace
|
30
|
-
@build_servers = build_servers
|
21
|
+
services_attributes:, build_servers:, global_build_vars:,
|
22
|
+
deployer_strategy:, deployer_namespace:, deployer_require_confirimation:)
|
23
|
+
@name = name
|
24
|
+
@artifacts = artifacts
|
25
|
+
@registries = registries
|
26
|
+
@env_files = env_files
|
27
|
+
@templates = templates
|
28
|
+
@kubeconfig_path = kubeconfig_path
|
29
|
+
@build_servers = build_servers
|
31
30
|
@services_attributes = services_attributes
|
32
31
|
@global_build_vars = global_build_vars
|
32
|
+
@deployer_strategy = deployer_strategy
|
33
|
+
@deployer_namespace = deployer_namespace
|
34
|
+
@deployer_require_confirimation = deployer_require_confirimation
|
33
35
|
end
|
34
36
|
|
35
37
|
def service_attributes(service_name)
|
@@ -17,18 +17,19 @@ class KuberKit::Core::ConfigurationDefinition
|
|
17
17
|
|
18
18
|
def to_attrs
|
19
19
|
OpenStruct.new(
|
20
|
-
name:
|
21
|
-
artifacts:
|
22
|
-
registries:
|
23
|
-
env_files:
|
24
|
-
templates:
|
25
|
-
kubeconfig_path:
|
26
|
-
|
27
|
-
|
28
|
-
enabled_services: @enabled_services,
|
29
|
-
build_servers: @build_servers,
|
20
|
+
name: @configuration_name,
|
21
|
+
artifacts: @artifacts,
|
22
|
+
registries: @registries,
|
23
|
+
env_files: @env_files,
|
24
|
+
templates: @templates,
|
25
|
+
kubeconfig_path: @kubeconfig_path,
|
26
|
+
enabled_services: @enabled_services,
|
27
|
+
build_servers: @build_servers,
|
30
28
|
services_attributes: @services_attributes,
|
31
29
|
global_build_vars: @global_build_vars,
|
30
|
+
deployer_strategy: @deployer_strategy,
|
31
|
+
deployer_namespace: @deployer_namespace,
|
32
|
+
deployer_require_confirimation: @deployer_require_confirimation || false,
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
@@ -94,6 +95,12 @@ class KuberKit::Core::ConfigurationDefinition
|
|
94
95
|
self
|
95
96
|
end
|
96
97
|
|
98
|
+
def deployer_require_confirimation
|
99
|
+
@deployer_require_confirimation = true
|
100
|
+
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
97
104
|
def enabled_services(services)
|
98
105
|
if services.is_a?(Hash)
|
99
106
|
@enabled_services += services.keys.map(&:to_sym)
|
@@ -20,17 +20,18 @@ class KuberKit::Core::ConfigurationFactory
|
|
20
20
|
build_servers = fetch_build_servers(configuration_attrs.build_servers)
|
21
21
|
|
22
22
|
KuberKit::Core::Configuration.new(
|
23
|
-
name:
|
24
|
-
artifacts:
|
25
|
-
registries:
|
26
|
-
env_files:
|
27
|
-
templates:
|
28
|
-
kubeconfig_path:
|
29
|
-
|
30
|
-
deployer_namespace: configuration_attrs.deployer_namespace,
|
31
|
-
build_servers: build_servers,
|
23
|
+
name: configuration_attrs.name,
|
24
|
+
artifacts: artifacts,
|
25
|
+
registries: registries,
|
26
|
+
env_files: env_files,
|
27
|
+
templates: templates,
|
28
|
+
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
29
|
+
build_servers: build_servers,
|
32
30
|
services_attributes: configuration_attrs.services_attributes,
|
33
31
|
global_build_vars: configuration_attrs.global_build_vars || {},
|
32
|
+
deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
|
33
|
+
deployer_namespace: configuration_attrs.deployer_namespace,
|
34
|
+
deployer_require_confirimation: configuration_attrs.deployer_require_confirimation,
|
34
35
|
)
|
35
36
|
end
|
36
37
|
|
@@ -3,7 +3,7 @@ class KuberKit::Core::ConfigurationStore
|
|
3
3
|
"core.configuration_factory",
|
4
4
|
"core.configuration_definition_factory",
|
5
5
|
"shell.local_shell",
|
6
|
-
"
|
6
|
+
"ui"
|
7
7
|
]
|
8
8
|
|
9
9
|
def define(configuration_name)
|
@@ -33,7 +33,7 @@ class KuberKit::Core::ConfigurationStore
|
|
33
33
|
load_definition(path)
|
34
34
|
end
|
35
35
|
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
36
|
-
|
36
|
+
ui.print_warning("ConfigurationStore", "Directory with configurations not found: #{dir_path}")
|
37
37
|
[]
|
38
38
|
end
|
39
39
|
|
@@ -3,7 +3,7 @@ class KuberKit::Core::ImageStore
|
|
3
3
|
"core.image_factory",
|
4
4
|
"core.image_definition_factory",
|
5
5
|
"shell.local_shell",
|
6
|
-
"
|
6
|
+
"ui"
|
7
7
|
]
|
8
8
|
|
9
9
|
def define(image_name, image_dir = nil)
|
@@ -33,7 +33,7 @@ class KuberKit::Core::ImageStore
|
|
33
33
|
load_definition(path)
|
34
34
|
end
|
35
35
|
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
36
|
-
|
36
|
+
ui.print_warning("ImageStore", "Directory with images not found: #{dir_path}")
|
37
37
|
[]
|
38
38
|
end
|
39
39
|
|
@@ -3,7 +3,7 @@ class KuberKit::Core::ServiceStore
|
|
3
3
|
"core.service_factory",
|
4
4
|
"core.service_definition_factory",
|
5
5
|
"shell.local_shell",
|
6
|
-
"
|
6
|
+
"ui",
|
7
7
|
]
|
8
8
|
|
9
9
|
def define(service_name)
|
@@ -33,7 +33,7 @@ class KuberKit::Core::ServiceStore
|
|
33
33
|
load_definition(path)
|
34
34
|
end
|
35
35
|
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
36
|
-
|
36
|
+
ui.print_warning("ServiceStore", "Directory with services not found: #{dir_path}")
|
37
37
|
[]
|
38
38
|
end
|
39
39
|
|
@@ -12,7 +12,9 @@ class KuberKit::ImageCompiler::Compiler
|
|
12
12
|
context_helper = context_helper_factory.build_image_context(shell, image)
|
13
13
|
image_build_dir_creator.create(shell, image, image_build_dir, context_helper: context_helper)
|
14
14
|
|
15
|
-
image_builder.build(shell, image, image_build_dir, context_helper: context_helper)
|
15
|
+
result = image_builder.build(shell, image, image_build_dir, context_helper: context_helper)
|
16
16
|
image_build_dir_creator.cleanup(shell, image_build_dir)
|
17
|
+
|
18
|
+
result
|
17
19
|
end
|
18
20
|
end
|
@@ -10,7 +10,13 @@ class KuberKit::ImageCompiler::ImageBuilder
|
|
10
10
|
def build(shell, image, build_dir, context_helper: nil)
|
11
11
|
image.before_build_callback.call(context_helper, build_dir) if image.before_build_callback
|
12
12
|
|
13
|
-
|
13
|
+
build_options = ["-t=#{image.registry_url}"]
|
14
|
+
# use quite option for api mode ui, so it will only return built image id
|
15
|
+
if KuberKit.ui_mode == :api
|
16
|
+
build_options << "-q"
|
17
|
+
end
|
18
|
+
|
19
|
+
build_result = docker_commands.build(shell, build_dir, build_options)
|
14
20
|
|
15
21
|
version_tag = version_tag_builder.get_version
|
16
22
|
docker_commands.tag(shell, image.registry_url, version_tag)
|
@@ -21,5 +27,7 @@ class KuberKit::ImageCompiler::ImageBuilder
|
|
21
27
|
end
|
22
28
|
|
23
29
|
image.after_build_callback.call(context_helper, build_dir) if image.after_build_callback
|
30
|
+
|
31
|
+
build_result
|
24
32
|
end
|
25
33
|
end
|
@@ -20,7 +20,9 @@ class KuberKit::ImageCompiler::ImageDependencyResolver
|
|
20
20
|
next_dependencies = get_next(image_names, resolved: resolved_dependencies, limit: compile_limit)
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
(image_names - resolved_dependencies).each_slice(compile_limit) do |group|
|
24
|
+
block.call(group)
|
25
|
+
end
|
24
26
|
end
|
25
27
|
|
26
28
|
Contract Or[Symbol, ArrayOf[Symbol]], KeywordArgs[
|
@@ -10,8 +10,10 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
10
10
|
:image_name,
|
11
11
|
:detached,
|
12
12
|
:command_name,
|
13
|
-
:
|
14
|
-
:delete_if_exists
|
13
|
+
:custom_args,
|
14
|
+
:delete_if_exists,
|
15
|
+
:volumes,
|
16
|
+
:networks,
|
15
17
|
]
|
16
18
|
|
17
19
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
@@ -23,8 +25,10 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
23
25
|
end
|
24
26
|
|
25
27
|
container_name = strategy_options.fetch(:container_name, service.uri)
|
26
|
-
command_name = strategy_options.fetch(:command_name,
|
27
|
-
|
28
|
+
command_name = strategy_options.fetch(:command_name, nil)
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
|
+
networks = strategy_options.fetch(:networks, [])
|
31
|
+
volumes = strategy_options.fetch(:volumes, [])
|
28
32
|
|
29
33
|
image_name = strategy_options.fetch(:image_name, nil)
|
30
34
|
if image_name.nil?
|
@@ -37,15 +41,24 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
37
41
|
docker_commands.delete_container(shell, container_name)
|
38
42
|
end
|
39
43
|
|
40
|
-
|
44
|
+
custom_args = Array(custom_args)
|
41
45
|
if container_name
|
42
|
-
|
46
|
+
custom_args << "--name #{container_name}"
|
47
|
+
end
|
48
|
+
networks.each do |network|
|
49
|
+
docker_commands.create_network(shell, network)
|
50
|
+
custom_args << "--network #{network}"
|
51
|
+
end
|
52
|
+
volumes.each do |volume|
|
53
|
+
volume_name, _ = volume.split(":")
|
54
|
+
docker_commands.create_volume(shell, volume_name) unless volume_name.start_with?("/")
|
55
|
+
custom_args << "--volume #{volume}"
|
43
56
|
end
|
44
57
|
|
45
58
|
docker_commands.run(
|
46
59
|
shell, image.remote_registry_url,
|
47
60
|
command: command_name,
|
48
|
-
args:
|
61
|
+
args: custom_args,
|
49
62
|
detached: !!strategy_options[:detached]
|
50
63
|
)
|
51
64
|
end
|
@@ -8,7 +8,7 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
8
8
|
STRATEGY_OPTIONS = [
|
9
9
|
:service_name,
|
10
10
|
:command_name,
|
11
|
-
:
|
11
|
+
:custom_args,
|
12
12
|
:detached
|
13
13
|
]
|
14
14
|
|
@@ -25,13 +25,13 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
25
25
|
end
|
26
26
|
|
27
27
|
service_name = strategy_options.fetch(:service_name, service.name.to_s)
|
28
|
-
command_name = strategy_options.fetch(:command_name,
|
29
|
-
|
28
|
+
command_name = strategy_options.fetch(:command_name, nil)
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
30
|
|
31
31
|
docker_compose_commands.run(shell, config_path,
|
32
32
|
service: service_name,
|
33
33
|
command: command_name,
|
34
|
-
args:
|
34
|
+
args: custom_args,
|
35
35
|
detached: !!strategy_options[:detached]
|
36
36
|
)
|
37
37
|
end
|
@@ -39,7 +39,7 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
39
39
|
kubectl_commands.delete_resource(shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
40
40
|
end
|
41
41
|
|
42
|
-
kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
42
|
+
apply_result = kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
43
43
|
|
44
44
|
restart_enabled = strategy_options.fetch(:restart_if_exists, true)
|
45
45
|
if restart_enabled && resource_exists
|
@@ -48,5 +48,7 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
48
48
|
kubeconfig_path: kubeconfig_path, namespace: namespace
|
49
49
|
)
|
50
50
|
end
|
51
|
+
|
52
|
+
apply_result
|
51
53
|
end
|
52
54
|
end
|
@@ -3,7 +3,7 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
3
3
|
default_args = ["--rm=true"]
|
4
4
|
args_list = (default_args + args).join(" ")
|
5
5
|
|
6
|
-
shell.exec!(%Q{docker build #{build_dir} #{args_list}})
|
6
|
+
shell.exec!(%Q{docker image build #{build_dir} #{args_list}})
|
7
7
|
end
|
8
8
|
|
9
9
|
def tag(shell, image_name, tag_name)
|
@@ -29,26 +29,67 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def container_exists?(shell, container_name)
|
33
|
-
result =
|
32
|
+
def container_exists?(shell, container_name, status: nil)
|
33
|
+
result = get_containers(shell, container_name, status: status)
|
34
34
|
result && result != ""
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
shell.exec!(%Q{docker rm -f #{container_name}})
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_container_id(shell, container_name, only_healthy: false, status: "running")
|
37
|
+
def get_containers(shell, container_name, only_healthy: false, status: nil)
|
42
38
|
command_parts = []
|
43
39
|
command_parts << "docker ps -a -q"
|
44
40
|
|
45
41
|
if only_healthy
|
46
42
|
command_parts << "--filter=\"health=healthy\""
|
47
43
|
end
|
48
|
-
|
49
|
-
|
44
|
+
if status
|
45
|
+
command_parts << "--filter=\"status=#{status}\""
|
46
|
+
end
|
50
47
|
command_parts << "--filter=\"name=#{container_name}\""
|
51
48
|
|
52
49
|
shell.exec!(command_parts.join(" "))
|
53
50
|
end
|
51
|
+
|
52
|
+
def delete_container(shell, container_name)
|
53
|
+
shell.exec!("docker rm -f #{container_name}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_network(shell, name)
|
57
|
+
unless network_exists?(shell, name)
|
58
|
+
shell.exec!("docker network create #{name}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def network_exists?(shell, network_name)
|
63
|
+
result = get_networks(shell, network_name)
|
64
|
+
result && result != ""
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_networks(shell, network_name)
|
68
|
+
command_parts = []
|
69
|
+
command_parts << "docker network ls"
|
70
|
+
command_parts << "--filter=\"name=#{network_name}\""
|
71
|
+
command_parts << "--format \"{{.Name}}\""
|
72
|
+
|
73
|
+
shell.exec!(command_parts.join(" "))
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_volume(shell, name)
|
77
|
+
unless volume_exists?(shell, name)
|
78
|
+
shell.exec!("docker volume create #{name}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def volume_exists?(shell, volume_name)
|
83
|
+
result = get_volumes(shell, volume_name)
|
84
|
+
result && result != ""
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_volumes(shell, volume_name)
|
88
|
+
command_parts = []
|
89
|
+
command_parts << "docker volume ls"
|
90
|
+
command_parts << "--filter=\"name=#{volume_name}\""
|
91
|
+
command_parts << "--format \"{{.Name}}\""
|
92
|
+
|
93
|
+
shell.exec!(command_parts.join(" "))
|
94
|
+
end
|
54
95
|
end
|
@@ -2,16 +2,16 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
|
4
4
|
include KuberKit::Import[
|
5
|
-
"tools.logger",
|
6
5
|
"shell.command_counter",
|
7
6
|
"shell.rsync_commands",
|
7
|
+
"ui",
|
8
8
|
]
|
9
9
|
|
10
10
|
def exec!(command, log_command: true)
|
11
11
|
command_number = command_counter.get_number.to_s.rjust(2, "0")
|
12
12
|
|
13
13
|
if log_command
|
14
|
-
|
14
|
+
ui.print_debug("LocalShell", "Execute: [#{command_number}]: #{command.to_s.cyan}")
|
15
15
|
end
|
16
16
|
|
17
17
|
result = nil
|
@@ -20,7 +20,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
|
|
20
20
|
end
|
21
21
|
|
22
22
|
if result && result != "" && log_command
|
23
|
-
|
23
|
+
ui.print_debug("LocalShell", "Finished [#{command_number}] with result: \n ----\n#{result.grey}\n ----")
|
24
24
|
end
|
25
25
|
|
26
26
|
if $?.exitstatus != 0
|
@@ -34,7 +34,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
|
|
34
34
|
command_number = command_counter.get_number.to_s.rjust(2, "0")
|
35
35
|
|
36
36
|
if log_command
|
37
|
-
|
37
|
+
ui.print_debug("LocalShell", "Interactive: [#{command_number}]: #{command.to_s.cyan}")
|
38
38
|
end
|
39
39
|
|
40
40
|
result = system(command)
|
@@ -57,7 +57,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
|
|
57
57
|
|
58
58
|
File.write(file_path, content)
|
59
59
|
|
60
|
-
|
60
|
+
ui.print_debug("LocalShell", "Created file #{file_path.to_s.cyan}\r\n ----\r\n#{content.grey}\r\n ----")
|
61
61
|
|
62
62
|
true
|
63
63
|
end
|
@@ -2,7 +2,7 @@ require 'tempfile'
|
|
2
2
|
|
3
3
|
class KuberKit::Shell::SshShell < KuberKit::Shell::LocalShell
|
4
4
|
include KuberKit::Import[
|
5
|
-
"
|
5
|
+
"ui",
|
6
6
|
"shell.command_counter",
|
7
7
|
"shell.rsync_commands",
|
8
8
|
"shell.local_shell"
|
@@ -24,13 +24,13 @@ class KuberKit::Shell::SshShell < KuberKit::Shell::LocalShell
|
|
24
24
|
command_number = command_counter.get_number.to_s.rjust(2, "0")
|
25
25
|
|
26
26
|
if log_command
|
27
|
-
|
27
|
+
ui.print_debug("SshShell", "#{ssh_session.host.green} > Execute: [#{command_number}]: #{command.to_s.cyan}")
|
28
28
|
end
|
29
29
|
|
30
30
|
result = ssh_session.exec!(command)
|
31
31
|
|
32
32
|
if result && result != "" && log_command
|
33
|
-
|
33
|
+
ui.print_debug("SshShell", "#{ssh_session.host.green} > Finished [#{command_number}] with result: \n#{result.grey}")
|
34
34
|
end
|
35
35
|
|
36
36
|
result
|
@@ -62,7 +62,7 @@ class KuberKit::Shell::SshShell < KuberKit::Shell::LocalShell
|
|
62
62
|
sync(file.path, file_path)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
ui.print_debug("SshShell", "Created file #{file_path.to_s.cyan}\r\n ----\r\n#{content.grey}\r\n ----")
|
66
66
|
|
67
67
|
true
|
68
68
|
end
|
@@ -26,7 +26,7 @@ class KuberKit::Tools::LoggerFactory
|
|
26
26
|
severity_text = severity.to_s
|
27
27
|
severity_text = severity_text.colorize(severity_color) if severity_color
|
28
28
|
|
29
|
-
if level == Logger::
|
29
|
+
if level == Logger::DEBUG
|
30
30
|
"#{datetime.strftime("%Y/%m/%d %H:%M:%S").grey} #{msg}\n"
|
31
31
|
else
|
32
32
|
"#{datetime.strftime("%Y/%m/%d %H:%M:%S").grey} #{severity_text.downcase}: #{msg}\n"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'json'
|
2
|
+
class KuberKit::UI::Api < KuberKit::UI::Simple
|
3
|
+
class Task < KuberKit::UI::Simple::Task
|
4
|
+
def print_started
|
5
|
+
# do nothing, api formatter should only show result
|
6
|
+
end
|
7
|
+
|
8
|
+
def print_finished
|
9
|
+
# do nothing, api formatter should only show result
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_task_group
|
14
|
+
TaskGroup.new(KuberKit::UI::Api::Task)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_task(title, &block)
|
18
|
+
task = KuberKit::UI::Api::Task.new(title, &block)
|
19
|
+
task.execute
|
20
|
+
task.wait
|
21
|
+
end
|
22
|
+
|
23
|
+
def print_info(title, text)
|
24
|
+
logger.debug(text)
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_error(title, text)
|
28
|
+
logger.debug(text)
|
29
|
+
print_json({error: text})
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_warning(title, text)
|
33
|
+
logger.debug(text)
|
34
|
+
end
|
35
|
+
|
36
|
+
def print_debug(title, text)
|
37
|
+
logger.debug(text)
|
38
|
+
end
|
39
|
+
|
40
|
+
def print_result(message, data = {})
|
41
|
+
print_json({message: message}.merge(data))
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
def print_json(data)
|
46
|
+
puts JSON.generate(data)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class KuberKit::UI::Debug < KuberKit::UI::Simple
|
2
|
+
def print_info(title, text)
|
3
|
+
print_text(text, color: String::Colors::BLUE)
|
4
|
+
end
|
5
|
+
|
6
|
+
def print_error(title, text)
|
7
|
+
print_text(text, color: String::Colors::RED)
|
8
|
+
end
|
9
|
+
|
10
|
+
def print_warning(title, text)
|
11
|
+
print_text(text, color: String::Colors::YELLOW)
|
12
|
+
logger.debug(text)
|
13
|
+
end
|
14
|
+
|
15
|
+
def print_debug(title, text)
|
16
|
+
print_text(text, color: nil)
|
17
|
+
logger.debug(text)
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_result(message, data = {})
|
21
|
+
print_debug("Result", "---------------------------")
|
22
|
+
print_debug("Result", message)
|
23
|
+
print_debug("Result", "---------------------------")
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
def print_text(text, color: nil)
|
28
|
+
colorized_message = color ? text.colorize(color) : text
|
29
|
+
puts " #{Time.now.strftime("%H:%M:%S").grey} #{colorized_message}"
|
30
|
+
end
|
31
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'cli/ui'
|
2
2
|
|
3
3
|
class KuberKit::UI::Interactive
|
4
|
+
include KuberKit::Import[
|
5
|
+
"tools.logger",
|
6
|
+
]
|
7
|
+
|
4
8
|
class TaskGroup < CLI::UI::SpinGroup
|
5
9
|
end
|
6
10
|
|
@@ -24,6 +28,17 @@ class KuberKit::UI::Interactive
|
|
24
28
|
|
25
29
|
def print_warning(title, text)
|
26
30
|
print_in_frame(title, text, color: :yellow)
|
31
|
+
logger.debug(text)
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_debug(title, text)
|
35
|
+
logger.debug(text)
|
36
|
+
end
|
37
|
+
|
38
|
+
def print_result(message, data = {})
|
39
|
+
print_debug("Result", "---------------------------")
|
40
|
+
print_debug("Result", message)
|
41
|
+
print_debug("Result", "---------------------------")
|
27
42
|
end
|
28
43
|
|
29
44
|
def prompt(text, options, &callback)
|
data/lib/kuber_kit/ui/simple.rb
CHANGED
@@ -1,19 +1,33 @@
|
|
1
1
|
class KuberKit::UI::Simple
|
2
|
+
include KuberKit::Import[
|
3
|
+
"tools.logger",
|
4
|
+
]
|
5
|
+
|
2
6
|
class Task
|
3
7
|
def initialize(title, &callback)
|
4
8
|
@title = title
|
5
9
|
@callback = callback
|
6
10
|
end
|
7
11
|
|
12
|
+
def print_started
|
13
|
+
puts "- #{@title}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def print_finished
|
17
|
+
puts "- #{@title.grey}"
|
18
|
+
end
|
19
|
+
|
8
20
|
def execute
|
9
21
|
if @thread
|
10
22
|
raise "Already started execution of task '#{title}'"
|
11
23
|
end
|
12
24
|
|
13
25
|
@thread = Thread.new do
|
14
|
-
|
26
|
+
Thread.current.abort_on_exception = true
|
27
|
+
Thread.current.report_on_exception = false
|
28
|
+
print_started
|
15
29
|
@callback.call(self)
|
16
|
-
|
30
|
+
print_finished
|
17
31
|
end
|
18
32
|
end
|
19
33
|
|
@@ -30,8 +44,12 @@ class KuberKit::UI::Simple
|
|
30
44
|
end
|
31
45
|
|
32
46
|
class TaskGroup
|
47
|
+
def initialize(task_class)
|
48
|
+
@task_class = task_class
|
49
|
+
end
|
50
|
+
|
33
51
|
def add(task_title, &task_block)
|
34
|
-
task =
|
52
|
+
task = @task_class.new(task_title, &task_block)
|
35
53
|
task.execute
|
36
54
|
add_task(task)
|
37
55
|
end
|
@@ -47,7 +65,7 @@ class KuberKit::UI::Simple
|
|
47
65
|
end
|
48
66
|
|
49
67
|
def create_task_group
|
50
|
-
TaskGroup.new
|
68
|
+
TaskGroup.new(KuberKit::UI::Simple::Task)
|
51
69
|
end
|
52
70
|
|
53
71
|
def create_task(title, &block)
|
@@ -66,6 +84,17 @@ class KuberKit::UI::Simple
|
|
66
84
|
|
67
85
|
def print_warning(title, text)
|
68
86
|
print_text(title, text, color: String::Colors::YELLOW)
|
87
|
+
logger.debug(text)
|
88
|
+
end
|
89
|
+
|
90
|
+
def print_debug(title, text)
|
91
|
+
logger.debug(text)
|
92
|
+
end
|
93
|
+
|
94
|
+
def print_result(message, data = {})
|
95
|
+
print_debug("Result", "---------------------------")
|
96
|
+
print_debug("Result", message)
|
97
|
+
print_debug("Result", "---------------------------")
|
69
98
|
end
|
70
99
|
|
71
100
|
def prompt(text, options, &callback)
|
@@ -75,7 +104,7 @@ class KuberKit::UI::Simple
|
|
75
104
|
result
|
76
105
|
end
|
77
106
|
|
78
|
-
|
107
|
+
protected
|
79
108
|
def print_text(title, text, color:)
|
80
109
|
puts "#{title.colorize(color)}\r\n #{text.colorize(color)}"
|
81
110
|
end
|
data/lib/kuber_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuber_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- example/infrastructure/registries.rb
|
184
184
|
- example/infrastructure/templates.rb
|
185
185
|
- example/services/compose_app.rb
|
186
|
+
- example/services/docker_app.rb
|
186
187
|
- example/services/env_file.rb
|
187
188
|
- example/services/ruby_app.rb
|
188
189
|
- kuber_kit.gemspec
|
@@ -287,6 +288,8 @@ files:
|
|
287
288
|
- lib/kuber_kit/tools/file_presence_checker.rb
|
288
289
|
- lib/kuber_kit/tools/logger_factory.rb
|
289
290
|
- lib/kuber_kit/ui.rb
|
291
|
+
- lib/kuber_kit/ui/api.rb
|
292
|
+
- lib/kuber_kit/ui/debug.rb
|
290
293
|
- lib/kuber_kit/ui/interactive.rb
|
291
294
|
- lib/kuber_kit/ui/simple.rb
|
292
295
|
- lib/kuber_kit/version.rb
|
@@ -294,7 +297,7 @@ homepage: https://github.com/ArtStation/kuber_kit
|
|
294
297
|
licenses:
|
295
298
|
- MIT
|
296
299
|
metadata: {}
|
297
|
-
post_install_message:
|
300
|
+
post_install_message:
|
298
301
|
rdoc_options: []
|
299
302
|
require_paths:
|
300
303
|
- lib
|
@@ -309,8 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
312
|
- !ruby/object:Gem::Version
|
310
313
|
version: '0'
|
311
314
|
requirements: []
|
312
|
-
rubygems_version: 3.0.
|
313
|
-
signing_key:
|
315
|
+
rubygems_version: 3.0.8
|
316
|
+
signing_key:
|
314
317
|
specification_version: 4
|
315
318
|
summary: Docker Containers Build & Deployment
|
316
319
|
test_files: []
|