kuber_kit 0.1.4 → 0.1.9
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 +4 -2
- data/README.md +16 -3
- data/TODO.md +4 -4
- data/example/app_data/env_file.yml +10 -0
- data/example/configurations/review.rb +2 -1
- data/example/images/app_sources/Dockerfile +1 -1
- data/example/images/ruby_app/image.rb +4 -4
- data/example/infrastructure/build_servers.rb +8 -0
- data/example/infrastructure/templates.rb +5 -0
- data/example/services/env_file.rb +6 -0
- data/kuber_kit.gemspec +1 -0
- data/lib/kuber_kit.rb +50 -23
- data/lib/kuber_kit/actions/configuration_loader.rb +5 -0
- data/lib/kuber_kit/actions/env_file_reader.rb +8 -5
- data/lib/kuber_kit/actions/image_compiler.rb +18 -22
- data/lib/kuber_kit/actions/kubectl_applier.rb +6 -1
- data/lib/kuber_kit/actions/service_deployer.rb +13 -3
- data/lib/kuber_kit/actions/service_reader.rb +9 -6
- data/lib/kuber_kit/actions/template_reader.rb +5 -0
- data/lib/kuber_kit/cli.rb +12 -6
- data/lib/kuber_kit/configs.rb +24 -22
- data/lib/kuber_kit/container.rb +39 -19
- data/lib/kuber_kit/core/artifacts/artifact_store.rb +12 -23
- data/lib/kuber_kit/core/build_servers/abstract_build_server.rb +21 -0
- data/lib/kuber_kit/core/build_servers/build_server.rb +24 -0
- data/lib/kuber_kit/core/build_servers/build_server_store.rb +18 -0
- data/lib/kuber_kit/core/configuration.rb +14 -4
- data/lib/kuber_kit/core/configuration_definition.rb +22 -1
- data/lib/kuber_kit/core/configuration_factory.rb +11 -1
- data/lib/kuber_kit/core/configuration_store.rb +14 -24
- data/lib/kuber_kit/core/context_helper/base_helper.rb +12 -7
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +11 -8
- data/lib/kuber_kit/core/context_helper/service_helper.rb +9 -4
- data/lib/kuber_kit/core/env_files/env_file_store.rb +8 -23
- data/lib/kuber_kit/core/image_store.rb +8 -18
- data/lib/kuber_kit/core/registries/registry_store.rb +8 -23
- data/lib/kuber_kit/core/service.rb +19 -3
- data/lib/kuber_kit/core/service_definition.rb +7 -0
- data/lib/kuber_kit/core/service_factory.rb +5 -1
- data/lib/kuber_kit/core/service_store.rb +13 -23
- data/lib/kuber_kit/core/store.rb +48 -0
- data/lib/kuber_kit/core/templates/template_store.rb +12 -23
- data/lib/kuber_kit/env_file_reader/action_handler.rb +12 -0
- data/lib/kuber_kit/env_file_reader/reader.rb +4 -4
- data/lib/kuber_kit/env_file_reader/{abstract_env_file_reader.rb → strategies/abstract.rb} +1 -1
- data/lib/kuber_kit/env_file_reader/{artifact_file_reader.rb → strategies/artifact_file.rb} +1 -1
- data/lib/kuber_kit/image_compiler/action_handler.rb +21 -0
- data/lib/kuber_kit/image_compiler/build_server_pool.rb +30 -0
- data/lib/kuber_kit/image_compiler/build_server_pool_factory.rb +13 -0
- data/lib/kuber_kit/image_compiler/compiler.rb +2 -5
- data/lib/kuber_kit/image_compiler/image_build_dir_creator.rb +13 -7
- data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +25 -5
- data/lib/kuber_kit/preprocessing/file_preprocessor.rb +5 -4
- data/lib/kuber_kit/preprocessing/text_preprocessor.rb +1 -1
- data/lib/kuber_kit/service_deployer/action_handler.rb +16 -0
- data/lib/kuber_kit/service_deployer/deployer.rb +28 -6
- data/lib/kuber_kit/service_deployer/strategies/abstract.rb +1 -1
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +9 -4
- data/lib/kuber_kit/service_deployer/strategy_detector.rb +6 -0
- data/lib/kuber_kit/service_reader/action_handler.rb +13 -0
- data/lib/kuber_kit/{service_deployer/service_reader.rb → service_reader/reader.rb} +1 -1
- data/lib/kuber_kit/shell/abstract_shell.rb +4 -0
- data/lib/kuber_kit/shell/{bash_commands.rb → commands/bash_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{docker_commands.rb → commands/docker_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{git_commands.rb → commands/git_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{kubectl_commands.rb → commands/kubectl_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{rsync_commands.rb → commands/rsync_commands.rb} +9 -3
- data/lib/kuber_kit/shell/local_shell.rb +24 -5
- data/lib/kuber_kit/shell/ssh_session.rb +60 -0
- data/lib/kuber_kit/shell/ssh_shell.rb +77 -0
- data/lib/kuber_kit/tools/file_presence_checker.rb +6 -2
- data/lib/kuber_kit/version.rb +1 -1
- metadata +40 -13
- data/lib/kuber_kit/preprocessing/dir_preprocessor.rb +0 -19
- data/lib/kuber_kit/service_deployer/service_restarter.rb +0 -37
- data/lib/kuber_kit/tools/files_sync.rb +0 -10
@@ -6,6 +6,7 @@ class KuberKit::Core::ConfigurationFactory
|
|
6
6
|
"core.artifact_store",
|
7
7
|
"core.env_file_store",
|
8
8
|
"core.template_store",
|
9
|
+
"core.build_server_store",
|
9
10
|
"configs"
|
10
11
|
]
|
11
12
|
|
@@ -16,6 +17,7 @@ class KuberKit::Core::ConfigurationFactory
|
|
16
17
|
registries = fetch_registries(configuration_attrs.registries)
|
17
18
|
env_files = fetch_env_files(configuration_attrs.env_files)
|
18
19
|
templates = fetch_templates(configuration_attrs.templates)
|
20
|
+
build_servers = fetch_build_servers(configuration_attrs.build_servers)
|
19
21
|
|
20
22
|
KuberKit::Core::Configuration.new(
|
21
23
|
name: configuration_attrs.name,
|
@@ -24,7 +26,9 @@ class KuberKit::Core::ConfigurationFactory
|
|
24
26
|
env_files: env_files,
|
25
27
|
templates: templates,
|
26
28
|
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
27
|
-
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy
|
29
|
+
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy,
|
30
|
+
services_attributes: configuration_attrs.services_attributes,
|
31
|
+
build_servers: build_servers
|
28
32
|
)
|
29
33
|
end
|
30
34
|
|
@@ -60,4 +64,10 @@ class KuberKit::Core::ConfigurationFactory
|
|
60
64
|
end
|
61
65
|
result
|
62
66
|
end
|
67
|
+
|
68
|
+
def fetch_build_servers(build_servers)
|
69
|
+
build_servers.map do |build_server_name|
|
70
|
+
build_server_store.get(build_server_name)
|
71
|
+
end
|
72
|
+
end
|
63
73
|
end
|
@@ -1,7 +1,4 @@
|
|
1
1
|
class KuberKit::Core::ConfigurationStore
|
2
|
-
NotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
-
AlreadyAddedError = Class.new(KuberKit::Error)
|
4
|
-
|
5
2
|
include KuberKit::Import[
|
6
3
|
"core.configuration_factory",
|
7
4
|
"core.configuration_definition_factory",
|
@@ -16,24 +13,12 @@ class KuberKit::Core::ConfigurationStore
|
|
16
13
|
end
|
17
14
|
|
18
15
|
def add_definition(configuration_definition)
|
19
|
-
|
20
|
-
|
21
|
-
unless @@configuration_definitions[configuration_definition.configuration_name].nil?
|
22
|
-
raise AlreadyAddedError, "image #{configuration_definition.configuration_name} was already added"
|
23
|
-
end
|
24
|
-
|
25
|
-
@@configuration_definitions[configuration_definition.configuration_name] = configuration_definition
|
16
|
+
definitions_store.add(configuration_definition.configuration_name, configuration_definition)
|
26
17
|
end
|
27
18
|
|
28
19
|
Contract Symbol => Any
|
29
20
|
def get_definition(configuration_name)
|
30
|
-
|
31
|
-
|
32
|
-
if @@configuration_definitions[configuration_name].nil?
|
33
|
-
raise NotFoundError, "configuration #{configuration_name} not found"
|
34
|
-
end
|
35
|
-
|
36
|
-
@@configuration_definitions[configuration_name]
|
21
|
+
definitions_store.get(configuration_name)
|
37
22
|
end
|
38
23
|
|
39
24
|
Contract Symbol => Any
|
@@ -57,18 +42,23 @@ class KuberKit::Core::ConfigurationStore
|
|
57
42
|
end
|
58
43
|
|
59
44
|
def reset!
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def all_definitions
|
64
|
-
@@configuration_definitions ||= {}
|
45
|
+
definitions_store.reset!
|
65
46
|
end
|
66
47
|
|
67
48
|
def count
|
68
|
-
|
49
|
+
definitions_store.size
|
69
50
|
end
|
70
51
|
|
71
52
|
def exists?(configuration_name)
|
72
|
-
|
53
|
+
definitions_store.exists?(configuration_name)
|
73
54
|
end
|
55
|
+
|
56
|
+
def all_definitions
|
57
|
+
definitions_store.items
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def definitions_store
|
62
|
+
@@definitions_store ||= KuberKit::Core::Store.new(KuberKit::Core::ConfigurationDefinition)
|
63
|
+
end
|
74
64
|
end
|
@@ -1,25 +1,30 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::BaseHelper
|
2
2
|
CONTRACT = RespondTo[:get_binding]
|
3
3
|
|
4
|
-
attr_reader :shell, :artifact_store, :image_store
|
4
|
+
attr_reader :shell, :artifact_store, :image_store, :env_file_reader
|
5
5
|
|
6
|
-
def initialize(image_store:, artifact_store:, shell:)
|
7
|
-
@image_store
|
8
|
-
@artifact_store
|
9
|
-
@shell
|
6
|
+
def initialize(image_store:, artifact_store:, shell:, env_file_reader:)
|
7
|
+
@image_store = image_store
|
8
|
+
@artifact_store = artifact_store
|
9
|
+
@shell = shell
|
10
|
+
@env_file_reader = env_file_reader
|
10
11
|
end
|
11
12
|
|
12
13
|
def image_url(image_name)
|
13
|
-
image = @image_store.get_image(image_name)
|
14
|
+
image = @image_store.get_image(image_name.to_sym)
|
14
15
|
|
15
16
|
image.remote_registry_url
|
16
17
|
end
|
17
18
|
|
18
19
|
def artifact_path(name, file_name = nil)
|
19
|
-
artifact = @artifact_store.get(name)
|
20
|
+
artifact = @artifact_store.get(name.to_sym)
|
20
21
|
[artifact.cloned_path, file_name].compact.join("/")
|
21
22
|
end
|
22
23
|
|
24
|
+
def env_file(env_file_name)
|
25
|
+
@env_file_reader.call(@shell, env_file_name)
|
26
|
+
end
|
27
|
+
|
23
28
|
def configuration_name
|
24
29
|
KuberKit.current_configuration.name
|
25
30
|
end
|
@@ -1,23 +1,26 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ContextHelperFactory
|
2
2
|
include KuberKit::Import[
|
3
3
|
"core.image_store",
|
4
|
-
"core.artifact_store"
|
4
|
+
"core.artifact_store",
|
5
|
+
env_file_reader: "env_file_reader.action_handler"
|
5
6
|
]
|
6
7
|
|
7
8
|
def build_image_context(shell)
|
8
9
|
KuberKit::Core::ContextHelper::ImageHelper.new(
|
9
|
-
image_store:
|
10
|
-
artifact_store:
|
11
|
-
shell:
|
10
|
+
image_store: image_store,
|
11
|
+
artifact_store: artifact_store,
|
12
|
+
shell: shell,
|
13
|
+
env_file_reader: env_file_reader
|
12
14
|
)
|
13
15
|
end
|
14
16
|
|
15
17
|
def build_service_context(shell, service)
|
16
18
|
KuberKit::Core::ContextHelper::ServiceHelper.new(
|
17
|
-
image_store:
|
18
|
-
artifact_store:
|
19
|
-
shell:
|
20
|
-
|
19
|
+
image_store: image_store,
|
20
|
+
artifact_store: artifact_store,
|
21
|
+
shell: shell,
|
22
|
+
env_file_reader: env_file_reader,
|
23
|
+
service: service,
|
21
24
|
)
|
22
25
|
end
|
23
26
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelper::BaseHelper
|
2
|
-
def initialize(image_store:, artifact_store:, shell:, service:)
|
2
|
+
def initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:)
|
3
3
|
super(
|
4
|
-
image_store:
|
5
|
-
artifact_store:
|
6
|
-
shell:
|
4
|
+
image_store: image_store,
|
5
|
+
artifact_store: artifact_store,
|
6
|
+
shell: shell,
|
7
|
+
env_file_reader: env_file_reader
|
7
8
|
)
|
8
9
|
@service = service
|
9
10
|
end
|
@@ -15,4 +16,8 @@ class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelp
|
|
15
16
|
def service_uri
|
16
17
|
@service.uri
|
17
18
|
end
|
19
|
+
|
20
|
+
def attribute(attribute_name, default: nil)
|
21
|
+
@service.attribute(attribute_name, default: default)
|
22
|
+
end
|
18
23
|
end
|
@@ -1,19 +1,6 @@
|
|
1
1
|
class KuberKit::Core::EnvFiles::EnvFileStore
|
2
|
-
NotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
-
AlreadyAddedError = Class.new(KuberKit::Error)
|
4
|
-
|
5
2
|
def add(env_file)
|
6
|
-
|
7
|
-
|
8
|
-
if !env_file.is_a?(KuberKit::Core::EnvFiles::AbstractEnvFile)
|
9
|
-
raise ArgumentError.new("should be an instance of KuberKit::Core::EnvFiles::AbstractEnvFile, got: #{env_file.inspect}")
|
10
|
-
end
|
11
|
-
|
12
|
-
unless @@env_files[env_file.name].nil?
|
13
|
-
raise AlreadyAddedError, "env_file #{env_file.name} was already added"
|
14
|
-
end
|
15
|
-
|
16
|
-
@@env_files[env_file.name] = env_file
|
3
|
+
store.add(env_file.name, env_file)
|
17
4
|
end
|
18
5
|
|
19
6
|
def get(env_file_name)
|
@@ -24,14 +11,7 @@ class KuberKit::Core::EnvFiles::EnvFileStore
|
|
24
11
|
end
|
25
12
|
|
26
13
|
def get_global(env_file_name)
|
27
|
-
|
28
|
-
env_file = @@env_files[env_file_name]
|
29
|
-
|
30
|
-
if env_file.nil?
|
31
|
-
raise NotFoundError, "env_file '#{env_file_name}' not found"
|
32
|
-
end
|
33
|
-
|
34
|
-
env_file
|
14
|
+
store.get(env_file_name)
|
35
15
|
end
|
36
16
|
|
37
17
|
def get_from_configuration(env_file_name)
|
@@ -40,6 +20,11 @@ class KuberKit::Core::EnvFiles::EnvFileStore
|
|
40
20
|
end
|
41
21
|
|
42
22
|
def reset!
|
43
|
-
|
23
|
+
store.reset!
|
44
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def store
|
28
|
+
@@store ||= KuberKit::Core::Store.new(KuberKit::Core::EnvFiles::AbstractEnvFile)
|
29
|
+
end
|
45
30
|
end
|
@@ -1,7 +1,4 @@
|
|
1
1
|
class KuberKit::Core::ImageStore
|
2
|
-
NotFoundError = Class.new(KuberKit::Error)
|
3
|
-
AlreadyAddedError = Class.new(KuberKit::Error)
|
4
|
-
|
5
2
|
include KuberKit::Import[
|
6
3
|
"core.image_factory",
|
7
4
|
"core.image_definition_factory",
|
@@ -16,24 +13,12 @@ class KuberKit::Core::ImageStore
|
|
16
13
|
end
|
17
14
|
|
18
15
|
def add_definition(image_definition)
|
19
|
-
|
20
|
-
|
21
|
-
unless @@image_definitions[image_definition.image_name].nil?
|
22
|
-
raise AlreadyAddedError, "image #{image_definition.image_name} was already added"
|
23
|
-
end
|
24
|
-
|
25
|
-
@@image_definitions[image_definition.image_name] = image_definition
|
16
|
+
definitions_store.add(image_definition.image_name, image_definition)
|
26
17
|
end
|
27
18
|
|
28
19
|
Contract Symbol => Any
|
29
20
|
def get_definition(image_name)
|
30
|
-
|
31
|
-
|
32
|
-
if @@image_definitions[image_name].nil?
|
33
|
-
raise NotFoundError, "image #{image_name} not found"
|
34
|
-
end
|
35
|
-
|
36
|
-
@@image_definitions[image_name]
|
21
|
+
definitions_store.get(image_name)
|
37
22
|
end
|
38
23
|
|
39
24
|
Contract Symbol => Any
|
@@ -57,6 +42,11 @@ class KuberKit::Core::ImageStore
|
|
57
42
|
end
|
58
43
|
|
59
44
|
def reset!
|
60
|
-
|
45
|
+
definitions_store.reset!
|
61
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def definitions_store
|
50
|
+
@@definitions_store ||= KuberKit::Core::Store.new(KuberKit::Core::ImageDefinition)
|
51
|
+
end
|
62
52
|
end
|
@@ -1,19 +1,6 @@
|
|
1
1
|
class KuberKit::Core::Registries::RegistryStore
|
2
|
-
NotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
-
AlreadyAddedError = Class.new(KuberKit::Error)
|
4
|
-
|
5
2
|
def add(registry)
|
6
|
-
|
7
|
-
|
8
|
-
if !registry.is_a?(KuberKit::Core::Registries::AbstractRegistry)
|
9
|
-
raise ArgumentError.new("should be an instance of KuberKit::Core::Registries::AbstractRegistry, got: #{registry.inspect}")
|
10
|
-
end
|
11
|
-
|
12
|
-
unless @@registries[registry.name].nil?
|
13
|
-
raise AlreadyAddedError, "registry #{registry.name} was already added"
|
14
|
-
end
|
15
|
-
|
16
|
-
@@registries[registry.name] = registry
|
3
|
+
store.add(registry.name, registry)
|
17
4
|
end
|
18
5
|
|
19
6
|
def get(registry_name)
|
@@ -24,14 +11,7 @@ class KuberKit::Core::Registries::RegistryStore
|
|
24
11
|
end
|
25
12
|
|
26
13
|
def get_global(registry_name)
|
27
|
-
|
28
|
-
registry = @@registries[registry_name]
|
29
|
-
|
30
|
-
if registry.nil?
|
31
|
-
raise NotFoundError, "registry '#{registry_name}' not found"
|
32
|
-
end
|
33
|
-
|
34
|
-
registry
|
14
|
+
store.get(registry_name)
|
35
15
|
end
|
36
16
|
|
37
17
|
def get_from_configuration(registry_name)
|
@@ -44,6 +24,11 @@ class KuberKit::Core::Registries::RegistryStore
|
|
44
24
|
end
|
45
25
|
|
46
26
|
def reset!
|
47
|
-
|
27
|
+
store.reset!
|
48
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def store
|
32
|
+
@@store ||= KuberKit::Core::Store.new(KuberKit::Core::Registries::AbstractRegistry)
|
33
|
+
end
|
49
34
|
end
|
@@ -1,20 +1,36 @@
|
|
1
1
|
class KuberKit::Core::Service
|
2
|
-
|
2
|
+
AttributeNotSet = Class.new(Indocker::Error)
|
3
|
+
|
4
|
+
attr_reader :name, :template_name, :tags, :images, :attributes
|
3
5
|
|
4
6
|
Contract KeywordArgs[
|
5
7
|
name: Symbol,
|
6
8
|
template_name: Symbol,
|
7
9
|
tags: ArrayOf[Symbol],
|
8
10
|
images: ArrayOf[Symbol],
|
11
|
+
attributes: HashOf[Symbol => Any],
|
9
12
|
] => Any
|
10
|
-
def initialize(name:, template_name:, tags:, images:)
|
13
|
+
def initialize(name:, template_name:, tags:, images:, attributes:)
|
11
14
|
@name = name
|
12
15
|
@template_name = template_name
|
13
16
|
@tags = tags
|
14
17
|
@images = images
|
18
|
+
@attributes = attributes
|
15
19
|
end
|
16
20
|
|
17
21
|
def uri
|
18
|
-
name.to_s.
|
22
|
+
name.to_s.gsub("_", "-")
|
23
|
+
end
|
24
|
+
|
25
|
+
def attribute(attribute_name, default: nil)
|
26
|
+
if !attributes.has_key?(attribute_name.to_sym) && default.nil?
|
27
|
+
raise AttributeNotSet, "attribute #{attribute_name} was not set"
|
28
|
+
end
|
29
|
+
|
30
|
+
if !attributes.has_key?(attribute_name.to_sym) && !default.nil?
|
31
|
+
return default
|
32
|
+
end
|
33
|
+
|
34
|
+
attributes[attribute_name.to_sym]
|
19
35
|
end
|
20
36
|
end
|
@@ -12,6 +12,7 @@ class KuberKit::Core::ServiceDefinition
|
|
12
12
|
template_name: get_value(@template_name),
|
13
13
|
tags: Array(get_value(@tags)).map(&:to_sym),
|
14
14
|
images: Array(get_value(@images)).map(&:to_sym),
|
15
|
+
attributes: get_value(@attributes),
|
15
16
|
)
|
16
17
|
end
|
17
18
|
|
@@ -33,6 +34,12 @@ class KuberKit::Core::ServiceDefinition
|
|
33
34
|
self
|
34
35
|
end
|
35
36
|
|
37
|
+
def attributes(value = nil, &block)
|
38
|
+
@attributes = block_given? ? block : value
|
39
|
+
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
36
43
|
private
|
37
44
|
def get_value(variable)
|
38
45
|
variable.is_a?(Proc) ? variable.call : variable
|
@@ -8,11 +8,15 @@ class KuberKit::Core::ServiceFactory
|
|
8
8
|
raise AttributeNotSetError, "Please set template for service using #template method"
|
9
9
|
end
|
10
10
|
|
11
|
+
configuration_attributes = KuberKit.current_configuration.service_attributes(service_attrs.name)
|
12
|
+
attributes = (service_attrs.attributes || {}).merge(configuration_attributes)
|
13
|
+
|
11
14
|
KuberKit::Core::Service.new(
|
12
15
|
name: service_attrs.name,
|
13
16
|
template_name: service_attrs.template_name,
|
14
17
|
tags: service_attrs.tags,
|
15
|
-
images: service_attrs.images
|
18
|
+
images: service_attrs.images,
|
19
|
+
attributes: attributes
|
16
20
|
)
|
17
21
|
end
|
18
22
|
end
|
@@ -1,7 +1,4 @@
|
|
1
1
|
class KuberKit::Core::ServiceStore
|
2
|
-
NotFoundError = Class.new(KuberKit::Error)
|
3
|
-
AlreadyAddedError = Class.new(KuberKit::Error)
|
4
|
-
|
5
2
|
include KuberKit::Import[
|
6
3
|
"core.service_factory",
|
7
4
|
"core.service_definition_factory",
|
@@ -16,24 +13,12 @@ class KuberKit::Core::ServiceStore
|
|
16
13
|
end
|
17
14
|
|
18
15
|
def add_definition(service_definition)
|
19
|
-
|
20
|
-
|
21
|
-
unless @@service_definitions[service_definition.service_name].nil?
|
22
|
-
raise AlreadyAddedError, "service #{service_definition.service_name} was already added"
|
23
|
-
end
|
24
|
-
|
25
|
-
@@service_definitions[service_definition.service_name] = service_definition
|
16
|
+
definitions_store.add(service_definition.service_name, service_definition)
|
26
17
|
end
|
27
18
|
|
28
19
|
Contract Symbol => Any
|
29
20
|
def get_definition(service_name)
|
30
|
-
|
31
|
-
|
32
|
-
if @@service_definitions[service_name].nil?
|
33
|
-
raise NotFoundError, "service '#{service_name}' not found"
|
34
|
-
end
|
35
|
-
|
36
|
-
@@service_definitions[service_name]
|
21
|
+
definitions_store.get(service_name)
|
37
22
|
end
|
38
23
|
|
39
24
|
Contract Symbol => Any
|
@@ -57,18 +42,23 @@ class KuberKit::Core::ServiceStore
|
|
57
42
|
end
|
58
43
|
|
59
44
|
def reset!
|
60
|
-
|
45
|
+
definitions_store.reset!
|
61
46
|
end
|
62
47
|
|
63
|
-
def
|
64
|
-
|
48
|
+
def count
|
49
|
+
definitions_store.size
|
65
50
|
end
|
66
51
|
|
67
|
-
def
|
68
|
-
|
52
|
+
def all_definitions
|
53
|
+
definitions_store.items
|
69
54
|
end
|
70
55
|
|
71
56
|
def exists?(service_name)
|
72
|
-
|
57
|
+
definitions_store.exists?(service_name)
|
73
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def definitions_store
|
62
|
+
@@definitions_store ||= KuberKit::Core::Store.new(KuberKit::Core::ServiceDefinition)
|
63
|
+
end
|
74
64
|
end
|