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
@@ -12,6 +12,11 @@ class KuberKit::Actions::KubectlApplier
12
12
  kubectl_commands.apply_file(local_shell, file_path, kubeconfig_path: kubeconfig_path)
13
13
  task.update_title("Applied file: #{file_path}")
14
14
  end
15
- nil
15
+
16
+ true
17
+ rescue KuberKit::Error => e
18
+ ui.print_error("Error", e.message)
19
+
20
+ false
16
21
  end
17
22
  end
@@ -0,0 +1,19 @@
1
+ class KuberKit::Actions::KubectlAttacher
2
+ include KuberKit::Import[
3
+ "shell.kubectl_commands",
4
+ "shell.local_shell",
5
+ "ui"
6
+ ]
7
+
8
+ Contract String, Hash => Any
9
+ def call(pod_name, options)
10
+ kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
11
+ kubectl_commands.exec(local_shell, pod_name, "bash", args: "-it", kubeconfig_path: kubeconfig_path, interactive: true)
12
+
13
+ true
14
+ rescue KuberKit::Error => e
15
+ ui.print_error("Error", e.message)
16
+
17
+ false
18
+ end
19
+ end
@@ -2,11 +2,11 @@ class KuberKit::Actions::ServiceDeployer
2
2
  include KuberKit::Import[
3
3
  "actions.image_compiler",
4
4
  "service_deployer.service_list_resolver",
5
- "service_deployer.deployer",
6
5
  "core.service_store",
7
6
  "shell.local_shell",
8
7
  "tools.logger",
9
- "ui"
8
+ "ui",
9
+ service_deployer: "service_deployer.action_handler",
10
10
  ]
11
11
 
12
12
  Contract KeywordArgs[
@@ -19,6 +19,10 @@ class KuberKit::Actions::ServiceDeployer
19
19
  tags: tags || []
20
20
  )
21
21
 
22
+ unless service_names.any?
23
+ ui.print_warning "WARNING", "No service found with given options, nothing will be deployed."
24
+ end
25
+
22
26
  services = service_names.map do |service_name|
23
27
  service_store.get_service(service_name.to_sym)
24
28
  end
@@ -27,6 +31,12 @@ class KuberKit::Actions::ServiceDeployer
27
31
 
28
32
  compile_images(images_names)
29
33
  deploy_services(service_names)
34
+
35
+ true
36
+ rescue KuberKit::Error => e
37
+ ui.print_error("Error", e.message)
38
+
39
+ false
30
40
  end
31
41
 
32
42
  def deploy_services(service_names)
@@ -36,7 +46,7 @@ class KuberKit::Actions::ServiceDeployer
36
46
 
37
47
  logger.info("Started deploying: #{service_name.to_s.green}")
38
48
  task_group.add("Deploying #{service_name.to_s.yellow}") do |task|
39
- deployer.deploy(local_shell, service_name.to_sym)
49
+ service_deployer.call(local_shell, service_name.to_sym)
40
50
 
41
51
  task.update_title("Deployed #{service_name.to_s.green}")
42
52
  logger.info("Finished deploying: #{service_name.to_s.green}")
@@ -1,17 +1,20 @@
1
1
  class KuberKit::Actions::ServiceReader
2
2
  include KuberKit::Import[
3
- "core.service_store",
4
- "service_deployer.service_reader",
5
3
  "shell.local_shell",
6
- "ui"
4
+ "ui",
5
+ service_reader: "service_reader.action_handler",
7
6
  ]
8
7
 
9
8
  Contract Symbol, Hash => Any
10
9
  def call(service_name, options)
11
- service = service_store.get_service(service_name)
12
-
13
- result = service_reader.read(local_shell, service)
10
+ result = service_reader.call(local_shell, service_name)
14
11
 
15
12
  ui.print_info(service_name.to_s, result)
13
+
14
+ true
15
+ rescue KuberKit::Error => e
16
+ ui.print_error("Error", e.message)
17
+
18
+ false
16
19
  end
17
20
  end
@@ -13,5 +13,10 @@ class KuberKit::Actions::TemplateReader
13
13
  result = reader.read(local_shell, template)
14
14
 
15
15
  ui.print_info(template_name.to_s, result)
16
+
17
+ true
18
+ rescue KuberKit::Error => e
19
+ ui.print_error("Error", e.message)
20
+ false
16
21
  end
17
22
  end
@@ -14,56 +14,87 @@ class KuberKit::CLI < Thor
14
14
 
15
15
  image_names = image_names_str.split(",").map(&:strip).map(&:to_sym)
16
16
 
17
- KuberKit::Container['actions.configuration_loader'].call(options)
18
- KuberKit::Container['actions.image_compiler'].call(image_names, options)
17
+ if KuberKit::Container['actions.configuration_loader'].call(options)
18
+ result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
19
+ end
19
20
 
20
21
  logger = KuberKit::Container['tools.logger']
21
- logger.info("---------------------------")
22
- logger.info("Image compilation finished!")
23
- logger.info("---------------------------")
22
+ if result
23
+ logger.info("---------------------------")
24
+ logger.info("Image compilation finished!")
25
+ logger.info("---------------------------")
26
+ else
27
+ logger.info("-------------------------".red)
28
+ logger.info("Image compilation failed!".red)
29
+ logger.info("-------------------------".red)
30
+ end
31
+ end
32
+
33
+ desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
34
+ method_option :services, :type => :array, aliases: ["-s"]
35
+ method_option :tags, :type => :array, aliases: ["-t"]
36
+ def deploy
37
+ KuberKit.set_debug_mode(options[:debug])
38
+
39
+ if KuberKit::Container['actions.configuration_loader'].call(options)
40
+ result = KuberKit::Container['actions.service_deployer'].call(services: options[:services], tags: options[:tags])
41
+ end
42
+
43
+ logger = KuberKit::Container['tools.logger']
44
+ if result
45
+ logger.info("---------------------------")
46
+ logger.info("Service deployment finished!")
47
+ logger.info("---------------------------")
48
+ else
49
+ logger.info("-------------------------".red)
50
+ logger.info("Service deployment failed!".red)
51
+ logger.info("-------------------------".red)
52
+ end
24
53
  end
25
54
 
26
55
  desc "env ENV_FILE_NAME", "Return content of Env File ENV_FILE_NAME"
27
56
  def env(env_file_name)
28
57
  KuberKit.set_debug_mode(options[:debug])
29
58
 
30
- KuberKit::Container['actions.configuration_loader'].call(options)
31
- KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options)
59
+ if KuberKit::Container['actions.configuration_loader'].call(options)
60
+ KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options)
61
+ end
32
62
  end
33
63
 
34
64
  desc "template TEMPLATE_NAME", "Return content of Template TEMPLATE_NAME"
35
65
  def template(template_name)
36
66
  KuberKit.set_debug_mode(options[:debug])
37
67
 
38
- KuberKit::Container['actions.configuration_loader'].call(options)
39
- KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options)
68
+ if KuberKit::Container['actions.configuration_loader'].call(options)
69
+ KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options)
70
+ end
40
71
  end
41
72
 
42
73
  desc "service SERVICE_NAME", "Return content of Service SERVICE_NAME"
43
74
  def service(service_name)
44
75
  KuberKit.set_debug_mode(options[:debug])
45
76
 
46
- KuberKit::Container['actions.configuration_loader'].call(options)
47
- KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options)
77
+ if KuberKit::Container['actions.configuration_loader'].call(options)
78
+ KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options)
79
+ end
48
80
  end
49
81
 
50
82
  desc "apply FILE_PATH", "Apply FILE_PATH with kubectl"
51
83
  def apply(file_path)
52
84
  KuberKit.set_debug_mode(options[:debug])
53
85
 
54
- KuberKit::Container['actions.configuration_loader'].call(options)
55
- KuberKit::Container['actions.kubectl_applier'].call(File.expand_path(file_path), options)
86
+ if KuberKit::Container['actions.configuration_loader'].call(options)
87
+ KuberKit::Container['actions.kubectl_applier'].call(File.expand_path(file_path), options)
88
+ end
56
89
  end
57
90
 
58
- desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
59
- method_option :services, :type => :array, aliases: ["-s"]
60
- method_option :tags, :type => :array, aliases: ["-t"]
61
- def deploy
91
+ desc "attach POD_NAME", "Attach to POD_NAME with kubectl"
92
+ def attach(pod_name)
62
93
  KuberKit.set_debug_mode(options[:debug])
63
94
 
64
- KuberKit::Container['actions.configuration_loader'].call(options)
65
-
66
- KuberKit::Container['actions.service_deployer'].call(services: options[:services], tags: options[:tags])
95
+ if KuberKit::Container['actions.configuration_loader'].call(options)
96
+ KuberKit::Container['actions.kubectl_attacher'].call(pod_name, options)
97
+ end
67
98
  end
68
99
 
69
100
  def self.exit_on_failure?
@@ -14,33 +14,35 @@ class KuberKit::Configs
14
14
  'tmp',
15
15
  'logs'
16
16
  ]
17
- KUBER_KIT_DIRNAME = "kuber_kit".freeze
18
- IMAGES_DIRNAME = "images".freeze
19
- SERVICES_DIRNAME = "services".freeze
20
- INFRA_DIRNAME = "infrastructure".freeze
21
- CONFIGURATIONS_DIRNAME = "configurations".freeze
22
- ARTIFACT_CLONE_DIR = "/tmp/kuber_kit/artifacts"
23
- SERVICE_CONFIG_DIR = "/tmp/kuber_kit/services"
24
- DEPLOY_STRATEGY = :kubernetes
17
+ KUBER_KIT_DIRNAME = "kuber_kit".freeze
18
+ IMAGES_DIRNAME = "images".freeze
19
+ SERVICES_DIRNAME = "services".freeze
20
+ INFRA_DIRNAME = "infrastructure".freeze
21
+ CONFIGURATIONS_DIRNAME = "configurations".freeze
22
+ ARTIFACT_CLONE_DIR = "/tmp/kuber_kit/artifacts"
23
+ SERVICE_CONFIG_DIR = "/tmp/kuber_kit/services"
24
+ DEPLOY_STRATEGY = :kubernetes
25
+ COMPILE_SIMULTANEOUS_LIMIT = 5
25
26
 
26
27
  attr_accessor :image_dockerfile_name, :image_build_context_dir, :image_tag,
27
28
  :docker_ignore_list, :image_compile_dir,
28
29
  :kuber_kit_dirname, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
29
- :artifact_clone_dir, :service_config_dir, :deploy_strategy
30
+ :artifact_clone_dir, :service_config_dir, :deploy_strategy, :compile_simultaneous_limit
30
31
 
31
32
  def initialize
32
- @image_dockerfile_name = IMAGE_DOCKERFILE_NAME
33
- @image_build_context_dir = IMAGE_BUILD_CONTEXT_DIR
34
- @image_tag = IMAGE_TAG
35
- @image_compile_dir = IMAGE_COMPILE_DIR
36
- @docker_ignore_list = DOCKER_IGNORE_LIST
37
- @kuber_kit_dirname = KUBER_KIT_DIRNAME
38
- @images_dirname = IMAGES_DIRNAME
39
- @services_dirname = SERVICES_DIRNAME
40
- @infra_dirname = INFRA_DIRNAME
41
- @configurations_dirname = CONFIGURATIONS_DIRNAME
42
- @artifact_clone_dir = ARTIFACT_CLONE_DIR
43
- @service_config_dir = SERVICE_CONFIG_DIR
44
- @deploy_strategy = DEPLOY_STRATEGY
33
+ @image_dockerfile_name = IMAGE_DOCKERFILE_NAME
34
+ @image_build_context_dir = IMAGE_BUILD_CONTEXT_DIR
35
+ @image_tag = IMAGE_TAG
36
+ @image_compile_dir = IMAGE_COMPILE_DIR
37
+ @docker_ignore_list = DOCKER_IGNORE_LIST
38
+ @kuber_kit_dirname = KUBER_KIT_DIRNAME
39
+ @images_dirname = IMAGES_DIRNAME
40
+ @services_dirname = SERVICES_DIRNAME
41
+ @infra_dirname = INFRA_DIRNAME
42
+ @configurations_dirname = CONFIGURATIONS_DIRNAME
43
+ @artifact_clone_dir = ARTIFACT_CLONE_DIR
44
+ @service_config_dir = SERVICE_CONFIG_DIR
45
+ @deploy_strategy = DEPLOY_STRATEGY
46
+ @compile_simultaneous_limit = COMPILE_SIMULTANEOUS_LIMIT
45
47
  end
46
48
  end
@@ -29,6 +29,10 @@ class KuberKit::Container
29
29
  KuberKit::Actions::KubectlApplier.new
30
30
  end
31
31
 
32
+ register "actions.kubectl_attacher" do
33
+ KuberKit::Actions::KubectlAttacher.new
34
+ end
35
+
32
36
  register "configs" do
33
37
  KuberKit::Configs.new
34
38
  end
@@ -69,18 +73,22 @@ class KuberKit::Container
69
73
  KuberKit::Core::ConfigurationStore.new
70
74
  end
71
75
 
72
- register "core.registry_store" do
73
- KuberKit::Core::Registries::RegistryStore.new
74
- end
75
-
76
76
  register "core.artifact_store" do
77
77
  KuberKit::Core::Artifacts::ArtifactStore.new
78
78
  end
79
79
 
80
+ register "core.build_server_store" do
81
+ KuberKit::Core::BuildServers::BuildServerStore.new
82
+ end
83
+
80
84
  register "core.env_file_store" do
81
85
  KuberKit::Core::EnvFiles::EnvFileStore.new
82
86
  end
83
87
 
88
+ register "core.registry_store" do
89
+ KuberKit::Core::Registries::RegistryStore.new
90
+ end
91
+
84
92
  register "core.template_store" do
85
93
  KuberKit::Core::Templates::TemplateStore.new
86
94
  end
@@ -102,23 +110,23 @@ class KuberKit::Container
102
110
  end
103
111
 
104
112
  register "shell.bash_commands" do
105
- KuberKit::Shell::BashCommands.new
113
+ KuberKit::Shell::Commands::BashCommands.new
106
114
  end
107
115
 
108
116
  register "shell.docker_commands" do
109
- KuberKit::Shell::DockerCommands.new
117
+ KuberKit::Shell::Commands::DockerCommands.new
110
118
  end
111
119
 
112
120
  register "shell.git_commands" do
113
- KuberKit::Shell::GitCommands.new
121
+ KuberKit::Shell::Commands::GitCommands.new
114
122
  end
115
123
 
116
124
  register "shell.rsync_commands" do
117
- KuberKit::Shell::RsyncCommands.new
125
+ KuberKit::Shell::Commands::RsyncCommands.new
118
126
  end
119
127
 
120
128
  register "shell.kubectl_commands" do
121
- KuberKit::Shell::KubectlCommands.new
129
+ KuberKit::Shell::Commands::KubectlCommands.new
122
130
  end
123
131
 
124
132
  register "shell.local_shell" do
@@ -137,8 +145,12 @@ class KuberKit::Container
137
145
  KuberKit::Preprocessing::FilePreprocessor.new
138
146
  end
139
147
 
140
- register "preprocessing.dir_preprocessor" do
141
- KuberKit::Preprocessing::DirPreprocessor.new
148
+ register "image_compiler.action_handler" do
149
+ KuberKit::ImageCompiler::ActionHandler.new
150
+ end
151
+
152
+ register "image_compiler.build_server_pool_factory" do
153
+ KuberKit::ImageCompiler::BuildServerPoolFactory.new
142
154
  end
143
155
 
144
156
  register "image_compiler.compiler" do
@@ -173,12 +185,16 @@ class KuberKit::Container
173
185
  KuberKit::ArtifactsSync::NullArtifactResolver.new
174
186
  end
175
187
 
188
+ register "env_file_reader.action_handler" do
189
+ KuberKit::EnvFileReader::ActionHandler.new
190
+ end
191
+
176
192
  register "env_file_reader.reader" do
177
193
  KuberKit::EnvFileReader::Reader.new
178
194
  end
179
195
 
180
- register "env_file_reader.artifact_file_reader" do
181
- KuberKit::EnvFileReader::ArtifactFileReader.new
196
+ register "env_file_reader.strategies.artifact_file" do
197
+ KuberKit::EnvFileReader::Strategies::ArtifactFile.new
182
198
  end
183
199
 
184
200
  register "template_reader.reader" do
@@ -189,16 +205,16 @@ class KuberKit::Container
189
205
  KuberKit::TemplateReader::ArtifactFileReader.new
190
206
  end
191
207
 
192
- register "service_deployer.deployer" do
193
- KuberKit::ServiceDeployer::Deployer.new
208
+ register "service_deployer.action_handler" do
209
+ KuberKit::ServiceDeployer::ActionHandler.new
194
210
  end
195
211
 
196
- register "service_deployer.service_restarter" do
197
- KuberKit::ServiceDeployer::ServiceRestarter.new
212
+ register "service_deployer.strategy_detector" do
213
+ KuberKit::ServiceDeployer::StrategyDetector.new
198
214
  end
199
215
 
200
- register "service_deployer.service_reader" do
201
- KuberKit::ServiceDeployer::ServiceReader.new
216
+ register "service_deployer.deployer" do
217
+ KuberKit::ServiceDeployer::Deployer.new
202
218
  end
203
219
 
204
220
  register "service_deployer.service_list_resolver" do
@@ -209,6 +225,14 @@ class KuberKit::Container
209
225
  KuberKit::ServiceDeployer::Strategies::Kubernetes.new
210
226
  end
211
227
 
228
+ register "service_reader.action_handler" do
229
+ KuberKit::ServiceReader::ActionHandler.new
230
+ end
231
+
232
+ register "service_reader.reader" do
233
+ KuberKit::ServiceReader::Reader.new
234
+ end
235
+
212
236
  register "ui" do
213
237
  if KuberKit.debug_mode?
214
238
  KuberKit::UI::Simple.new
@@ -1,19 +1,6 @@
1
1
  class KuberKit::Core::Artifacts::ArtifactStore
2
- NotFoundError = Class.new(KuberKit::NotFoundError)
3
- AlreadyAddedError = Class.new(KuberKit::Error)
4
-
5
2
  def add(artifact)
6
- @@artifacts ||= {}
7
-
8
- if !artifact.is_a?(KuberKit::Core::Artifacts::AbstractArtifact)
9
- raise ArgumentError.new("should be an instance of KuberKit::Core::Artifacts::AbstractArtifact, got: #{artifact.inspect}")
10
- end
11
-
12
- unless @@artifacts[artifact.name].nil?
13
- raise AlreadyAddedError, "artifact #{artifact.name} was already added"
14
- end
15
-
16
- @@artifacts[artifact.name] = artifact
3
+ store.add(artifact.name, artifact)
17
4
  end
18
5
 
19
6
  def get(artifact_name)
@@ -24,14 +11,7 @@ class KuberKit::Core::Artifacts::ArtifactStore
24
11
  end
25
12
 
26
13
  def get_global(artifact_name)
27
- @@artifacts ||= {}
28
- artifact = @@artifacts[artifact_name]
29
-
30
- if artifact.nil?
31
- raise NotFoundError, "artifact '#{artifact_name}' not found"
32
- end
33
-
34
- artifact
14
+ store.get(artifact_name)
35
15
  end
36
16
 
37
17
  def get_from_configuration(artifact_name)
@@ -40,6 +20,15 @@ class KuberKit::Core::Artifacts::ArtifactStore
40
20
  end
41
21
 
42
22
  def reset!
43
- @@artifacts = {}
23
+ store.reset!
24
+ end
25
+
26
+ def exists?(artifact_name)
27
+ store.exists?(artifact_name)
44
28
  end
29
+
30
+ private
31
+ def store
32
+ @@store ||= KuberKit::Core::Store.new(KuberKit::Core::Artifacts::AbstractArtifact)
33
+ end
45
34
  end