kuber_kit 0.3.8 → 0.3.9

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdefb838f103f417001c7ff0167d95bc985a1db8b8b97b505426e5f2b98db7f3
4
- data.tar.gz: 13f8f1103796553e56a874064e36a33e66931e73917a141e6fad049c5ced73da
3
+ metadata.gz: 8321dfb87de00ef987aa2c826e5310fd721664135b90e194562a9c9f26ad044e
4
+ data.tar.gz: dccbfdc6df8ed8bedd6e6d30ddfd576c42c1a12ec36aa465769a1fcc207d38af
5
5
  SHA512:
6
- metadata.gz: cbd45f1537f9ecc3b2d29a090f85921b47ffda91093aefa7f150d5101ff3bc147f30966febdb37352e6dfb3f7e245a84423a649a0f9d9cdd586dd597634be96c
7
- data.tar.gz: 947ced5481b927993ed9462255fcf7ed656c718e9642fc0f8888b14a41aa630947b89d96f56d9b5a571956c5475c6e711c3a1b604e333b617a5208292e39e9ca
6
+ metadata.gz: cde945512a525f1ef577f540ae3919bc602d442fb44eb14505fe2a4761ad1c15061f9bab1540b9b8de2592cf4d4f4f7396bfe451499af45cd6198659ad7cfaeb
7
+ data.tar.gz: cca667290f77ff94934ce302666655d1bdefc414f074915c8a6d091590786b20ff2aa26a04c02f9d07b5e3c88f2e48439c3cbe71add7d374ea255deda753e125
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.3.8)
4
+ kuber_kit (0.3.9)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
@@ -5,7 +5,7 @@ class KuberKit::Configs
5
5
  :image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir,
6
6
  :kuber_kit_dirname, :kuber_kit_min_version, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
7
7
  :artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit,
8
- :additional_images_paths, :deprecation_warnings_disabled
8
+ :additional_images_paths, :deprecation_warnings_disabled, :log_file_path
9
9
  ]
10
10
  DOCKER_IGNORE_LIST = [
11
11
  'Dockerfile',
@@ -51,6 +51,7 @@ class KuberKit::Configs
51
51
  set :compile_simultaneous_limit, 5
52
52
  set :additional_images_paths, []
53
53
  set :deprecation_warnings_disabled, false
54
+ set :log_file_path, "/tmp/kuber_kit.log"
54
55
  end
55
56
 
56
57
  def items
@@ -114,7 +114,7 @@ class KuberKit::Container
114
114
  end
115
115
 
116
116
  register "tools.logger" do
117
- KuberKit::Container["tools.logger_factory"].create("/tmp/kuber_kit.log")
117
+ KuberKit::Container["tools.logger_factory"].create()
118
118
  end
119
119
 
120
120
  register "shell.bash_commands" do
@@ -4,11 +4,11 @@ class KuberKit::Core::Service
4
4
  attr_reader :name, :template_name, :tags, :images, :attributes, :deployer_strategy
5
5
 
6
6
  Contract KeywordArgs[
7
- name: Symbol,
8
- template_name: Symbol,
9
- tags: ArrayOf[Symbol],
10
- images: ArrayOf[Symbol],
11
- attributes: HashOf[Symbol => Any],
7
+ name: Symbol,
8
+ template_name: Maybe[Symbol],
9
+ tags: ArrayOf[Symbol],
10
+ images: ArrayOf[Symbol],
11
+ attributes: HashOf[Symbol => Any],
12
12
  deployer_strategy: Maybe[Symbol]
13
13
  ] => Any
14
14
  def initialize(name:, template_name:, tags:, images:, attributes:, deployer_strategy:)
@@ -1,13 +1,7 @@
1
1
  class KuberKit::Core::ServiceFactory
2
- AttributeNotSetError = Class.new(KuberKit::Error)
3
-
4
2
  def create(definition)
5
3
  service_attrs = definition.to_service_attrs
6
4
 
7
- if service_attrs.template_name.nil?
8
- raise AttributeNotSetError, "Please set template for service using #template method"
9
- end
10
-
11
5
  configuration_attributes = KuberKit.current_configuration.service_attributes(service_attrs.name)
12
6
  attributes = (service_attrs.attributes || {}).merge(configuration_attributes)
13
7
 
@@ -9,8 +9,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
9
9
  :container_name,
10
10
  :image_name,
11
11
  :detached,
12
- :docker_run_args,
13
- :docker_run_command,
12
+ :command_name,
13
+ :command_args,
14
14
  :delete_if_exists
15
15
  ]
16
16
 
@@ -22,9 +22,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
22
22
  raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
23
23
  end
24
24
 
25
- container_name = strategy_options.fetch(:container_name, service.uri)
26
- docker_run_args = strategy_options.fetch(:docker_run_args, nil)
27
- docker_run_command = strategy_options.fetch(:docker_run_command, nil)
25
+ container_name = strategy_options.fetch(:container_name, service.uri)
26
+ command_name = strategy_options.fetch(:command_name, "bash")
27
+ command_args = strategy_options.fetch(:command_args, nil)
28
28
 
29
29
  image_name = strategy_options.fetch(:image_name, nil)
30
30
  if image_name.nil?
@@ -39,9 +39,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
39
39
 
40
40
  docker_commands.run(
41
41
  shell, image.remote_registry_url,
42
- run_args: docker_run_args,
43
- run_command: docker_run_command,
44
- detached: !!strategy_options[:detached]
42
+ command: command_name,
43
+ args: command_args,
44
+ detached: !!strategy_options[:detached]
45
45
  )
46
46
  end
47
47
  end
@@ -8,6 +8,7 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
8
8
  STRATEGY_OPTIONS = [
9
9
  :service_name,
10
10
  :command_name,
11
+ :command_args,
11
12
  :detached
12
13
  ]
13
14
 
@@ -25,10 +26,12 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
25
26
 
26
27
  service_name = strategy_options.fetch(:service_name, service.name.to_s)
27
28
  command_name = strategy_options.fetch(:command_name, "bash")
29
+ command_args = strategy_options.fetch(:command_args, nil)
28
30
 
29
31
  docker_compose_commands.run(shell, config_path,
30
32
  service: service_name,
31
33
  command: command_name,
34
+ args: command_args,
32
35
  detached: !!strategy_options[:detached]
33
36
  )
34
37
  end
@@ -6,8 +6,14 @@ class KuberKit::ServiceReader::Reader
6
6
  "preprocessing.text_preprocessor"
7
7
  ]
8
8
 
9
+ AttributeNotSetError = Class.new(KuberKit::Error)
10
+
9
11
  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
10
12
  def read(shell, service)
13
+ if service.template_name.nil?
14
+ raise AttributeNotSetError, "Please set template for service using #template method"
15
+ end
16
+
11
17
  template = template_store.get(service.template_name)
12
18
 
13
19
  context_helper = context_helper_factory.build_service_context(shell, service)
@@ -14,15 +14,19 @@ class KuberKit::Shell::Commands::DockerCommands
14
14
  shell.exec!(%Q{docker push #{tag_name}})
15
15
  end
16
16
 
17
- def run(shell, image_name, run_args: nil, run_command: nil, detached: false)
17
+ def run(shell, image_name, args: nil, command: nil, detached: false, interactive: false)
18
18
  command_parts = []
19
19
  command_parts << "docker run"
20
20
  command_parts << "-d" if detached
21
- command_parts << run_args if run_args
21
+ command_parts << args if args
22
22
  command_parts << image_name
23
- command_parts << run_command if run_command
23
+ command_parts << command if command
24
24
 
25
- shell.exec!(command_parts.join(" "))
25
+ if interactive
26
+ shell.interactive!(command_parts.join(" "))
27
+ else
28
+ shell.exec!(command_parts.join(" "))
29
+ end
26
30
  end
27
31
 
28
32
  def container_exists?(shell, container_name)
@@ -1,17 +1,16 @@
1
1
  class KuberKit::Shell::Commands::DockerComposeCommands
2
- def run(shell, path, service:, command:, interactive: false, detached: false)
2
+ def run(shell, path, service:, args: nil, command: nil, detached: false, interactive: false)
3
3
  command_parts = [
4
4
  "docker-compose",
5
5
  "-f #{path}",
6
6
  "run",
7
7
  ]
8
8
 
9
- if detached
10
- command_parts << "-d"
11
- end
12
9
 
10
+ command_parts << "-d" if detached
11
+ command_parts << args if args
13
12
  command_parts << service
14
- command_parts << command
13
+ command_parts << command if command
15
14
 
16
15
  if interactive
17
16
  shell.interactive!(command_parts.join(" "))
@@ -9,8 +9,12 @@ class KuberKit::Tools::LoggerFactory
9
9
  Logger::FATAL => String::Colors::PURPLE,
10
10
  }
11
11
 
12
- def create(stdout, level = nil)
13
- logger = Logger.new(stdout)
12
+ include KuberKit::Import[
13
+ "configs",
14
+ ]
15
+
16
+ def create(stdout = nil, level = nil)
17
+ logger = Logger.new(stdout || configs.log_file_path)
14
18
 
15
19
  logger.level = level || Logger::DEBUG
16
20
 
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
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.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite