kuber_kit 0.5.5 → 0.5.6

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: 87f41f4c189d1bb0420bc1db160dbd53c1b2769541b0ad0e772a9b74f20cd3ed
4
- data.tar.gz: d2b92edffabbe62b11801d09bd5f81cfd7a27be52aa0cea04ade796bc311f370
3
+ metadata.gz: 185201d6f305a1e69b2d5ec982288234454404bb9b87501130f159fb58a3b97a
4
+ data.tar.gz: e411255031c65afe38e7b0faa20e9b578b2d3eca93a3bb9dc013766a59c7d2b1
5
5
  SHA512:
6
- metadata.gz: 0fcbdb08cf391d2ff480a7490261d7508f6e7d970b09091893fa4f6eb7338661df4f42349031303f16db404b74f3ca1f7fe9ec4f699f1c9052358cb661a2e4f8
7
- data.tar.gz: 922e179ff88f29dcb15f64a66a4e6fb43c7ee63b5a44be44a86ba401b64685997af1bf370281be36e332e729347e27e2f8f6d8f8f6a5b648bd3a2f6205c079d6
6
+ metadata.gz: 936fd6032488908db1fffe95f736dd05042c499f2995be2bc28566b2f65d9d5b35150acc0cf08de50442c16408d56d623292bb8e051215bfc15b8aba804266cc
7
+ data.tar.gz: c81b1a227cf5690d675b0b8d269382f0bb6d13ed71cfc3442679e1bd7471b995e02e7177b6c93bfb6955792bd591708c0ea017f9ea52291992bbbd0e5b33c0e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ **0.5.6**
2
+ - Pre-process env file if it has .erb extension
3
+ - Allow attaching env file from configuration to docker container
4
+ - Change default data paths to use home directory
5
+ - Add env groups support to combine multiple env files
6
+
1
7
  **0.5.5**
2
8
  - Added ability to skip services during deployment using -S option
3
9
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.5.5)
4
+ kuber_kit (0.5.6)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
@@ -14,7 +14,7 @@ GEM
14
14
  specs:
15
15
  cli-ui (1.5.1)
16
16
  coderay (1.1.3)
17
- concurrent-ruby (1.1.8)
17
+ concurrent-ruby (1.1.9)
18
18
  contracts-lite (0.15.0)
19
19
  diff-lcs (1.4.4)
20
20
  docile (1.3.2)
@@ -26,7 +26,7 @@ GEM
26
26
  dry-container (0.7.2)
27
27
  concurrent-ruby (~> 1.0)
28
28
  dry-configurable (~> 0.1, >= 0.1.3)
29
- dry-core (0.5.0)
29
+ dry-core (0.6.0)
30
30
  concurrent-ruby (~> 1.0)
31
31
  method_source (1.0.0)
32
32
  net-ssh (6.1.0)
@@ -7,6 +7,7 @@ KuberKit
7
7
  detached: false,
8
8
  image_name: :ruby_app,
9
9
  container_name: "test_docker_app",
10
- delete_if_exists: true
10
+ delete_if_exists: true,
11
+ env_file_names: [:test]
11
12
  }
12
13
  )
data/lib/kuber_kit.rb CHANGED
@@ -54,6 +54,7 @@ module KuberKit
54
54
  autoload :EnvFileStore, 'core/env_files/env_file_store'
55
55
  autoload :AbstractEnvFile, 'core/env_files/abstract_env_file'
56
56
  autoload :ArtifactFile, 'core/env_files/artifact_file'
57
+ autoload :EnvGroup, 'core/env_files/env_group'
57
58
  end
58
59
 
59
60
  module ContextHelper
@@ -127,10 +128,13 @@ module KuberKit
127
128
  module EnvFileReader
128
129
  autoload :ActionHandler, 'env_file_reader/action_handler'
129
130
  autoload :Reader, 'env_file_reader/reader'
131
+ autoload :EnvFileParser, 'env_file_reader/env_file_parser'
132
+ autoload :EnvFileTempfileCreator, 'env_file_reader/env_file_tempfile_creator'
130
133
 
131
134
  module Strategies
132
135
  autoload :Abstract, 'env_file_reader/strategies/abstract'
133
136
  autoload :ArtifactFile, 'env_file_reader/strategies/artifact_file'
137
+ autoload :EnvGroup, 'env_file_reader/strategies/env_group'
134
138
  end
135
139
  end
136
140
 
@@ -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, :deploy_simultaneous_limit,
8
- :additional_images_paths, :deprecation_warnings_disabled, :log_file_path
8
+ :additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir
9
9
  ]
10
10
  DOCKER_IGNORE_LIST = [
11
11
  'Dockerfile',
@@ -34,10 +34,12 @@ class KuberKit::Configs
34
34
  end
35
35
 
36
36
  def add_default_configs
37
+ home_kuber_kit_path = File.expand_path(File.join("~", ".kuber_kit"))
38
+
37
39
  set :image_dockerfile_name, "Dockerfile"
38
40
  set :image_build_context_dir, "build_context"
39
41
  set :image_tag, 'latest'
40
- set :image_compile_dir, "/tmp/kuber_kit/image_builds"
42
+ set :image_compile_dir, File.join(home_kuber_kit_path, "image_builds")
41
43
  set :docker_ignore_list, DOCKER_IGNORE_LIST
42
44
  set :kuber_kit_dirname, "kuber_kit"
43
45
  set :kuber_kit_min_version, KuberKit::VERSION
@@ -45,14 +47,15 @@ class KuberKit::Configs
45
47
  set :services_dirname, "services"
46
48
  set :infra_dirname, "infrastructure"
47
49
  set :configurations_dirname, "configurations"
48
- set :artifact_clone_dir, "/tmp/kuber_kit/artifacts"
49
- set :service_config_dir, "/tmp/kuber_kit/services"
50
+ set :artifact_clone_dir, File.join(home_kuber_kit_path, "artifacts")
51
+ set :service_config_dir, File.join(home_kuber_kit_path, "services")
50
52
  set :deployer_strategy, :kubernetes
51
53
  set :compile_simultaneous_limit, 5
52
54
  set :deploy_simultaneous_limit, 5
53
55
  set :additional_images_paths, []
54
56
  set :deprecation_warnings_disabled, false
55
- set :log_file_path, "/tmp/kuber_kit.log"
57
+ set :log_file_path, File.join(home_kuber_kit_path, "deploy.log")
58
+ set :env_file_compile_dir, File.join(home_kuber_kit_path, "env_files")
56
59
  end
57
60
 
58
61
  def items
@@ -229,10 +229,22 @@ class KuberKit::Container
229
229
  KuberKit::EnvFileReader::Reader.new
230
230
  end
231
231
 
232
+ register "env_file_reader.env_file_parser" do
233
+ KuberKit::EnvFileReader::EnvFileParser.new
234
+ end
235
+
236
+ register "env_file_reader.env_file_tempfile_creator" do
237
+ KuberKit::EnvFileReader::EnvFileTempfileCreator.new
238
+ end
239
+
232
240
  register "env_file_reader.strategies.artifact_file" do
233
241
  KuberKit::EnvFileReader::Strategies::ArtifactFile.new
234
242
  end
235
243
 
244
+ register "env_file_reader.strategies.env_group" do
245
+ KuberKit::EnvFileReader::Strategies::EnvGroup.new
246
+ end
247
+
236
248
  register "template_reader.action_handler" do
237
249
  KuberKit::TemplateReader::ActionHandler.new
238
250
  end
@@ -3,6 +3,7 @@ class KuberKit::Core::Artifacts::ArtifactStore
3
3
  store.add(artifact.name, artifact)
4
4
  end
5
5
 
6
+ Contract Symbol => Maybe[KuberKit::Core::Artifacts::AbstractArtifact]
6
7
  def get(artifact_name)
7
8
  artifact = get_from_configuration(artifact_name) ||
8
9
  get_global(artifact_name)
@@ -10,10 +11,12 @@ class KuberKit::Core::Artifacts::ArtifactStore
10
11
  artifact
11
12
  end
12
13
 
14
+ Contract Symbol => Maybe[KuberKit::Core::Artifacts::AbstractArtifact]
13
15
  def get_global(artifact_name)
14
16
  store.get(artifact_name)
15
17
  end
16
18
 
19
+ Contract Symbol => Maybe[KuberKit::Core::Artifacts::AbstractArtifact]
17
20
  def get_from_configuration(artifact_name)
18
21
  artifacts = KuberKit.current_configuration.artifacts
19
22
  artifacts[artifact_name]
@@ -6,4 +6,8 @@ class KuberKit::Core::EnvFiles::AbstractEnvFile
6
6
  def initialize(env_file_name)
7
7
  @name = env_file_name
8
8
  end
9
+
10
+ def uniq_name
11
+ @name.to_s
12
+ end
9
13
  end
@@ -6,4 +6,8 @@ class KuberKit::Core::EnvFiles::ArtifactFile < KuberKit::Core::EnvFiles::Abstrac
6
6
  @artifact_name = artifact_name
7
7
  @file_path = file_path
8
8
  end
9
+
10
+ def uniq_name
11
+ [@artifact_name.to_s, @name.to_s].join("-")
12
+ end
9
13
  end
@@ -3,6 +3,7 @@ class KuberKit::Core::EnvFiles::EnvFileStore
3
3
  store.add(env_file.name, env_file)
4
4
  end
5
5
 
6
+ Contract Symbol => Maybe[KuberKit::Core::EnvFiles::AbstractEnvFile]
6
7
  def get(env_file_name)
7
8
  env_file = get_from_configuration(env_file_name) ||
8
9
  get_global(env_file_name)
@@ -10,10 +11,12 @@ class KuberKit::Core::EnvFiles::EnvFileStore
10
11
  env_file
11
12
  end
12
13
 
14
+ Contract Symbol => Maybe[KuberKit::Core::EnvFiles::AbstractEnvFile]
13
15
  def get_global(env_file_name)
14
16
  store.get(env_file_name)
15
17
  end
16
18
 
19
+ Contract Symbol => Maybe[KuberKit::Core::EnvFiles::AbstractEnvFile]
17
20
  def get_from_configuration(env_file_name)
18
21
  env_files = KuberKit.current_configuration.env_files
19
22
  env_files[env_file_name]
@@ -0,0 +1,12 @@
1
+ class KuberKit::Core::EnvFiles::EnvGroup < KuberKit::Core::EnvFiles::AbstractEnvFile
2
+ attr_reader :env_files
3
+
4
+ def initialize(env_group_name, env_files:)
5
+ super(env_group_name)
6
+ @env_files = env_files
7
+ end
8
+
9
+ def uniq_name
10
+ "env-group-#{@name.to_s}"
11
+ end
12
+ end
@@ -3,6 +3,7 @@ class KuberKit::Core::Registries::RegistryStore
3
3
  store.add(registry.name, registry)
4
4
  end
5
5
 
6
+ Contract Symbol => Maybe[KuberKit::Core::Registries::AbstractRegistry]
6
7
  def get(registry_name)
7
8
  registry = get_from_configuration(registry_name) ||
8
9
  get_global(registry_name)
@@ -10,10 +11,12 @@ class KuberKit::Core::Registries::RegistryStore
10
11
  registry
11
12
  end
12
13
 
14
+ Contract Symbol => Maybe[KuberKit::Core::Registries::AbstractRegistry]
13
15
  def get_global(registry_name)
14
16
  store.get(registry_name)
15
17
  end
16
18
 
19
+ Contract Symbol => Maybe[KuberKit::Core::Registries::AbstractRegistry]
17
20
  def get_from_configuration(registry_name)
18
21
  registries = KuberKit.current_configuration.registries
19
22
  registries[registry_name]
@@ -3,6 +3,7 @@ class KuberKit::Core::Templates::TemplateStore
3
3
  store.add(template.name, template)
4
4
  end
5
5
 
6
+ Contract Symbol => Maybe[KuberKit::Core::Templates::AbstractTemplate]
6
7
  def get(template_name)
7
8
  template = get_from_configuration(template_name) ||
8
9
  get_global(template_name)
@@ -10,10 +11,12 @@ class KuberKit::Core::Templates::TemplateStore
10
11
  template
11
12
  end
12
13
 
14
+ Contract Symbol => Maybe[KuberKit::Core::Templates::AbstractTemplate]
13
15
  def get_global(template_name)
14
16
  store.get(template_name)
15
17
  end
16
18
 
19
+ Contract Symbol => Maybe[KuberKit::Core::Templates::AbstractTemplate]
17
20
  def get_from_configuration(template_name)
18
21
  templates = KuberKit.current_configuration.templates
19
22
  templates[template_name]
@@ -0,0 +1,51 @@
1
+ class KuberKit::EnvFileReader::EnvFileParser
2
+ # Parser is based on:
3
+ # https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb
4
+ LINE = /
5
+ (?:^|\A) # beginning of line
6
+ \s* # leading whitespace
7
+ (?:export\s+)? # optional export
8
+ ([\w\.]+) # key
9
+ (?:\s*=\s*?|:\s+?) # separator
10
+ ( # optional value begin
11
+ \s*'(?:\\'|[^'])*' # single quoted value
12
+ | # or
13
+ \s*"(?:\\"|[^"])*" # double quoted value
14
+ | # or
15
+ [^\#\r\n]+ # unquoted value
16
+ )? # value end
17
+ \s* # trailing whitespace
18
+ (?:\#.*)? # optional comment
19
+ (?:$|\z) # end of line
20
+ /x
21
+
22
+ Contract String => Hash
23
+ def call(string)
24
+ hash = {}
25
+ string.gsub(/\r\n?/, "\n").scan(LINE).each do |key, value|
26
+ hash[key] = parse_value(value || "")
27
+ end
28
+ hash
29
+ end
30
+
31
+ private
32
+
33
+ def parse_value(value)
34
+ # Remove surrounding quotes
35
+ value = value.strip.sub(/\A(['"])(.*)\1\z/m, '\2')
36
+
37
+ if Regexp.last_match(1) == '"'
38
+ value = unescape_characters(expand_newlines(value))
39
+ end
40
+
41
+ value
42
+ end
43
+
44
+ def unescape_characters(value)
45
+ value.gsub(/\\([^$])/, '\1')
46
+ end
47
+
48
+ def expand_newlines(value)
49
+ value.gsub('\n', "\n").gsub('\r', "\r")
50
+ end
51
+ end
@@ -0,0 +1,17 @@
1
+ class KuberKit::EnvFileReader::EnvFileTempfileCreator
2
+ include KuberKit::Import[
3
+ "env_file_reader.reader",
4
+ "configs"
5
+ ]
6
+
7
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::EnvFiles::AbstractEnvFile => String
8
+ def call(shell, env_file)
9
+ env_file_hash = reader.read(shell, env_file)
10
+ env_file_raw = env_file_hash.to_a.map{|k,v| "#{k}=#{v}"}.join("\r\n")
11
+ temp_file_path = File.join(configs.env_file_compile_dir, env_file.uniq_name)
12
+
13
+ shell.write(temp_file_path, env_file_raw)
14
+
15
+ temp_file_path
16
+ end
17
+ end
@@ -3,6 +3,7 @@ class KuberKit::EnvFileReader::Reader
3
3
 
4
4
  include KuberKit::Import[
5
5
  "env_file_reader.strategies.artifact_file",
6
+ "env_file_reader.strategies.env_group",
6
7
  ]
7
8
 
8
9
  def initialize(**injected_deps)
@@ -35,5 +36,6 @@ class KuberKit::EnvFileReader::Reader
35
36
  private
36
37
  def add_default_strategies
37
38
  use_reader(artifact_file, env_file_class: KuberKit::Core::EnvFiles::ArtifactFile)
39
+ use_reader(env_group, env_file_class: KuberKit::Core::EnvFiles::EnvGroup)
38
40
  end
39
41
  end
@@ -1,8 +1,12 @@
1
1
  class KuberKit::EnvFileReader::Strategies::ArtifactFile < KuberKit::EnvFileReader::Strategies::Abstract
2
2
  include KuberKit::Import[
3
- "core.artifact_store"
3
+ "core.artifact_store",
4
+ "env_file_reader.env_file_parser",
5
+ "preprocessing.text_preprocessor"
4
6
  ]
5
7
 
8
+ PREPROCESS_EXTENSIONS = [".erb"]
9
+
6
10
  def read(shell, env_file)
7
11
  artifact = artifact_store.get(env_file.artifact_name)
8
12
 
@@ -16,71 +20,11 @@ class KuberKit::EnvFileReader::Strategies::ArtifactFile < KuberKit::EnvFileReade
16
20
  def read_file(shell, file_path)
17
21
  result = {}
18
22
  content = shell.read(file_path)
19
- Parser.call(content)
20
- end
21
-
22
- # Parser is based on:
23
- # https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb
24
- class Parser
25
- LINE = /
26
- (?:^|\A) # beginning of line
27
- \s* # leading whitespace
28
- (?:export\s+)? # optional export
29
- ([\w\.]+) # key
30
- (?:\s*=\s*?|:\s+?) # separator
31
- ( # optional value begin
32
- \s*'(?:\\'|[^'])*' # single quoted value
33
- | # or
34
- \s*"(?:\\"|[^"])*" # double quoted value
35
- | # or
36
- [^\#\r\n]+ # unquoted value
37
- )? # value end
38
- \s* # trailing whitespace
39
- (?:\#.*)? # optional comment
40
- (?:$|\z) # end of line
41
- /x
42
-
43
- class << self
44
- def call(string, is_load = false)
45
- new(string, is_load).call
23
+ enable_preprocessing = PREPROCESS_EXTENSIONS.any?{ |e| e == File.extname(file_path) }
24
+ if enable_preprocessing
25
+ content = text_preprocessor.compile(content)
46
26
  end
47
- end
48
27
 
49
- def initialize(string, is_load = false)
50
- @string = string
51
- @hash = {}
52
- @is_load = is_load
28
+ env_file_parser.call(content)
53
29
  end
54
-
55
- def call
56
- # Convert line breaks to same format
57
- lines = @string.gsub(/\r\n?/, "\n")
58
- # Process matches
59
- lines.scan(LINE).each do |key, value|
60
- @hash[key] = parse_value(value || "")
61
- end
62
- @hash
63
- end
64
-
65
- private
66
-
67
- def parse_value(value)
68
- # Remove surrounding quotes
69
- value = value.strip.sub(/\A(['"])(.*)\1\z/m, '\2')
70
-
71
- if Regexp.last_match(1) == '"'
72
- value = unescape_characters(expand_newlines(value))
73
- end
74
-
75
- value
76
- end
77
-
78
- def unescape_characters(value)
79
- value.gsub(/\\([^$])/, '\1')
80
- end
81
-
82
- def expand_newlines(value)
83
- value.gsub('\n', "\n").gsub('\r', "\r")
84
- end
85
- end
86
30
  end
@@ -0,0 +1,21 @@
1
+ class KuberKit::EnvFileReader::Strategies::EnvGroup < KuberKit::EnvFileReader::Strategies::Abstract
2
+ include KuberKit::Import[
3
+ "env_file_reader.strategies.artifact_file",
4
+ "core.env_file_store",
5
+ ]
6
+
7
+ def read(shell, env_group)
8
+ content = {}
9
+ env_group.env_files.each do |env_file_name|
10
+ env_file = env_file_store.get(env_file_name)
11
+
12
+ if env_file.is_a?(KuberKit::Core::EnvFiles::EnvGroup)
13
+ raise "EnvGroup inside another EnvGroup is not supported"
14
+ end
15
+
16
+ result = artifact_file.read(shell, env_file)
17
+ content = content.merge(result)
18
+ end
19
+ content
20
+ end
21
+ end
@@ -1,6 +1,8 @@
1
1
  class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer::Strategies::Abstract
2
2
  include KuberKit::Import[
3
+ "env_file_reader.env_file_tempfile_creator",
3
4
  "shell.docker_commands",
5
+ "core.env_file_store",
4
6
  "core.image_store",
5
7
  "configs",
6
8
  ]
@@ -18,6 +20,7 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
18
20
  :networks,
19
21
  :expose,
20
22
  :publish,
23
+ :env_file_names
21
24
  ]
22
25
 
23
26
  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
@@ -28,16 +31,19 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
28
31
  raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
29
32
  end
30
33
 
31
- namespace = strategy_options.fetch(:namespace, nil)
32
- container_name = strategy_options.fetch(:container_name, [namespace, service.name].compact.join("_"))
33
- command_name = strategy_options.fetch(:command_name, nil)
34
- env_file = strategy_options.fetch(:env_file, nil)
35
- custom_args = strategy_options.fetch(:custom_args, nil)
36
- networks = strategy_options.fetch(:networks, [])
37
- volumes = strategy_options.fetch(:volumes, [])
38
- expose_ports = strategy_options.fetch(:expose, [])
39
- publish_ports = strategy_options.fetch(:publish, [])
40
- hostname = strategy_options.fetch(:hostname, container_name)
34
+ namespace = strategy_options.fetch(:namespace, nil)
35
+ container_name = strategy_options.fetch(:container_name, [namespace, service.name].compact.join("_"))
36
+ command_name = strategy_options.fetch(:command_name, nil)
37
+ custom_env_file = strategy_options.fetch(:env_file, nil)
38
+ custom_args = strategy_options.fetch(:custom_args, nil)
39
+ networks = strategy_options.fetch(:networks, [])
40
+ volumes = strategy_options.fetch(:volumes, [])
41
+ expose_ports = strategy_options.fetch(:expose, [])
42
+ publish_ports = strategy_options.fetch(:publish, [])
43
+ hostname = strategy_options.fetch(:hostname, container_name)
44
+
45
+ env_file_names = strategy_options.fetch(:env_file_names, [])
46
+ env_files = prepare_env_files(shell, env_file_names)
41
47
 
42
48
  image_name = strategy_options.fetch(:image_name, nil)
43
49
  if image_name.nil?
@@ -54,8 +60,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
54
60
  if container_name
55
61
  custom_args << "--name #{container_name}"
56
62
  end
57
- if env_file
58
- custom_args << "--env-file #{env_file}"
63
+ if custom_env_file
64
+ custom_args << "--env-file #{custom_env_file}"
59
65
  end
60
66
  if hostname
61
67
  custom_args << "--hostname #{hostname}"
@@ -75,6 +81,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
75
81
  Array(publish_ports).each do |publish_port|
76
82
  custom_args << "--publish #{publish_port}"
77
83
  end
84
+ Array(env_files).each do |env_file|
85
+ custom_args << "--env-file #{env_file}"
86
+ end
78
87
 
79
88
  docker_commands.run(
80
89
  shell, image.remote_registry_url,
@@ -84,4 +93,14 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
84
93
  interactive: !strategy_options[:detached]
85
94
  )
86
95
  end
96
+
97
+ private
98
+ def prepare_env_files(shell, env_file_names)
99
+ env_files = env_file_names.map do |env_file_name|
100
+ env_file_store.get(env_file_name)
101
+ end
102
+ env_files.map do |env_file|
103
+ env_file_tempfile_creator.call(shell, env_file)
104
+ end
105
+ end
87
106
  end
@@ -3,10 +3,10 @@ class KuberKit::TemplateReader::Strategies::ArtifactFile < KuberKit::TemplateRea
3
3
  "core.artifact_store"
4
4
  ]
5
5
 
6
- def read(shell, env_file)
7
- artifact = artifact_store.get(env_file.artifact_name)
6
+ def read(shell, template)
7
+ artifact = artifact_store.get(template.artifact_name)
8
8
 
9
- file_parts = [artifact.cloned_path, env_file.file_path].compact
9
+ file_parts = [artifact.cloned_path, template.file_path].compact
10
10
  file_path = File.join(*file_parts)
11
11
 
12
12
  shell.read(file_path)
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'fileutils'
2
3
 
3
4
  class KuberKit::Tools::LoggerFactory
4
5
  SEVERITY_COLORS_BY_LEVEL = {
@@ -14,6 +15,10 @@ class KuberKit::Tools::LoggerFactory
14
15
  ]
15
16
 
16
17
  def create(stdout = nil, level = nil)
18
+ if !stdout
19
+ prepare_log_file(configs.log_file_path)
20
+ end
21
+
17
22
  logger = Logger.new(stdout || configs.log_file_path)
18
23
 
19
24
  logger.level = level || Logger::DEBUG
@@ -35,4 +40,13 @@ class KuberKit::Tools::LoggerFactory
35
40
 
36
41
  logger
37
42
  end
43
+
44
+ private
45
+ def prepare_log_file(file_path)
46
+ dir_path = File.dirname(file_path)
47
+ unless Dir.exists?(dir_path)
48
+ FileUtils.mkdir_p(dir_path)
49
+ end
50
+ FileUtils.touch(file_path)
51
+ end
38
52
  end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
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.5.5
4
+ version: 0.5.6
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-05-12 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite
@@ -245,6 +245,7 @@ files:
245
245
  - lib/kuber_kit/core/env_files/abstract_env_file.rb
246
246
  - lib/kuber_kit/core/env_files/artifact_file.rb
247
247
  - lib/kuber_kit/core/env_files/env_file_store.rb
248
+ - lib/kuber_kit/core/env_files/env_group.rb
248
249
  - lib/kuber_kit/core/image.rb
249
250
  - lib/kuber_kit/core/image_definition.rb
250
251
  - lib/kuber_kit/core/image_definition_factory.rb
@@ -263,9 +264,12 @@ files:
263
264
  - lib/kuber_kit/core/templates/artifact_file.rb
264
265
  - lib/kuber_kit/core/templates/template_store.rb
265
266
  - lib/kuber_kit/env_file_reader/action_handler.rb
267
+ - lib/kuber_kit/env_file_reader/env_file_parser.rb
268
+ - lib/kuber_kit/env_file_reader/env_file_tempfile_creator.rb
266
269
  - lib/kuber_kit/env_file_reader/reader.rb
267
270
  - lib/kuber_kit/env_file_reader/strategies/abstract.rb
268
271
  - lib/kuber_kit/env_file_reader/strategies/artifact_file.rb
272
+ - lib/kuber_kit/env_file_reader/strategies/env_group.rb
269
273
  - lib/kuber_kit/extensions/colored_string.rb
270
274
  - lib/kuber_kit/extensions/contracts.rb
271
275
  - lib/kuber_kit/extensions/indocker_compat.rb