kuber_kit 0.2.7 → 0.2.8
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/TODO.md +0 -1
- data/example/config.rb +3 -0
- data/lib/kuber_kit.rb +16 -3
- data/lib/kuber_kit/actions/configuration_loader.rb +13 -0
- data/lib/kuber_kit/actions/template_reader.rb +3 -6
- data/lib/kuber_kit/configs.rb +60 -32
- data/lib/kuber_kit/container.rb +6 -2
- data/lib/kuber_kit/core/configuration.rb +8 -4
- data/lib/kuber_kit/core/configuration_definition.rb +8 -1
- data/lib/kuber_kit/core/configuration_factory.rb +3 -2
- data/lib/kuber_kit/core/context_helper/base_helper.rb +4 -0
- data/lib/kuber_kit/core/context_helper/context_args.rb +39 -0
- data/lib/kuber_kit/env_file_reader/reader.rb +10 -6
- data/lib/kuber_kit/service_deployer/deployer.rb +11 -7
- data/lib/kuber_kit/template_reader/action_handler.rb +13 -0
- data/lib/kuber_kit/template_reader/reader.rb +13 -9
- data/lib/kuber_kit/template_reader/{abstract_template_reader.rb → strategies/abstract.rb} +1 -1
- data/lib/kuber_kit/template_reader/{artifact_file_reader.rb → strategies/artifact_file.rb} +1 -1
- data/lib/kuber_kit/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4caab78fa6712fb2e509f29078f209fe491f35973a973a941143feed08f41d1c
|
|
4
|
+
data.tar.gz: 4aa7e98355e2e961d963026c640422a4d90deb802a0ffadfd4d938781527ab7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08ad78c315e7e7900f668707f96ea61e9a200f90c5ae7f9d94a54835540a697549e763692c73734631f03df2d76c53d9eef7bff4e019a003b23b63baf3499902'
|
|
7
|
+
data.tar.gz: e347e3b630580b7476fa67a4434ef870b897979d2322a73e32027346933be12f37b7f1212426e9e806833074e7c3cb655b5bed930c6556c30f1288ec49dec45d
|
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
data/example/config.rb
ADDED
data/lib/kuber_kit.rb
CHANGED
|
@@ -57,6 +57,7 @@ module KuberKit
|
|
|
57
57
|
autoload :ImageHelper, 'core/context_helper/image_helper'
|
|
58
58
|
autoload :ServiceHelper, 'core/context_helper/service_helper'
|
|
59
59
|
autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
|
|
60
|
+
autoload :ContextArgs, 'core/context_helper/context_args'
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
module Registries
|
|
@@ -127,9 +128,13 @@ module KuberKit
|
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
module TemplateReader
|
|
131
|
+
autoload :ActionHandler, 'template_reader/action_handler'
|
|
130
132
|
autoload :Reader, 'template_reader/reader'
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
|
|
134
|
+
module Strategies
|
|
135
|
+
autoload :Abstract, 'template_reader/strategies/abstract'
|
|
136
|
+
autoload :ArtifactFile, 'template_reader/strategies/artifact_file'
|
|
137
|
+
end
|
|
133
138
|
end
|
|
134
139
|
|
|
135
140
|
module ServiceDeployer
|
|
@@ -170,9 +175,9 @@ module KuberKit
|
|
|
170
175
|
autoload :Simple, 'ui/simple'
|
|
171
176
|
end
|
|
172
177
|
|
|
173
|
-
autoload :Configs, 'configs'
|
|
174
178
|
autoload :CLI, 'cli'
|
|
175
179
|
autoload :Container, 'container'
|
|
180
|
+
autoload :Configs, 'configs'
|
|
176
181
|
|
|
177
182
|
Import = Dry::AutoInject(Container)
|
|
178
183
|
|
|
@@ -211,6 +216,10 @@ module KuberKit
|
|
|
211
216
|
@current_configuration ||= Container['core.configuration_store'].get_configuration(@configuration_name)
|
|
212
217
|
end
|
|
213
218
|
|
|
219
|
+
def global_build_vars
|
|
220
|
+
KuberKit::Core::ContextHelper::ContextArgs.new(current_configuration.global_build_vars)
|
|
221
|
+
end
|
|
222
|
+
|
|
214
223
|
def add_registry(registry)
|
|
215
224
|
Container["core.registry_store"].add(registry)
|
|
216
225
|
end
|
|
@@ -234,6 +243,10 @@ module KuberKit
|
|
|
234
243
|
def build_helper(&proc)
|
|
235
244
|
KuberKit::Core::ContextHelper::BaseHelper.class_exec(&proc)
|
|
236
245
|
end
|
|
246
|
+
|
|
247
|
+
def configure(&proc)
|
|
248
|
+
yield(Container["configs"])
|
|
249
|
+
end
|
|
237
250
|
end
|
|
238
251
|
end
|
|
239
252
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
class KuberKit::Actions::ConfigurationLoader
|
|
2
|
+
APP_CONFIG_FILENAME = "config.rb".freeze
|
|
3
|
+
|
|
2
4
|
include KuberKit::Import[
|
|
3
5
|
"core.registry_store",
|
|
4
6
|
"core.image_store",
|
|
@@ -14,6 +16,13 @@ class KuberKit::Actions::ConfigurationLoader
|
|
|
14
16
|
Contract Hash => Any
|
|
15
17
|
def call(options)
|
|
16
18
|
root_path = options[:path] || File.join(Dir.pwd, configs.kuber_kit_dirname)
|
|
19
|
+
|
|
20
|
+
# require config file first, in case if other dirs are overriden in config
|
|
21
|
+
config_file_path = File.join(root_path, APP_CONFIG_FILENAME)
|
|
22
|
+
if File.exists?(config_file_path)
|
|
23
|
+
require config_file_path
|
|
24
|
+
end
|
|
25
|
+
|
|
17
26
|
images_path = options[:images_path] || File.join(root_path, configs.images_dirname)
|
|
18
27
|
services_path = options[:services_path] || File.join(root_path, configs.services_dirname)
|
|
19
28
|
infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
|
|
@@ -32,6 +41,10 @@ class KuberKit::Actions::ConfigurationLoader
|
|
|
32
41
|
ui.print_warning "WARNING", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
|
33
42
|
end
|
|
34
43
|
|
|
44
|
+
if Gem::Version.new(KuberKit::VERSION) < Gem::Version.new(configs.kuber_kit_min_version)
|
|
45
|
+
raise KuberKit::Error, "The minimal required kuber_kit version is #{configs.kuber_kit_min_version}"
|
|
46
|
+
end
|
|
47
|
+
|
|
35
48
|
load_configurations(configurations_path, configuration_name)
|
|
36
49
|
load_infrastructure(infra_path)
|
|
37
50
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
class KuberKit::Actions::TemplateReader
|
|
2
2
|
include KuberKit::Import[
|
|
3
|
-
"core.template_store",
|
|
4
|
-
"template_reader.reader",
|
|
5
3
|
"shell.local_shell",
|
|
6
|
-
"ui"
|
|
4
|
+
"ui",
|
|
5
|
+
template_reader: "template_reader.action_handler",
|
|
7
6
|
]
|
|
8
7
|
|
|
9
8
|
Contract Symbol, Hash => Any
|
|
10
9
|
def call(template_name, options)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
result = reader.read(local_shell, template)
|
|
10
|
+
result = template_reader.call(local_shell, template_name)
|
|
14
11
|
|
|
15
12
|
ui.print_info(template_name.to_s, result)
|
|
16
13
|
|
data/lib/kuber_kit/configs.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class KuberKit::Configs
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
AVAILABLE_CONFIGS = [
|
|
5
|
+
:image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir,
|
|
6
|
+
:kuber_kit_dirname, :kuber_kit_min_version, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
|
|
7
|
+
:artifact_clone_dir, :service_config_dir, :deploy_strategy, :compile_simultaneous_limit
|
|
8
|
+
]
|
|
6
9
|
DOCKER_IGNORE_LIST = [
|
|
7
10
|
'Dockerfile',
|
|
8
11
|
'.DS_Store',
|
|
@@ -14,35 +17,60 @@ class KuberKit::Configs
|
|
|
14
17
|
'tmp',
|
|
15
18
|
'logs'
|
|
16
19
|
]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attr_accessor :image_dockerfile_name, :image_build_context_dir, :image_tag,
|
|
28
|
-
:docker_ignore_list, :image_compile_dir,
|
|
29
|
-
:kuber_kit_dirname, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
|
|
30
|
-
:artifact_clone_dir, :service_config_dir, :deploy_strategy, :compile_simultaneous_limit
|
|
20
|
+
|
|
21
|
+
AVAILABLE_CONFIGS.each do |config_name|
|
|
22
|
+
define_method(config_name) do
|
|
23
|
+
get(config_name.to_sym)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
define_method(:"#{config_name}=") do |value|
|
|
27
|
+
set(config_name.to_sym, value)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
31
30
|
|
|
32
31
|
def initialize
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
add_default_configs unless items.any?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_default_configs
|
|
36
|
+
set :image_dockerfile_name, "Dockerfile"
|
|
37
|
+
set :image_build_context_dir, "build_context"
|
|
38
|
+
set :image_tag, 'latest'
|
|
39
|
+
set :image_compile_dir, "/tmp/kuber_kit/image_builds"
|
|
40
|
+
set :docker_ignore_list, DOCKER_IGNORE_LIST
|
|
41
|
+
set :kuber_kit_dirname, "kuber_kit"
|
|
42
|
+
set :kuber_kit_min_version, KuberKit::VERSION
|
|
43
|
+
set :images_dirname, "images"
|
|
44
|
+
set :services_dirname, "services"
|
|
45
|
+
set :infra_dirname, "infrastructure"
|
|
46
|
+
set :configurations_dirname, "configurations"
|
|
47
|
+
set :artifact_clone_dir, "/tmp/kuber_kit/artifacts"
|
|
48
|
+
set :service_config_dir, "/tmp/kuber_kit/services"
|
|
49
|
+
set :deploy_strategy, :kubernetes
|
|
50
|
+
set :compile_simultaneous_limit, 5
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def items
|
|
54
|
+
@@items ||= {}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def set(key, value)
|
|
58
|
+
unless AVAILABLE_CONFIGS.include?(key)
|
|
59
|
+
raise ArgumentError, "#{key} is not a valid configuration key"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
items[key] = value
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get(key)
|
|
66
|
+
unless AVAILABLE_CONFIGS.include?(key)
|
|
67
|
+
raise ArgumentError, "#{key} is not a valid configuration key"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
items[key]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def reset!
|
|
74
|
+
@@items = {}
|
|
47
75
|
end
|
|
48
76
|
end
|
data/lib/kuber_kit/container.rb
CHANGED
|
@@ -197,12 +197,16 @@ class KuberKit::Container
|
|
|
197
197
|
KuberKit::EnvFileReader::Strategies::ArtifactFile.new
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
+
register "template_reader.action_handler" do
|
|
201
|
+
KuberKit::TemplateReader::ActionHandler.new
|
|
202
|
+
end
|
|
203
|
+
|
|
200
204
|
register "template_reader.reader" do
|
|
201
205
|
KuberKit::TemplateReader::Reader.new
|
|
202
206
|
end
|
|
203
207
|
|
|
204
|
-
register "template_reader.
|
|
205
|
-
KuberKit::TemplateReader::
|
|
208
|
+
register "template_reader.strategies.artifact_file" do
|
|
209
|
+
KuberKit::TemplateReader::Strategies::ArtifactFile.new
|
|
206
210
|
end
|
|
207
211
|
|
|
208
212
|
register "service_deployer.action_handler" do
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
class KuberKit::Core::Configuration
|
|
2
2
|
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
|
|
3
|
-
:deploy_strategy, :deploy_namespace, :services_attributes, :build_servers
|
|
3
|
+
:deploy_strategy, :deploy_namespace, :services_attributes, :build_servers,
|
|
4
|
+
:global_build_vars
|
|
4
5
|
|
|
5
6
|
Contract KeywordArgs[
|
|
6
7
|
name: Symbol,
|
|
@@ -12,10 +13,12 @@ class KuberKit::Core::Configuration
|
|
|
12
13
|
deploy_strategy: Symbol,
|
|
13
14
|
deploy_namespace: Maybe[Symbol],
|
|
14
15
|
services_attributes: HashOf[Symbol => Hash],
|
|
15
|
-
build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer]
|
|
16
|
+
build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
|
|
17
|
+
global_build_vars: HashOf[Symbol => Any],
|
|
16
18
|
] => Any
|
|
17
19
|
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
|
|
18
|
-
deploy_strategy:, deploy_namespace:, services_attributes:, build_servers
|
|
20
|
+
deploy_strategy:, deploy_namespace:, services_attributes:, build_servers:,
|
|
21
|
+
global_build_vars:)
|
|
19
22
|
@name = name
|
|
20
23
|
@artifacts = artifacts
|
|
21
24
|
@registries = registries
|
|
@@ -24,8 +27,9 @@ class KuberKit::Core::Configuration
|
|
|
24
27
|
@kubeconfig_path = kubeconfig_path
|
|
25
28
|
@deploy_strategy = deploy_strategy
|
|
26
29
|
@deploy_namespace = deploy_namespace
|
|
27
|
-
@services_attributes = services_attributes
|
|
28
30
|
@build_servers = build_servers
|
|
31
|
+
@services_attributes = services_attributes
|
|
32
|
+
@global_build_vars = global_build_vars
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def service_attributes(service_name)
|
|
@@ -27,7 +27,8 @@ class KuberKit::Core::ConfigurationDefinition
|
|
|
27
27
|
deploy_namespace: @deploy_namespace,
|
|
28
28
|
enabled_services: @enabled_services,
|
|
29
29
|
build_servers: @build_servers,
|
|
30
|
-
services_attributes:
|
|
30
|
+
services_attributes: @services_attributes,
|
|
31
|
+
global_build_vars: @global_build_vars,
|
|
31
32
|
)
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -99,4 +100,10 @@ class KuberKit::Core::ConfigurationDefinition
|
|
|
99
100
|
|
|
100
101
|
self
|
|
101
102
|
end
|
|
103
|
+
|
|
104
|
+
def global_build_vars(variables)
|
|
105
|
+
@global_build_vars = variables
|
|
106
|
+
|
|
107
|
+
self
|
|
108
|
+
end
|
|
102
109
|
end
|
|
@@ -28,8 +28,9 @@ class KuberKit::Core::ConfigurationFactory
|
|
|
28
28
|
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
|
29
29
|
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy,
|
|
30
30
|
deploy_namespace: configuration_attrs.deploy_namespace,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
build_servers: build_servers,
|
|
32
|
+
services_attributes: configuration_attrs.services_attributes,
|
|
33
|
+
global_build_vars: configuration_attrs.global_build_vars || {},
|
|
33
34
|
)
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class KuberKit::Core::ContextHelper::ContextArgs
|
|
2
|
+
attr_reader :parent, :parent_name
|
|
3
|
+
|
|
4
|
+
def initialize(context_args, parent_name = nil, parent = nil)
|
|
5
|
+
@context_args = context_args
|
|
6
|
+
@parent_name = parent_name
|
|
7
|
+
@parent = parent
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def method_missing(name, *args)
|
|
11
|
+
if args.size > 0
|
|
12
|
+
raise ArgumentError.new("context args does not accept any arguments")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
value = @context_args.fetch(name) do
|
|
16
|
+
raise(KuberKit::Error, "build arg '#{format_arg(name)}' is not defined, available args: #{@context_args.inspect}")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
if value.is_a?(Hash)
|
|
20
|
+
return self.class.new(value, name, self)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
value
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def format_arg(name)
|
|
29
|
+
string = [@parent_name, name].compact.join(".")
|
|
30
|
+
parent = @parent
|
|
31
|
+
|
|
32
|
+
while parent do
|
|
33
|
+
string = [parent.parent_name, string].compact.join(".")
|
|
34
|
+
parent = parent.parent
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
string
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -5,6 +5,11 @@ class KuberKit::EnvFileReader::Reader
|
|
|
5
5
|
"env_file_reader.strategies.artifact_file",
|
|
6
6
|
]
|
|
7
7
|
|
|
8
|
+
def initialize(**injected_deps)
|
|
9
|
+
super(injected_deps)
|
|
10
|
+
add_default_strategies
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
def use_reader(env_file_reader, env_file_class:)
|
|
9
14
|
@@readers ||= {}
|
|
10
15
|
|
|
@@ -16,8 +21,6 @@ class KuberKit::EnvFileReader::Reader
|
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
def read(shell, env_file)
|
|
19
|
-
add_default_readers
|
|
20
|
-
|
|
21
24
|
reader = @@readers[env_file.class]
|
|
22
25
|
|
|
23
26
|
raise ReaderNotFoundError, "Can't find reader for env file #{env_file}" if reader.nil?
|
|
@@ -25,11 +28,12 @@ class KuberKit::EnvFileReader::Reader
|
|
|
25
28
|
reader.read(shell, env_file)
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
def add_default_readers
|
|
29
|
-
use_reader(artifact_file, env_file_class: KuberKit::Core::EnvFiles::ArtifactFile)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
31
|
def reset!
|
|
33
32
|
@@readers = {}
|
|
34
33
|
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
def add_default_strategies
|
|
37
|
+
use_reader(artifact_file, env_file_class: KuberKit::Core::EnvFiles::ArtifactFile)
|
|
38
|
+
end
|
|
35
39
|
end
|
|
@@ -7,6 +7,11 @@ class KuberKit::ServiceDeployer::Deployer
|
|
|
7
7
|
"service_deployer.strategies.kubernetes_runner"
|
|
8
8
|
]
|
|
9
9
|
|
|
10
|
+
def initialize(**injected_deps)
|
|
11
|
+
super(injected_deps)
|
|
12
|
+
add_default_strategies
|
|
13
|
+
end
|
|
14
|
+
|
|
10
15
|
def register_strategy(strategy_name, strategy)
|
|
11
16
|
@@strategies ||= {}
|
|
12
17
|
|
|
@@ -19,8 +24,6 @@ class KuberKit::ServiceDeployer::Deployer
|
|
|
19
24
|
|
|
20
25
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, Symbol => Any
|
|
21
26
|
def deploy(shell, service, strategy_name)
|
|
22
|
-
add_default_strategies
|
|
23
|
-
|
|
24
27
|
deployer = @@strategies[strategy_name]
|
|
25
28
|
|
|
26
29
|
raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if deployer.nil?
|
|
@@ -28,12 +31,13 @@ class KuberKit::ServiceDeployer::Deployer
|
|
|
28
31
|
deployer.deploy(shell, service)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
def add_default_strategies
|
|
32
|
-
register_strategy(:kubernetes, kubernetes)
|
|
33
|
-
register_strategy(:kubernetes_runner, kubernetes_runner)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
34
|
def reset!
|
|
37
35
|
@@strategies = {}
|
|
38
36
|
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
def add_default_strategies
|
|
40
|
+
register_strategy(:kubernetes, kubernetes)
|
|
41
|
+
register_strategy(:kubernetes_runner, kubernetes_runner)
|
|
42
|
+
end
|
|
39
43
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class KuberKit::TemplateReader::ActionHandler
|
|
2
|
+
include KuberKit::Import[
|
|
3
|
+
"template_reader.reader",
|
|
4
|
+
"core.template_store",
|
|
5
|
+
]
|
|
6
|
+
|
|
7
|
+
Contract KuberKit::Shell::AbstractShell, Symbol => Any
|
|
8
|
+
def call(shell, template_name)
|
|
9
|
+
template = template_store.get(template_name)
|
|
10
|
+
|
|
11
|
+
reader.read(shell, template)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -2,22 +2,25 @@ class KuberKit::TemplateReader::Reader
|
|
|
2
2
|
ReaderNotFoundError = Class.new(KuberKit::NotFoundError)
|
|
3
3
|
|
|
4
4
|
include KuberKit::Import[
|
|
5
|
-
"template_reader.
|
|
5
|
+
"template_reader.strategies.artifact_file",
|
|
6
6
|
]
|
|
7
7
|
|
|
8
|
+
def initialize(**injected_deps)
|
|
9
|
+
super(injected_deps)
|
|
10
|
+
add_default_strategies
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
def use_reader(template_reader, template_class:)
|
|
9
14
|
@@readers ||= {}
|
|
10
15
|
|
|
11
|
-
if !template_reader.is_a?(KuberKit::TemplateReader::
|
|
12
|
-
raise ArgumentError.new("should be an instance of KuberKit::TemplateReader::
|
|
16
|
+
if !template_reader.is_a?(KuberKit::TemplateReader::Strategies::Abstract)
|
|
17
|
+
raise ArgumentError.new("should be an instance of KuberKit::TemplateReader::Strategies::Abstract, got: #{template_reader.inspect}")
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
@@readers[template_class] = template_reader
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
def read(shell, template)
|
|
19
|
-
add_default_readers
|
|
20
|
-
|
|
21
24
|
reader = @@readers[template.class]
|
|
22
25
|
|
|
23
26
|
raise ReaderNotFoundError, "Can't find reader for template #{template}" if reader.nil?
|
|
@@ -25,11 +28,12 @@ class KuberKit::TemplateReader::Reader
|
|
|
25
28
|
reader.read(shell, template)
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
def add_default_readers
|
|
29
|
-
use_reader(artifact_file_reader, template_class: KuberKit::Core::Templates::ArtifactFile)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
31
|
def reset!
|
|
33
32
|
@@readers = {}
|
|
34
33
|
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
def add_default_strategies
|
|
37
|
+
use_reader(artifact_file, template_class: KuberKit::Core::Templates::ArtifactFile)
|
|
38
|
+
end
|
|
35
39
|
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.2.
|
|
4
|
+
version: 0.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Iskander Khaziev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-12-
|
|
11
|
+
date: 2020-12-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: contracts-lite
|
|
@@ -162,6 +162,7 @@ files:
|
|
|
162
162
|
- example/app_data/service.yml
|
|
163
163
|
- example/app_data/test.env
|
|
164
164
|
- example/app_data/test.txt
|
|
165
|
+
- example/config.rb
|
|
165
166
|
- example/configurations/review.rb
|
|
166
167
|
- example/images/app_sources/Dockerfile
|
|
167
168
|
- example/images/app_sources/build_context/source.rb
|
|
@@ -211,6 +212,7 @@ files:
|
|
|
211
212
|
- lib/kuber_kit/core/configuration_factory.rb
|
|
212
213
|
- lib/kuber_kit/core/configuration_store.rb
|
|
213
214
|
- lib/kuber_kit/core/context_helper/base_helper.rb
|
|
215
|
+
- lib/kuber_kit/core/context_helper/context_args.rb
|
|
214
216
|
- lib/kuber_kit/core/context_helper/context_helper_factory.rb
|
|
215
217
|
- lib/kuber_kit/core/context_helper/image_helper.rb
|
|
216
218
|
- lib/kuber_kit/core/context_helper/service_helper.rb
|
|
@@ -271,9 +273,10 @@ files:
|
|
|
271
273
|
- lib/kuber_kit/shell/local_shell.rb
|
|
272
274
|
- lib/kuber_kit/shell/ssh_session.rb
|
|
273
275
|
- lib/kuber_kit/shell/ssh_shell.rb
|
|
274
|
-
- lib/kuber_kit/template_reader/
|
|
275
|
-
- lib/kuber_kit/template_reader/artifact_file_reader.rb
|
|
276
|
+
- lib/kuber_kit/template_reader/action_handler.rb
|
|
276
277
|
- lib/kuber_kit/template_reader/reader.rb
|
|
278
|
+
- lib/kuber_kit/template_reader/strategies/abstract.rb
|
|
279
|
+
- lib/kuber_kit/template_reader/strategies/artifact_file.rb
|
|
277
280
|
- lib/kuber_kit/tools/file_presence_checker.rb
|
|
278
281
|
- lib/kuber_kit/tools/logger_factory.rb
|
|
279
282
|
- lib/kuber_kit/ui.rb
|