kuber_kit 0.1.0

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 (118) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -0
  7. data/Gemfile +8 -0
  8. data/Gemfile.lock +67 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +19 -0
  11. data/Rakefile +6 -0
  12. data/TODO.md +2 -0
  13. data/bin/console +14 -0
  14. data/bin/kit +8 -0
  15. data/example/app_data/service.yml +7 -0
  16. data/example/app_data/test.env +2 -0
  17. data/example/app_data/test.txt +1 -0
  18. data/example/configurations/review.rb +4 -0
  19. data/example/images/app_sources/Dockerfile +6 -0
  20. data/example/images/app_sources/build_context/source.rb +2 -0
  21. data/example/images/app_sources/image.rb +4 -0
  22. data/example/images/ruby/Dockerfile +1 -0
  23. data/example/images/ruby/image.rb +3 -0
  24. data/example/images/ruby_app/Dockerfile +11 -0
  25. data/example/images/ruby_app/build_context/example_file.txt +2 -0
  26. data/example/images/ruby_app/image.rb +15 -0
  27. data/example/images/ruby_app2/Dockerfile +8 -0
  28. data/example/images/ruby_app2/build_context/example_file.txt +2 -0
  29. data/example/images/ruby_app2/image.rb +4 -0
  30. data/example/infrastructure/artifacts.rb +13 -0
  31. data/example/infrastructure/env_files.rb +4 -0
  32. data/example/infrastructure/registries.rb +4 -0
  33. data/example/infrastructure/services.rb +3 -0
  34. data/example/infrastructure/templates.rb +4 -0
  35. data/kuber_kit.gemspec +35 -0
  36. data/lib/kuber_kit.rb +205 -0
  37. data/lib/kuber_kit/actions/configuration_loader.rb +74 -0
  38. data/lib/kuber_kit/actions/env_file_reader.rb +17 -0
  39. data/lib/kuber_kit/actions/image_compiler.rb +56 -0
  40. data/lib/kuber_kit/actions/kubectl_applier.rb +17 -0
  41. data/lib/kuber_kit/actions/service_applier.rb +39 -0
  42. data/lib/kuber_kit/actions/service_reader.rb +17 -0
  43. data/lib/kuber_kit/actions/template_reader.rb +17 -0
  44. data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +5 -0
  45. data/lib/kuber_kit/artifacts_sync/artifacts_updater.rb +42 -0
  46. data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +31 -0
  47. data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +7 -0
  48. data/lib/kuber_kit/cli.rb +72 -0
  49. data/lib/kuber_kit/configs.rb +42 -0
  50. data/lib/kuber_kit/container.rb +207 -0
  51. data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +13 -0
  52. data/lib/kuber_kit/core/artifacts/artifact_store.rb +45 -0
  53. data/lib/kuber_kit/core/artifacts/git.rb +22 -0
  54. data/lib/kuber_kit/core/artifacts/local.rb +14 -0
  55. data/lib/kuber_kit/core/configuration.rb +20 -0
  56. data/lib/kuber_kit/core/configuration_definition.rb +67 -0
  57. data/lib/kuber_kit/core/configuration_definition_factory.rb +5 -0
  58. data/lib/kuber_kit/core/configuration_factory.rb +61 -0
  59. data/lib/kuber_kit/core/configuration_store.rb +72 -0
  60. data/lib/kuber_kit/core/context_helper/base_helper.rb +28 -0
  61. data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +23 -0
  62. data/lib/kuber_kit/core/context_helper/image_helper.rb +2 -0
  63. data/lib/kuber_kit/core/context_helper/service_helper.rb +19 -0
  64. data/lib/kuber_kit/core/env_files/abstract_env_file.rb +9 -0
  65. data/lib/kuber_kit/core/env_files/artifact_file.rb +9 -0
  66. data/lib/kuber_kit/core/env_files/env_file_store.rb +45 -0
  67. data/lib/kuber_kit/core/image.rb +39 -0
  68. data/lib/kuber_kit/core/image_definition.rb +85 -0
  69. data/lib/kuber_kit/core/image_definition_factory.rb +5 -0
  70. data/lib/kuber_kit/core/image_factory.rb +40 -0
  71. data/lib/kuber_kit/core/image_store.rb +60 -0
  72. data/lib/kuber_kit/core/registries/abstract_registry.rb +25 -0
  73. data/lib/kuber_kit/core/registries/registry.rb +24 -0
  74. data/lib/kuber_kit/core/registries/registry_store.rb +49 -0
  75. data/lib/kuber_kit/core/service.rb +14 -0
  76. data/lib/kuber_kit/core/service_definition.rb +33 -0
  77. data/lib/kuber_kit/core/service_definition_factory.rb +5 -0
  78. data/lib/kuber_kit/core/service_factory.rb +17 -0
  79. data/lib/kuber_kit/core/service_store.rb +68 -0
  80. data/lib/kuber_kit/core/templates/abstract_template.rb +9 -0
  81. data/lib/kuber_kit/core/templates/artifact_file.rb +9 -0
  82. data/lib/kuber_kit/core/templates/template_store.rb +45 -0
  83. data/lib/kuber_kit/env_file_reader/abstract_env_file_reader.rb +5 -0
  84. data/lib/kuber_kit/env_file_reader/artifact_file_reader.rb +86 -0
  85. data/lib/kuber_kit/env_file_reader/reader.rb +35 -0
  86. data/lib/kuber_kit/extensions/colored_string.rb +43 -0
  87. data/lib/kuber_kit/extensions/contracts.rb +4 -0
  88. data/lib/kuber_kit/extensions/indocker_compat.rb +19 -0
  89. data/lib/kuber_kit/extensions/inspectable.rb +10 -0
  90. data/lib/kuber_kit/image_compiler/compiler.rb +21 -0
  91. data/lib/kuber_kit/image_compiler/image_build_dir_creator.rb +37 -0
  92. data/lib/kuber_kit/image_compiler/image_builder.rb +26 -0
  93. data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +40 -0
  94. data/lib/kuber_kit/image_compiler/version_tag_builder.rb +5 -0
  95. data/lib/kuber_kit/preprocessing/dir_preprocessor.rb +19 -0
  96. data/lib/kuber_kit/preprocessing/file_preprocessor.rb +33 -0
  97. data/lib/kuber_kit/preprocessing/text_preprocessor.rb +7 -0
  98. data/lib/kuber_kit/service_deployer/service_list_resolver.rb +56 -0
  99. data/lib/kuber_kit/service_deployer/service_reader.rb +20 -0
  100. data/lib/kuber_kit/shell/abstract_shell.rb +20 -0
  101. data/lib/kuber_kit/shell/bash_commands.rb +25 -0
  102. data/lib/kuber_kit/shell/command_counter.rb +19 -0
  103. data/lib/kuber_kit/shell/docker_commands.rb +16 -0
  104. data/lib/kuber_kit/shell/git_commands.rb +28 -0
  105. data/lib/kuber_kit/shell/kubectl_commands.rb +12 -0
  106. data/lib/kuber_kit/shell/local_shell.rb +64 -0
  107. data/lib/kuber_kit/shell/rsync_commands.rb +20 -0
  108. data/lib/kuber_kit/template_reader/abstract_template_reader.rb +5 -0
  109. data/lib/kuber_kit/template_reader/artifact_file_reader.rb +14 -0
  110. data/lib/kuber_kit/template_reader/reader.rb +35 -0
  111. data/lib/kuber_kit/tools/file_presence_checker.rb +25 -0
  112. data/lib/kuber_kit/tools/files_sync.rb +10 -0
  113. data/lib/kuber_kit/tools/logger_factory.rb +34 -0
  114. data/lib/kuber_kit/ui.rb +18 -0
  115. data/lib/kuber_kit/ui/interactive.rb +44 -0
  116. data/lib/kuber_kit/ui/simple.rb +75 -0
  117. data/lib/kuber_kit/version.rb +3 -0
  118. metadata +273 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a9ac91299a59af0f2eec1d7382f3b55f0946931e1d4f87de909d76631242f441
4
+ data.tar.gz: d0737d6d217a9c4107fb77536fd36e2c3d59e71adb9dd8c68b6dbc2c12e2eb8f
5
+ SHA512:
6
+ metadata.gz: d9feedc39ab9959d1a3e4bd38a5b6703f6d93f16d03bbd4805732166266e64c4dc9798d6e5d173de2e5058f1ccfc8ad86143c793916efd9936768279eedff14f
7
+ data.tar.gz: a9bf6386c3bac7c75c894f82464af2e9e83dd94e56dec4be9da87fd092c81e9cbff568c4432921ff601c11831127f497651beb835d21edc8379675dffc6c0e1a
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ kuber-kit
@@ -0,0 +1 @@
1
+ 2.5.8
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.8
7
+ before_install: gem install bundler -v 1.17.3
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in kuber_kit.gemspec
6
+ gemspec
7
+
8
+ gem 'simplecov', require: false, group: :test
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kuber_kit (0.1.0)
5
+ cli-ui
6
+ contracts-lite
7
+ dry-auto_inject
8
+ thor
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ cli-ui (1.3.0)
14
+ coderay (1.1.3)
15
+ concurrent-ruby (1.1.7)
16
+ contracts-lite (0.15.0)
17
+ diff-lcs (1.4.4)
18
+ docile (1.3.2)
19
+ dry-auto_inject (0.7.0)
20
+ dry-container (>= 0.3.4)
21
+ dry-configurable (0.11.6)
22
+ concurrent-ruby (~> 1.0)
23
+ dry-core (~> 0.4, >= 0.4.7)
24
+ dry-equalizer (~> 0.2)
25
+ dry-container (0.7.2)
26
+ concurrent-ruby (~> 1.0)
27
+ dry-configurable (~> 0.1, >= 0.1.3)
28
+ dry-core (0.4.9)
29
+ concurrent-ruby (~> 1.0)
30
+ dry-equalizer (0.3.0)
31
+ method_source (1.0.0)
32
+ pry (0.13.1)
33
+ coderay (~> 1.1)
34
+ method_source (~> 1.0)
35
+ rake (10.5.0)
36
+ rspec (3.9.0)
37
+ rspec-core (~> 3.9.0)
38
+ rspec-expectations (~> 3.9.0)
39
+ rspec-mocks (~> 3.9.0)
40
+ rspec-core (3.9.3)
41
+ rspec-support (~> 3.9.3)
42
+ rspec-expectations (3.9.3)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.9.0)
45
+ rspec-mocks (3.9.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.9.0)
48
+ rspec-support (3.9.4)
49
+ simplecov (0.19.0)
50
+ docile (~> 1.1)
51
+ simplecov-html (~> 0.11)
52
+ simplecov-html (0.12.3)
53
+ thor (1.0.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ bundler (~> 1.17)
60
+ kuber_kit!
61
+ pry
62
+ rake (~> 10.0)
63
+ rspec (~> 3.0)
64
+ simplecov
65
+
66
+ BUNDLED WITH
67
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Iskander Khaziev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Docker Kit
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'kuber_kit'
9
+ ```
10
+
11
+ ## Launch compilation for example images
12
+
13
+ ```
14
+ bin/kit compile ruby_app,ruby_app2 --path=./example -C review
15
+ ```
16
+
17
+ ## License
18
+
19
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/TODO.md ADDED
@@ -0,0 +1,2 @@
1
+ - add build servers support
2
+ - add build vars support (use images instead of containers)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kuber_kit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/kit ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ require "kuber_kit"
7
+
8
+ KuberKit::CLI.start(ARGV)
@@ -0,0 +1,7 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: "<%= service_uri %>"
5
+ spec:
6
+ selector:
7
+ app: test-app
@@ -0,0 +1,2 @@
1
+ APP_NAME=KuberKit
2
+ APP_ENV=test
@@ -0,0 +1 @@
1
+ Test Artifact
@@ -0,0 +1,4 @@
1
+ KuberKit
2
+ .define_configuration(:review)
3
+ .use_registry(:review_default, as: :default)
4
+ .use_artifact(:kuber_kit_repo, as: :kuber_kit_repo)
@@ -0,0 +1,6 @@
1
+ FROM default/ruby
2
+
3
+ RUN mkdir -p /app
4
+ WORKDIR /app
5
+
6
+ COPY source.rb source.rb
@@ -0,0 +1,2 @@
1
+ sleep(3)
2
+ puts "Hello world"
@@ -0,0 +1,4 @@
1
+ KuberKit
2
+ .define_image(:app_sources)
3
+ .registry(:default)
4
+ .depends_on(:ruby)
@@ -0,0 +1 @@
1
+ FROM ruby:2.5.8-slim
@@ -0,0 +1,3 @@
1
+ KuberKit
2
+ .define_image(:ruby)
3
+ .registry(:default)
@@ -0,0 +1,11 @@
1
+ FROM <%= image_url(:app_sources) %> AS app_sources
2
+ FROM <%= image_url(:ruby) %>
3
+
4
+ COPY --from=app_sources /app /app
5
+
6
+ COPY test.txt test.txt
7
+ COPY README.md README.md
8
+
9
+ RUN ruby /app/source.rb
10
+
11
+ COPY example_file.txt example_file.txt
@@ -0,0 +1,2 @@
1
+ file content
2
+ <%= "example" %>
@@ -0,0 +1,15 @@
1
+ KuberKit
2
+ .define_image(:ruby_app)
3
+ .registry(:default)
4
+ .depends_on(:ruby, :app_sources)
5
+ .before_build do |context_helper, build_dir|
6
+ # copy file local artifact
7
+ source_path = context_helper.artifact_path(:kuber_kit_example_data, "test.txt")
8
+ target_path = File.join(build_dir, "test.txt")
9
+ context_helper.shell.exec!("cp #{source_path} #{target_path}")
10
+
11
+ # copy file local artifact
12
+ source_path = context_helper.artifact_path(:kuber_kit_repo, "README.md")
13
+ target_path = File.join(build_dir, "README.md")
14
+ context_helper.shell.exec!("cp #{source_path} #{target_path}")
15
+ end
@@ -0,0 +1,8 @@
1
+ FROM <%= image_url(:app_sources) %> AS app_sources
2
+ FROM <%= image_url(:ruby) %>
3
+
4
+ COPY --from=app_sources /app /app
5
+
6
+ RUN ruby /app/source.rb
7
+
8
+ COPY example_file.txt example_file.txt
@@ -0,0 +1,2 @@
1
+ file content
2
+ <%= "example" %>
@@ -0,0 +1,4 @@
1
+ KuberKit
2
+ .define_image(:ruby_app2)
3
+ .registry(:default)
4
+ .depends_on(:ruby, :app_sources)
@@ -0,0 +1,13 @@
1
+ data_path = File.expand_path File.join(File.dirname(__FILE__), "..", "app_data")
2
+
3
+ KuberKit.add_artifact(
4
+ KuberKit::Core::Artifacts::Local
5
+ .new(:kuber_kit_example_data)
6
+ .setup( data_path )
7
+ )
8
+
9
+ KuberKit.add_artifact(
10
+ KuberKit::Core::Artifacts::Git
11
+ .new(:kuber_kit_repo)
12
+ .setup(remote_url: "git@github.com:ArtStation/kuber_kit.git")
13
+ )
@@ -0,0 +1,4 @@
1
+ KuberKit.add_env_file(
2
+ KuberKit::Core::EnvFiles::ArtifactFile
3
+ .new(:test, artifact_name: :kuber_kit_example_data, file_path: "test.env")
4
+ )
@@ -0,0 +1,4 @@
1
+ KuberKit.add_registry(
2
+ KuberKit::Registries::Remote
3
+ .new(:review_default)
4
+ )
@@ -0,0 +1,3 @@
1
+ KuberKit
2
+ .define_service(:auth_app)
3
+ .template(:service)
@@ -0,0 +1,4 @@
1
+ KuberKit.add_template(
2
+ KuberKit::Core::Templates::ArtifactFile
3
+ .new(:service, artifact_name: :kuber_kit_example_data, file_path: "service.yml")
4
+ )
@@ -0,0 +1,35 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "kuber_kit/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kuber_kit"
8
+ spec.version = KuberKit::VERSION
9
+ spec.authors = ["Iskander Khaziev"]
10
+ spec.email = ["gvalmon@gmail.com"]
11
+
12
+ spec.summary = %q{Docker Containers Build & Deployment}
13
+ spec.description = %q{Docker Containers Build & Deployment}
14
+ spec.homepage = "https://github.com/ArtStation/kuber_kit"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "bin"
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "contracts-lite"
27
+ spec.add_dependency "dry-auto_inject"
28
+ spec.add_dependency "thor"
29
+ spec.add_dependency "cli-ui"
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.17"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "pry"
35
+ end
@@ -0,0 +1,205 @@
1
+ require "kuber_kit/version"
2
+ require 'ostruct'
3
+ require 'contracts'
4
+ require 'dry-auto_inject'
5
+ require 'kuber_kit/extensions/colored_string'
6
+ require 'kuber_kit/extensions/contracts'
7
+
8
+ $LOAD_PATH << File.join(__dir__, 'kuber_kit')
9
+
10
+ module KuberKit
11
+ Error = Class.new(StandardError)
12
+ NotImplementedError = Class.new(Error)
13
+ NotFoundError = Class.new(Error)
14
+
15
+ module Core
16
+ autoload :ImageDefinition, 'core/image_definition'
17
+ autoload :ImageDefinitionFactory, 'core/image_definition_factory'
18
+ autoload :ImageStore, 'core/image_store'
19
+ autoload :ImageFactory, 'core/image_factory'
20
+ autoload :Image, 'core/image'
21
+
22
+ autoload :ServiceDefinition, 'core/service_definition'
23
+ autoload :ServiceDefinitionFactory, 'core/service_definition_factory'
24
+ autoload :ServiceStore, 'core/service_store'
25
+ autoload :ServiceFactory, 'core/service_factory'
26
+ autoload :Service, 'core/service'
27
+
28
+ autoload :ConfigurationDefinition, 'core/configuration_definition'
29
+ autoload :ConfigurationDefinitionFactory, 'core/configuration_definition_factory'
30
+ autoload :ConfigurationStore, 'core/configuration_store'
31
+ autoload :ConfigurationFactory, 'core/configuration_factory'
32
+ autoload :Configuration, 'core/configuration'
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
46
+
47
+ module Artifacts
48
+ autoload :AbstractArtifact, 'core/artifacts/abstract_artifact'
49
+ autoload :ArtifactStore, 'core/artifacts/artifact_store'
50
+ autoload :Git, 'core/artifacts/git'
51
+ autoload :Local, 'core/artifacts/local'
52
+ end
53
+
54
+ module EnvFiles
55
+ autoload :EnvFileStore, 'core/env_files/env_file_store'
56
+ autoload :AbstractEnvFile, 'core/env_files/abstract_env_file'
57
+ autoload :ArtifactFile, 'core/env_files/artifact_file'
58
+ end
59
+
60
+ module Templates
61
+ autoload :TemplateStore, 'core/templates/template_store'
62
+ autoload :AbstractTemplate, 'core/templates/abstract_template'
63
+ autoload :ArtifactFile, 'core/templates/artifact_file'
64
+ end
65
+ end
66
+
67
+ module Tools
68
+ autoload :FilePresenceChecker, 'tools/file_presence_checker'
69
+ autoload :LoggerFactory, 'tools/logger_factory'
70
+ autoload :FilesSync, 'tools/files_sync'
71
+ end
72
+
73
+ module Shell
74
+ autoload :AbstractShell, 'shell/abstract_shell'
75
+ autoload :LocalShell, 'shell/local_shell'
76
+ 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'
82
+ end
83
+
84
+ module ImageCompiler
85
+ autoload :Compiler, 'image_compiler/compiler'
86
+ autoload :ImageBuilder, 'image_compiler/image_builder'
87
+ autoload :ImageBuildDirCreator, 'image_compiler/image_build_dir_creator'
88
+ autoload :ImageDependencyResolver, 'image_compiler/image_dependency_resolver'
89
+ autoload :VersionTagBuilder, 'image_compiler/version_tag_builder'
90
+ end
91
+
92
+ module Preprocessing
93
+ autoload :TextPreprocessor, 'preprocessing/text_preprocessor'
94
+ autoload :FilePreprocessor, 'preprocessing/file_preprocessor'
95
+ autoload :DirPreprocessor, 'preprocessing/dir_preprocessor'
96
+ end
97
+
98
+ module ArtifactsSync
99
+ autoload :AbstractArtifactResolver, 'artifacts_sync/abstract_artifact_resolver'
100
+ autoload :ArtifactsUpdater, 'artifacts_sync/artifacts_updater'
101
+ autoload :GitArtifactResolver, 'artifacts_sync/git_artifact_resolver'
102
+ autoload :NullArtifactResolver, 'artifacts_sync/null_artifact_resolver'
103
+ end
104
+
105
+ module EnvFileReader
106
+ 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'
109
+ end
110
+
111
+ module TemplateReader
112
+ autoload :Reader, 'template_reader/reader'
113
+ autoload :AbstractTemplateReader, 'template_reader/abstract_template_reader'
114
+ autoload :ArtifactFileReader, 'template_reader/artifact_file_reader'
115
+ end
116
+
117
+ module ServiceDeployer
118
+ autoload :ServiceReader, 'service_deployer/service_reader'
119
+ autoload :ServiceApplier, 'service_deployer/service_applier'
120
+ autoload :ServiceListResolver, 'service_deployer/service_list_resolver'
121
+ end
122
+
123
+ module Actions
124
+ autoload :ImageCompiler, 'actions/image_compiler'
125
+ autoload :EnvFileReader, 'actions/env_file_reader'
126
+ autoload :TemplateReader, 'actions/template_reader'
127
+ autoload :ServiceReader, 'actions/service_reader'
128
+ autoload :ServiceApplier, 'actions/service_applier'
129
+ autoload :ConfigurationLoader, 'actions/configuration_loader'
130
+ autoload :KubectlApplier, 'actions/kubectl_applier'
131
+ end
132
+
133
+ module Extensions
134
+ autoload :Inspectable, 'extensions/inspectable'
135
+ end
136
+
137
+ module UI
138
+ autoload :Interactive, 'ui/interactive'
139
+ autoload :Simple, 'ui/simple'
140
+ end
141
+
142
+ autoload :Configs, 'configs'
143
+ autoload :CLI, 'cli'
144
+ autoload :Container, 'container'
145
+
146
+ Import = Dry::AutoInject(Container)
147
+
148
+ class << self
149
+ def define_image(image_name)
150
+ image_path = caller[0].split(':').first
151
+
152
+ Container["core.image_store"].define(image_name, image_path.split('image.rb').first)
153
+ end
154
+
155
+ def define_service(service_name)
156
+ Container["core.service_store"].define(service_name)
157
+ end
158
+
159
+ def define_configuration(configuration_name)
160
+ Container["core.configuration_store"].define(configuration_name)
161
+ end
162
+
163
+ def set_configuration_name(configuration_name)
164
+ @configuration_name = configuration_name.to_sym
165
+ @current_configuration = nil
166
+ end
167
+
168
+ def set_debug_mode(value)
169
+ @debug_mode = value
170
+ end
171
+
172
+ def debug_mode?
173
+ !!@debug_mode
174
+ end
175
+
176
+ def current_configuration
177
+ if @configuration_name.nil?
178
+ raise "Please set configuration name before calling current_configuration"
179
+ end
180
+ @current_configuration ||= Container['core.configuration_store'].get_configuration(@configuration_name)
181
+ end
182
+
183
+ def add_registry(registry)
184
+ Container["core.registry_store"].add(registry)
185
+ end
186
+
187
+ def add_artifact(artifact)
188
+ Container["core.artifact_store"].add(artifact)
189
+ end
190
+
191
+ def add_env_file(env_file)
192
+ Container["core.env_file_store"].add(env_file)
193
+ end
194
+
195
+ def add_template(template)
196
+ Container["core.template_store"].add(template)
197
+ end
198
+
199
+ def build_helper(&proc)
200
+ KuberKit::Core::ContextHelper::BaseHelper.class_exec(&proc)
201
+ end
202
+ end
203
+ end
204
+
205
+ require 'kuber_kit/extensions/indocker_compat'