kuber_kit 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -2
  3. data/README.md +16 -3
  4. data/TODO.md +5 -4
  5. data/example/app_data/env_file.yml +10 -0
  6. data/example/configurations/review.rb +2 -1
  7. data/example/images/app_sources/Dockerfile +1 -1
  8. data/example/images/ruby_app/image.rb +4 -4
  9. data/example/infrastructure/build_servers.rb +8 -0
  10. data/example/infrastructure/templates.rb +5 -0
  11. data/example/services/env_file.rb +6 -0
  12. data/kuber_kit.gemspec +1 -0
  13. data/lib/kuber_kit.rb +51 -23
  14. data/lib/kuber_kit/actions/configuration_loader.rb +11 -2
  15. data/lib/kuber_kit/actions/env_file_reader.rb +8 -5
  16. data/lib/kuber_kit/actions/image_compiler.rb +18 -22
  17. data/lib/kuber_kit/actions/kubectl_applier.rb +6 -1
  18. data/lib/kuber_kit/actions/kubectl_attacher.rb +19 -0
  19. data/lib/kuber_kit/actions/service_deployer.rb +13 -3
  20. data/lib/kuber_kit/actions/service_reader.rb +9 -6
  21. data/lib/kuber_kit/actions/template_reader.rb +5 -0
  22. data/lib/kuber_kit/cli.rb +51 -20
  23. data/lib/kuber_kit/configs.rb +24 -22
  24. data/lib/kuber_kit/container.rb +43 -19
  25. data/lib/kuber_kit/core/artifacts/artifact_store.rb +12 -23
  26. data/lib/kuber_kit/core/build_servers/abstract_build_server.rb +21 -0
  27. data/lib/kuber_kit/core/build_servers/build_server.rb +24 -0
  28. data/lib/kuber_kit/core/build_servers/build_server_store.rb +18 -0
  29. data/lib/kuber_kit/core/configuration.rb +14 -4
  30. data/lib/kuber_kit/core/configuration_definition.rb +22 -1
  31. data/lib/kuber_kit/core/configuration_factory.rb +11 -1
  32. data/lib/kuber_kit/core/configuration_store.rb +14 -24
  33. data/lib/kuber_kit/core/context_helper/base_helper.rb +12 -7
  34. data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +11 -8
  35. data/lib/kuber_kit/core/context_helper/service_helper.rb +7 -6
  36. data/lib/kuber_kit/core/env_files/env_file_store.rb +8 -23
  37. data/lib/kuber_kit/core/image_store.rb +8 -18
  38. data/lib/kuber_kit/core/registries/registry_store.rb +8 -23
  39. data/lib/kuber_kit/core/service.rb +6 -2
  40. data/lib/kuber_kit/core/service_factory.rb +4 -1
  41. data/lib/kuber_kit/core/service_store.rb +13 -23
  42. data/lib/kuber_kit/core/store.rb +48 -0
  43. data/lib/kuber_kit/core/templates/template_store.rb +12 -23
  44. data/lib/kuber_kit/env_file_reader/action_handler.rb +12 -0
  45. data/lib/kuber_kit/env_file_reader/reader.rb +4 -4
  46. data/lib/kuber_kit/env_file_reader/{abstract_env_file_reader.rb → strategies/abstract.rb} +1 -1
  47. data/lib/kuber_kit/env_file_reader/{artifact_file_reader.rb → strategies/artifact_file.rb} +1 -1
  48. data/lib/kuber_kit/image_compiler/action_handler.rb +21 -0
  49. data/lib/kuber_kit/image_compiler/build_server_pool.rb +30 -0
  50. data/lib/kuber_kit/image_compiler/build_server_pool_factory.rb +13 -0
  51. data/lib/kuber_kit/image_compiler/compiler.rb +2 -5
  52. data/lib/kuber_kit/image_compiler/image_build_dir_creator.rb +13 -7
  53. data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +25 -5
  54. data/lib/kuber_kit/preprocessing/file_preprocessor.rb +5 -4
  55. data/lib/kuber_kit/preprocessing/text_preprocessor.rb +1 -1
  56. data/lib/kuber_kit/service_deployer/action_handler.rb +16 -0
  57. data/lib/kuber_kit/service_deployer/deployer.rb +28 -6
  58. data/lib/kuber_kit/service_deployer/strategies/abstract.rb +1 -1
  59. data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +9 -4
  60. data/lib/kuber_kit/service_deployer/strategy_detector.rb +6 -0
  61. data/lib/kuber_kit/service_reader/action_handler.rb +13 -0
  62. data/lib/kuber_kit/{service_deployer/service_reader.rb → service_reader/reader.rb} +1 -1
  63. data/lib/kuber_kit/shell/abstract_shell.rb +4 -0
  64. data/lib/kuber_kit/shell/{bash_commands.rb → commands/bash_commands.rb} +1 -1
  65. data/lib/kuber_kit/shell/{docker_commands.rb → commands/docker_commands.rb} +1 -1
  66. data/lib/kuber_kit/shell/{git_commands.rb → commands/git_commands.rb} +1 -1
  67. data/lib/kuber_kit/shell/{kubectl_commands.rb → commands/kubectl_commands.rb} +25 -1
  68. data/lib/kuber_kit/shell/commands/rsync_commands.rb +32 -0
  69. data/lib/kuber_kit/shell/local_shell.rb +24 -5
  70. data/lib/kuber_kit/shell/ssh_session.rb +60 -0
  71. data/lib/kuber_kit/shell/ssh_shell.rb +77 -0
  72. data/lib/kuber_kit/tools/file_presence_checker.rb +6 -2
  73. data/lib/kuber_kit/ui/interactive.rb +8 -0
  74. data/lib/kuber_kit/ui/simple.rb +6 -0
  75. data/lib/kuber_kit/version.rb +2 -2
  76. metadata +41 -13
  77. data/lib/kuber_kit/preprocessing/dir_preprocessor.rb +0 -19
  78. data/lib/kuber_kit/service_deployer/service_restarter.rb +0 -37
  79. data/lib/kuber_kit/shell/rsync_commands.rb +0 -20
  80. data/lib/kuber_kit/tools/files_sync.rb +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5df957bf6c31a193caef5d2fc163be4d925ba6dc3bd61f2d98c47f0eee2bb42
4
- data.tar.gz: 701748c782360287b41acd34dcd33a3c8d9192a2ba91685a5355dddbe4b19789
3
+ metadata.gz: 3f53003404cfe3339fb14d864f9b217dd93332d1c0d451ff34909a3a7224e2ab
4
+ data.tar.gz: c603662e4f86eebe2d0b4fa114576cef1518b4ce7c879c46a3bca8753f37eed9
5
5
  SHA512:
6
- metadata.gz: f4d10fbac924851b0552f1b833e8080203277245055717a5a7592437284eb9a5cd0535c369764ca474bc7a09686517254423fec45aeb2ccd8568d22c1851cf63
7
- data.tar.gz: 1972b5f5cdd6cb8e8b1f33ae210ac783f3ff55e1c36f6304c933c2a43b3b335ff40b9400fd725be957227b3ed8160327d8d19f0352abf9b9596e4f0b0855716d
6
+ metadata.gz: 6cc09c80cd1506066efc6ddb86b0bc01d7767fadaeab87fc5d7ca7275034505420d09c45f08566e42afe7e4bee0e89f16c298f8d3ee1010aef03c898b8c5de29
7
+ data.tar.gz: 89276b25a1de67c89386c86f584c558e4becb0ae100ae8a9f34bc230be6d81a9f1948965a5aa148173d005922757de8598ef7306561a4547700433b5cbc7ca08
@@ -1,16 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.1.5)
4
+ kuber_kit (0.2.0)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
8
+ net-ssh
8
9
  thor
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- cli-ui (1.3.0)
14
+ cli-ui (1.4.0)
14
15
  coderay (1.1.3)
15
16
  concurrent-ruby (1.1.7)
16
17
  contracts-lite (0.15.0)
@@ -29,6 +30,7 @@ GEM
29
30
  concurrent-ruby (~> 1.0)
30
31
  dry-equalizer (0.3.0)
31
32
  method_source (1.0.0)
33
+ net-ssh (6.1.0)
32
34
  pry (0.13.1)
33
35
  coderay (~> 1.1)
34
36
  method_source (~> 1.0)
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Docker Kit
1
+ # KuberKit
2
+
3
+ [![Codeship Status for ArtStation/kuber_kit](https://app.codeship.com/projects/1286f0a6-3f90-4c1b-b426-721ed8a6571b/status?branch=master)](https://app.codeship.com/projects/417264)
4
+
5
+ Solution for building & deploying applications on Kubernetes, written in Ruby.
2
6
 
3
7
  ## Installation
4
8
 
@@ -8,12 +12,21 @@ Add this line to your application's Gemfile:
8
12
  gem 'kuber_kit'
9
13
  ```
10
14
 
11
- ## Launch compilation for example images
15
+ ## Development
16
+
17
+ ### Launch compilation
18
+
19
+ ```
20
+ bin/kit compile ruby_app,ruby_app2 --path=./example
21
+ ```
22
+
23
+ ### Launch deployment
12
24
 
13
25
  ```
14
- bin/kit compile ruby_app,ruby_app2 --path=./example -C review
26
+ bin/kit compile -s ruby_app,ruby_app2 --path=./example
15
27
  ```
16
28
 
29
+
17
30
  ## License
18
31
 
19
32
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/TODO.md CHANGED
@@ -1,4 +1,5 @@
1
- - rename service reader to service config reader
2
- - service factory should make sure that template exists
3
- - add build servers support
4
- - add build vars support (use images instead of containers)
1
+ - implement interactive shell.exec!
2
+ - list services and require confirmation before deployment
3
+ - add build vars support (use images instead of containers)
4
+ - template should be able to set default attributes
5
+ - template should be able to depend on image?
@@ -0,0 +1,10 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Secret
4
+ metadata:
5
+ name: env-secret-review
6
+ type: Opaque
7
+ stringData:
8
+ <% env_file(:test).each do |key, value| -%>
9
+ <%= key %>: "<%= value %>"
10
+ <% end -%>
@@ -1,4 +1,5 @@
1
1
  KuberKit
2
2
  .define_configuration(:review)
3
3
  .use_registry(:review_default, as: :default)
4
- .use_artifact(:kuber_kit_repo, as: :kuber_kit_repo)
4
+ .use_artifact(:kuber_kit_repo, as: :kuber_kit_repo)
5
+ .use_build_server(:remote_bs)
@@ -1,4 +1,4 @@
1
- FROM default/ruby
1
+ FROM <%= image_url(:ruby) %>
2
2
 
3
3
  RUN mkdir -p /app
4
4
  WORKDIR /app
@@ -3,13 +3,13 @@ KuberKit
3
3
  .registry(:default)
4
4
  .depends_on(:ruby, :app_sources)
5
5
  .before_build do |context_helper, build_dir|
6
- # copy file local artifact
6
+ # copy file: local artifact
7
7
  source_path = context_helper.artifact_path(:kuber_kit_example_data, "test.txt")
8
8
  target_path = File.join(build_dir, "test.txt")
9
- context_helper.shell.exec!("cp #{source_path} #{target_path}")
9
+ context_helper.shell.sync(source_path, target_path)
10
10
 
11
- # copy file local artifact
11
+ # copy file: remote artifact
12
12
  source_path = context_helper.artifact_path(:kuber_kit_repo, "README.md")
13
13
  target_path = File.join(build_dir, "README.md")
14
- context_helper.shell.exec!("cp #{source_path} #{target_path}")
14
+ context_helper.shell.sync(source_path, target_path)
15
15
  end
@@ -0,0 +1,8 @@
1
+ ENV['SSH_TEST_HOST'] ||= "indocker.artstn.ninja"
2
+ ENV['SSH_TEST_USER'] ||= "kuber_kit"
3
+
4
+ KuberKit.add_build_server(
5
+ KuberKit::Core::BuildServers::BuildServer
6
+ .new(:remote_bs)
7
+ .setup(host: ENV['SSH_TEST_HOST'], user: ENV['SSH_TEST_USER'], port: 22)
8
+ )
@@ -1,4 +1,9 @@
1
1
  KuberKit.add_template(
2
2
  KuberKit::Core::Templates::ArtifactFile
3
3
  .new(:service, artifact_name: :kuber_kit_example_data, file_path: "service.yml")
4
+ )
5
+
6
+ KuberKit.add_template(
7
+ KuberKit::Core::Templates::ArtifactFile
8
+ .new(:env_file, artifact_name: :kuber_kit_example_data, file_path: "env_file.yml")
4
9
  )
@@ -0,0 +1,6 @@
1
+ KuberKit
2
+ .define_service(:env_file)
3
+ .template(:env_file)
4
+ .attributes(
5
+ deployment_restart_enabled: false
6
+ )
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "dry-auto_inject"
28
28
  spec.add_dependency "thor"
29
29
  spec.add_dependency "cli-ui"
30
+ spec.add_dependency "net-ssh"
30
31
 
31
32
  spec.add_development_dependency "bundler", "~> 1.17"
32
33
  spec.add_development_dependency "rake", "~> 10.0"
@@ -31,18 +31,7 @@ module KuberKit
31
31
  autoload :ConfigurationFactory, 'core/configuration_factory'
32
32
  autoload :Configuration, 'core/configuration'
33
33
 
34
- module ContextHelper
35
- autoload :BaseHelper, 'core/context_helper/base_helper'
36
- autoload :ImageHelper, 'core/context_helper/image_helper'
37
- autoload :ServiceHelper, 'core/context_helper/service_helper'
38
- autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
39
- end
40
-
41
- module Registries
42
- autoload :AbstractRegistry, 'core/registries/abstract_registry'
43
- autoload :RegistryStore, 'core/registries/registry_store'
44
- autoload :Registry, 'core/registries/registry'
45
- end
34
+ autoload :Store, 'core/store'
46
35
 
47
36
  module Artifacts
48
37
  autoload :AbstractArtifact, 'core/artifacts/abstract_artifact'
@@ -51,12 +40,31 @@ module KuberKit
51
40
  autoload :Local, 'core/artifacts/local'
52
41
  end
53
42
 
43
+ module BuildServers
44
+ autoload :AbstractBuildServer, 'core/build_servers/abstract_build_server'
45
+ autoload :BuildServerStore, 'core/build_servers/build_server_store'
46
+ autoload :BuildServer, 'core/build_servers/build_server'
47
+ end
48
+
54
49
  module EnvFiles
55
50
  autoload :EnvFileStore, 'core/env_files/env_file_store'
56
51
  autoload :AbstractEnvFile, 'core/env_files/abstract_env_file'
57
52
  autoload :ArtifactFile, 'core/env_files/artifact_file'
58
53
  end
59
54
 
55
+ module ContextHelper
56
+ autoload :BaseHelper, 'core/context_helper/base_helper'
57
+ autoload :ImageHelper, 'core/context_helper/image_helper'
58
+ autoload :ServiceHelper, 'core/context_helper/service_helper'
59
+ autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
60
+ end
61
+
62
+ module Registries
63
+ autoload :AbstractRegistry, 'core/registries/abstract_registry'
64
+ autoload :RegistryStore, 'core/registries/registry_store'
65
+ autoload :Registry, 'core/registries/registry'
66
+ end
67
+
60
68
  module Templates
61
69
  autoload :TemplateStore, 'core/templates/template_store'
62
70
  autoload :AbstractTemplate, 'core/templates/abstract_template'
@@ -67,21 +75,28 @@ module KuberKit
67
75
  module Tools
68
76
  autoload :FilePresenceChecker, 'tools/file_presence_checker'
69
77
  autoload :LoggerFactory, 'tools/logger_factory'
70
- autoload :FilesSync, 'tools/files_sync'
71
78
  end
72
79
 
73
80
  module Shell
74
81
  autoload :AbstractShell, 'shell/abstract_shell'
75
82
  autoload :LocalShell, 'shell/local_shell'
83
+ autoload :SshShell, 'shell/ssh_shell'
84
+ autoload :SshSession, 'shell/ssh_session'
76
85
  autoload :CommandCounter, 'shell/command_counter'
77
- autoload :BashCommands, 'shell/bash_commands'
78
- autoload :DockerCommands, 'shell/docker_commands'
79
- autoload :GitCommands, 'shell/git_commands'
80
- autoload :RsyncCommands, 'shell/rsync_commands'
81
- autoload :KubectlCommands, 'shell/kubectl_commands'
86
+
87
+ module Commands
88
+ autoload :BashCommands, 'shell/commands/bash_commands'
89
+ autoload :DockerCommands, 'shell/commands/docker_commands'
90
+ autoload :GitCommands, 'shell/commands/git_commands'
91
+ autoload :RsyncCommands, 'shell/commands/rsync_commands'
92
+ autoload :KubectlCommands, 'shell/commands/kubectl_commands'
93
+ end
82
94
  end
83
95
 
84
96
  module ImageCompiler
97
+ autoload :ActionHandler, 'image_compiler/action_handler'
98
+ autoload :BuildServerPool, 'image_compiler/build_server_pool'
99
+ autoload :BuildServerPoolFactory, 'image_compiler/build_server_pool_factory'
85
100
  autoload :Compiler, 'image_compiler/compiler'
86
101
  autoload :ImageBuilder, 'image_compiler/image_builder'
87
102
  autoload :ImageBuildDirCreator, 'image_compiler/image_build_dir_creator'
@@ -92,7 +107,6 @@ module KuberKit
92
107
  module Preprocessing
93
108
  autoload :TextPreprocessor, 'preprocessing/text_preprocessor'
94
109
  autoload :FilePreprocessor, 'preprocessing/file_preprocessor'
95
- autoload :DirPreprocessor, 'preprocessing/dir_preprocessor'
96
110
  end
97
111
 
98
112
  module ArtifactsSync
@@ -103,9 +117,13 @@ module KuberKit
103
117
  end
104
118
 
105
119
  module EnvFileReader
120
+ autoload :ActionHandler, 'env_file_reader/action_handler'
106
121
  autoload :Reader, 'env_file_reader/reader'
107
- autoload :AbstractEnvFileReader, 'env_file_reader/abstract_env_file_reader'
108
- autoload :ArtifactFileReader, 'env_file_reader/artifact_file_reader'
122
+
123
+ module Strategies
124
+ autoload :Abstract, 'env_file_reader/strategies/abstract'
125
+ autoload :ArtifactFile, 'env_file_reader/strategies/artifact_file'
126
+ end
109
127
  end
110
128
 
111
129
  module TemplateReader
@@ -115,9 +133,9 @@ module KuberKit
115
133
  end
116
134
 
117
135
  module ServiceDeployer
136
+ autoload :ActionHandler, 'service_deployer/action_handler'
137
+ autoload :StrategyDetector, 'service_deployer/strategy_detector'
118
138
  autoload :Deployer, 'service_deployer/deployer'
119
- autoload :ServiceRestarter, 'service_deployer/service_restarter'
120
- autoload :ServiceReader, 'service_deployer/service_reader'
121
139
  autoload :ServiceListResolver, 'service_deployer/service_list_resolver'
122
140
 
123
141
  module Strategies
@@ -126,6 +144,11 @@ module KuberKit
126
144
  end
127
145
  end
128
146
 
147
+ module ServiceReader
148
+ autoload :ActionHandler, 'service_reader/action_handler'
149
+ autoload :Reader, 'service_reader/reader'
150
+ end
151
+
129
152
  module Actions
130
153
  autoload :ImageCompiler, 'actions/image_compiler'
131
154
  autoload :EnvFileReader, 'actions/env_file_reader'
@@ -134,6 +157,7 @@ module KuberKit
134
157
  autoload :ServiceDeployer, 'actions/service_deployer'
135
158
  autoload :ConfigurationLoader, 'actions/configuration_loader'
136
159
  autoload :KubectlApplier, 'actions/kubectl_applier'
160
+ autoload :KubectlAttacher, 'actions/kubectl_attacher'
137
161
  end
138
162
 
139
163
  module Extensions
@@ -202,6 +226,10 @@ module KuberKit
202
226
  Container["core.template_store"].add(template)
203
227
  end
204
228
 
229
+ def add_build_server(build_server)
230
+ Container["core.build_server_store"].add(build_server)
231
+ end
232
+
205
233
  def build_helper(&proc)
206
234
  KuberKit::Core::ContextHelper::BaseHelper.class_exec(&proc)
207
235
  end
@@ -50,6 +50,11 @@ class KuberKit::Actions::ConfigurationLoader
50
50
  files = service_store.load_definitions(services_path)
51
51
  task.update_title("Loaded #{files.count} service definitions")
52
52
  end
53
+
54
+ true
55
+ rescue KuberKit::Error => e
56
+ ui.print_error("Error", e.message)
57
+ false
53
58
  end
54
59
 
55
60
  def load_configurations(configurations_path, configuration_name)
@@ -60,13 +65,17 @@ class KuberKit::Actions::ConfigurationLoader
60
65
  configuration_name ||= :_default_
61
66
  end
62
67
 
68
+ all_configurations = configuration_store.all_definitions.values
63
69
  if configuration_store.count == 1 && configuration_name.nil?
64
- first_configurations = configuration_store.all_definitions.values.first
70
+ first_configurations = all_configurations.first
65
71
  configuration_name = first_configurations.configuration_name
66
72
  end
67
73
 
68
74
  if configuration_store.count > 1 && configuration_name.nil?
69
- raise KuberKit::Error, "Please set configuration name using -C option"
75
+ options = all_configurations.map(&:configuration_name).map(&:to_s)
76
+ ui.prompt("Please select configuration name (or set it using -C option)", options) do |selection|
77
+ configuration_name = selection
78
+ end
70
79
  end
71
80
 
72
81
  KuberKit.set_configuration_name(configuration_name)
@@ -2,16 +2,19 @@ require 'json'
2
2
 
3
3
  class KuberKit::Actions::EnvFileReader
4
4
  include KuberKit::Import[
5
- "core.env_file_store",
6
- "env_file_reader.reader",
7
5
  "shell.local_shell",
8
- "ui"
6
+ "ui",
7
+ env_file_reader: "env_file_reader.action_handler",
9
8
  ]
10
9
 
11
10
  Contract Symbol, Hash => Any
12
11
  def call(env_file_name, options)
13
- env_file = env_file_store.get(env_file_name)
14
- result = reader.read(local_shell, env_file)
12
+ result = env_file_reader.call(local_shell, env_file_name)
15
13
  ui.print_info(env_file_name.to_s, JSON.pretty_generate(result))
14
+
15
+ true
16
+ rescue KuberKit::Error => e
17
+ ui.print_error("Error", e.message)
18
+ false
16
19
  end
17
20
  end
@@ -1,37 +1,42 @@
1
1
  class KuberKit::Actions::ImageCompiler
2
2
  include KuberKit::Import[
3
- "image_compiler.compiler",
4
3
  "image_compiler.image_dependency_resolver",
4
+ "image_compiler.build_server_pool_factory",
5
5
  "shell.local_shell",
6
6
  "tools.logger",
7
- "configs",
8
- "ui"
7
+ "ui",
8
+ image_compiler: "image_compiler.action_handler",
9
9
  ]
10
10
 
11
11
  Contract ArrayOf[Symbol], Hash => Any
12
12
  def call(image_names, options)
13
13
  build_id = generate_build_id
14
+ build_server_pool = build_server_pool_factory.create()
14
15
 
15
- resolved_dependencies = []
16
- dependencies = image_dependency_resolver.get_next(image_names)
17
-
18
- while (dependencies - resolved_dependencies).any?
19
- compile_simultaneously(dependencies, build_id)
20
- resolved_dependencies += dependencies
21
- dependencies = image_dependency_resolver.get_next(image_names, resolved: resolved_dependencies)
16
+ image_dependency_resolver.each_with_deps(image_names) do |dep_image_names|
17
+ result = compile_simultaneously(dep_image_names, build_id, build_server_pool)
18
+ abort unless result
22
19
  end
23
20
 
24
- compile_simultaneously(image_names - resolved_dependencies, build_id)
21
+ build_server_pool.disconnect_all
22
+
23
+ true
24
+ rescue KuberKit::Error => e
25
+ ui.print_error("Error", e.message)
26
+
27
+ false
25
28
  end
26
29
 
27
30
  private
28
- def compile_simultaneously(image_names, build_id)
31
+ def compile_simultaneously(image_names, build_id, build_server_pool)
29
32
  task_group = ui.create_task_group
30
33
  image_names.map do |image_name|
31
34
 
32
35
  logger.info("Started compiling: #{image_name.to_s.green}")
33
36
  task_group.add("Compiling #{image_name.to_s.yellow}") do |task|
34
- compile_image(image_name, build_id)
37
+ shell = build_server_pool.get_shell
38
+
39
+ image_compiler.call(shell, image_name, build_id)
35
40
 
36
41
  task.update_title("Compiled #{image_name.to_s.green}")
37
42
  logger.info("Finished compiling: #{image_name.to_s.green}")
@@ -41,16 +46,7 @@ class KuberKit::Actions::ImageCompiler
41
46
  task_group.wait
42
47
  end
43
48
 
44
- def compile_image(image_name, build_id)
45
- compile_dir = generate_compile_dir(build_id: build_id)
46
- compiler.compile(local_shell, image_name, compile_dir)
47
- end
48
-
49
49
  def generate_build_id
50
50
  Time.now.strftime("%H%M%S")
51
51
  end
52
-
53
- def generate_compile_dir(build_id:)
54
- File.join(configs.image_compile_dir, build_id)
55
- end
56
52
  end