kuber_kit 0.6.0 → 0.6.1

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: 32c19efd73a0f79e6dd009a9e6700c184b78eacde4be6c7eb3e9571a6aa5977d
4
- data.tar.gz: 6c66868a7a280ecaccc6dcb44ee75a929ecbb057545f412dab2f57e4e8c45bc9
3
+ metadata.gz: 03c60b8fd02854d59ccad27ac3e512b726049d55f87f41d9c0ac0256344705ba
4
+ data.tar.gz: e60f2f47da61e2b5c3942878c19c863c2537bd5a6513476bb4a26aea81259674
5
5
  SHA512:
6
- metadata.gz: 8b1316dd6e65c9f81db7450c4e86c398357cd429054965ddff80634744f1ab5b1acedb638cd51c9c65040edd0c09c67429d5f884eef6c443ddb0e6bf558bd878
7
- data.tar.gz: dac99cdc86d70f8f9424f6cb9aee0e7f5630e5407f878266c6373740015a5664c3ea6c27a29c9f39985b738bc7665281f9f9ced846436f251598da16bc6517f8
6
+ metadata.gz: 85bfd81c3419a8a44960c89e9e31d06a4775aa143141fdc8da8f46ea207d60a2be53310213a5cc96cf1fe034097c13f09d10256a72d0535bb6ee363d0a12c987
7
+ data.tar.gz: 7182215530a9ee4908e4e483c578764c3bbc63f4d510c89b68bf8a2cb15a5e41bf714eb553b1497ad2236af4e585feb0e6aa810b00bb8e0f3b3ff1357e9717bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ **0.6.1**
2
+ - Improve performance of artifacts update by updating in threads.
3
+ - Added an ability to define default services
4
+
1
5
  **0.6.0**
2
6
  - Cleanup old image build dirs
3
7
  - Add rotation to deployment log file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.6.0)
4
+ kuber_kit (0.6.1)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject (~> 0.7.0)
data/TODO.md CHANGED
@@ -1,5 +1,3 @@
1
- - env files should use a separate deployment method (with change detection)
2
1
  - add automatical confirmation support for service deployer
3
2
  - template should be able to set default attributes
4
- - template should be able to depend on image?
5
- - kit status should show the list of services and their status, with ability to select & view logs
3
+ - template should be able to depend on image?
data/lib/kuber_kit.rb CHANGED
@@ -122,7 +122,7 @@ module KuberKit
122
122
 
123
123
  module ArtifactsSync
124
124
  autoload :AbstractArtifactResolver, 'artifacts_sync/abstract_artifact_resolver'
125
- autoload :ArtifactsUpdater, 'artifacts_sync/artifacts_updater'
125
+ autoload :ArtifactUpdater, 'artifacts_sync/artifact_updater'
126
126
  autoload :GitArtifactResolver, 'artifacts_sync/git_artifact_resolver'
127
127
  autoload :NullArtifactResolver, 'artifacts_sync/null_artifact_resolver'
128
128
  end
@@ -5,7 +5,7 @@ class KuberKit::Actions::ConfigurationLoader
5
5
  "core.service_store",
6
6
  "core.configuration_store",
7
7
  "tools.workdir_detector",
8
- "artifacts_sync.artifacts_updater",
8
+ "artifacts_sync.artifact_updater",
9
9
  "shell.local_shell",
10
10
  "ui",
11
11
  "configs"
@@ -43,11 +43,7 @@ class KuberKit::Actions::ConfigurationLoader
43
43
  load_infrastructure(infra_path)
44
44
 
45
45
  if load_inventory
46
- ui.create_task("Updating artifacts") do |task|
47
- artifacts = KuberKit.current_configuration.artifacts.values
48
- artifacts_updater.update(local_shell, artifacts)
49
- task.update_title("Updated #{artifacts.count} artifacts")
50
- end
46
+ update_artifacts(KuberKit.current_configuration.artifacts.values)
51
47
 
52
48
  ui.create_task("Loading image definitions") do |task|
53
49
  files = image_store.load_definitions(images_path)
@@ -101,4 +97,17 @@ class KuberKit::Actions::ConfigurationLoader
101
97
  rescue KuberKit::Shell::AbstractShell::DirNotFoundError
102
98
  ui.print_warning("ConfigurationLoader", "Directory with infrastructure not found: #{infra_path}")
103
99
  end
100
+
101
+ def update_artifacts(artifacts)
102
+ return unless artifacts.any?
103
+
104
+ artifact_task_group = ui.create_task_group
105
+ artifacts.each do |artifact|
106
+ artifact_task_group.add("Updating #{artifact.name.to_s.yellow}") do |task|
107
+ artifact_updater.update(local_shell, artifact)
108
+ task.update_title("Updated #{artifact.name.to_s.green}")
109
+ end
110
+ end
111
+ artifact_task_group.wait
112
+ end
104
113
  end
@@ -27,14 +27,17 @@ class KuberKit::Actions::ServiceDeployer
27
27
  services, tags = deployment_options_selector.call()
28
28
  end
29
29
 
30
+ default_services = current_configuration.default_services.map(&:to_s)
30
31
  disabled_services = current_configuration.disabled_services.map(&:to_s)
31
32
  disabled_services += skip_services if skip_services
33
+
32
34
 
33
35
  service_names = service_list_resolver.resolve(
34
36
  services: services || [],
35
37
  tags: tags || [],
36
38
  enabled_services: current_configuration.enabled_services.map(&:to_s),
37
- disabled_services: disabled_services
39
+ disabled_services: disabled_services,
40
+ default_services: default_services
38
41
  ).map(&:to_sym)
39
42
 
40
43
  # Return the list of services with all dependencies.
@@ -1,4 +1,4 @@
1
- class KuberKit::ArtifactsSync::ArtifactsUpdater
1
+ class KuberKit::ArtifactsSync::ArtifactUpdater
2
2
  ResolverNotFoundError = Class.new(KuberKit::NotFoundError)
3
3
 
4
4
  include KuberKit::Import[
@@ -18,18 +18,16 @@ class KuberKit::ArtifactsSync::ArtifactsUpdater
18
18
  @@resolvers[artifact_class] = artifact_resolver
19
19
  end
20
20
 
21
- def update(shell, artifacts)
21
+ def update(shell, artifact)
22
22
  add_default_resolvers
23
23
 
24
- artifacts.each do |artifact|
25
- resolver = @@resolvers[artifact.class]
24
+ resolver = @@resolvers[artifact.class]
26
25
 
27
- ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
28
-
29
- raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
26
+ ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
27
+
28
+ raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
30
29
 
31
- resolver.resolve(shell, artifact)
32
- end
30
+ resolver.resolve(shell, artifact)
33
31
  end
34
32
 
35
33
  def add_default_resolvers
data/lib/kuber_kit/cli.rb CHANGED
@@ -45,7 +45,7 @@ class KuberKit::CLI < Thor
45
45
 
46
46
  if KuberKit::Container['actions.configuration_loader'].call(options)
47
47
  require_confirmation = options[:require_confirmation] ||
48
- KuberKit.current_configuration.deployer_require_confirimation ||
48
+ KuberKit.current_configuration.deployer_require_confirmation ||
49
49
  false
50
50
  started_at = Time.now.to_i
51
51
  action_result = KuberKit::Container['actions.service_deployer'].call(
@@ -217,8 +217,8 @@ class KuberKit::Container
217
217
  KuberKit::ImageCompiler::VersionTagBuilder.new
218
218
  end
219
219
 
220
- register "artifacts_sync.artifacts_updater" do
221
- KuberKit::ArtifactsSync::ArtifactsUpdater.new
220
+ register "artifacts_sync.artifact_updater" do
221
+ KuberKit::ArtifactsSync::ArtifactUpdater.new
222
222
  end
223
223
 
224
224
  register "artifacts_sync.git_artifact_resolver" do
@@ -1,7 +1,8 @@
1
1
  class KuberKit::Core::Configuration
2
2
  attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
3
- :services_attributes, :enabled_services, :disabled_services, :build_servers, :global_build_vars,
4
- :deployer_strategy, :deployer_namespace, :deployer_require_confirimation
3
+ :services_attributes, :enabled_services, :disabled_services, :default_services,
4
+ :build_servers, :global_build_vars,
5
+ :deployer_strategy, :deployer_namespace, :deployer_require_confirmation
5
6
 
6
7
  Contract KeywordArgs[
7
8
  name: Symbol,
@@ -13,15 +14,17 @@ class KuberKit::Core::Configuration
13
14
  services_attributes: HashOf[Symbol => Hash],
14
15
  enabled_services: ArrayOf[Symbol],
15
16
  disabled_services: ArrayOf[Symbol],
17
+ default_services: ArrayOf[Symbol],
16
18
  build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
17
19
  global_build_vars: HashOf[Symbol => Any],
18
20
  deployer_strategy: Symbol,
19
21
  deployer_namespace: Maybe[Symbol],
20
- deployer_require_confirimation: Bool,
22
+ deployer_require_confirmation: Bool,
21
23
  ] => Any
22
24
  def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
23
- services_attributes:, enabled_services:, disabled_services:, build_servers:, global_build_vars:,
24
- deployer_strategy:, deployer_namespace:, deployer_require_confirimation:)
25
+ services_attributes:, enabled_services:, disabled_services:, default_services:,
26
+ build_servers:, global_build_vars:,
27
+ deployer_strategy:, deployer_namespace:, deployer_require_confirmation:)
25
28
  @name = name
26
29
  @artifacts = artifacts
27
30
  @registries = registries
@@ -32,10 +35,11 @@ class KuberKit::Core::Configuration
32
35
  @services_attributes = services_attributes
33
36
  @enabled_services = enabled_services
34
37
  @disabled_services = disabled_services
38
+ @default_services = default_services
35
39
  @global_build_vars = global_build_vars
36
40
  @deployer_strategy = deployer_strategy
37
41
  @deployer_namespace = deployer_namespace
38
- @deployer_require_confirimation = deployer_require_confirimation
42
+ @deployer_require_confirmation = deployer_require_confirmation
39
43
  end
40
44
 
41
45
  def service_attributes(service_name)
@@ -13,6 +13,7 @@ class KuberKit::Core::ConfigurationDefinition
13
13
  @build_servers = []
14
14
  @enabled_services = []
15
15
  @disabled_services = []
16
+ @default_services = []
16
17
  @services_attributes = {}
17
18
  end
18
19
 
@@ -26,12 +27,13 @@ class KuberKit::Core::ConfigurationDefinition
26
27
  kubeconfig_path: @kubeconfig_path,
27
28
  enabled_services: @enabled_services,
28
29
  disabled_services: @disabled_services,
30
+ default_services: @default_services,
29
31
  build_servers: @build_servers,
30
32
  services_attributes: @services_attributes,
31
33
  global_build_vars: @global_build_vars,
32
34
  deployer_strategy: @deployer_strategy,
33
35
  deployer_namespace: @deployer_namespace,
34
- deployer_require_confirimation: @deployer_require_confirimation || false,
36
+ deployer_require_confirmation: @deployer_require_confirmation || false,
35
37
  )
36
38
  end
37
39
 
@@ -97,11 +99,12 @@ class KuberKit::Core::ConfigurationDefinition
97
99
  self
98
100
  end
99
101
 
100
- def deployer_require_confirimation
101
- @deployer_require_confirimation = true
102
+ def deployer_require_confirmation
103
+ @deployer_require_confirmation = true
102
104
 
103
105
  self
104
106
  end
107
+ alias_method :deployer_require_confirimation, :deployer_require_confirmation
105
108
 
106
109
  def enabled_services(services)
107
110
  if services.is_a?(Hash)
@@ -118,6 +121,11 @@ class KuberKit::Core::ConfigurationDefinition
118
121
  raise KuberKit::Error, "#enabled_services method accepts only Array or Hash"
119
122
  end
120
123
 
124
+ def default_services(services)
125
+ @default_services += services.map(&:to_sym)
126
+ return self
127
+ end
128
+
121
129
  def disabled_services(services)
122
130
  @disabled_services += services.map(&:to_sym)
123
131
  return self
@@ -30,10 +30,11 @@ class KuberKit::Core::ConfigurationFactory
30
30
  services_attributes: configuration_attrs.services_attributes,
31
31
  enabled_services: configuration_attrs.enabled_services,
32
32
  disabled_services: configuration_attrs.disabled_services,
33
+ default_services: configuration_attrs.default_services,
33
34
  global_build_vars: configuration_attrs.global_build_vars || {},
34
35
  deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
35
36
  deployer_namespace: configuration_attrs.deployer_namespace,
36
- deployer_require_confirimation: configuration_attrs.deployer_require_confirimation,
37
+ deployer_require_confirmation: configuration_attrs.deployer_require_confirmation,
37
38
  )
38
39
  end
39
40
 
@@ -7,9 +7,10 @@ class KuberKit::ServiceDeployer::ServiceListResolver
7
7
  services: Optional[ArrayOf[String]],
8
8
  tags: Optional[ArrayOf[String]],
9
9
  enabled_services: Optional[ArrayOf[String]],
10
- disabled_services: Optional[ArrayOf[String]]
10
+ disabled_services: Optional[ArrayOf[String]],
11
+ default_services: Optional[ArrayOf[String]]
11
12
  ] => ArrayOf[String]
12
- def resolve(services: [], tags: [], enabled_services: [], disabled_services: [])
13
+ def resolve(services: [], tags: [], enabled_services: [], disabled_services: [], default_services: [])
13
14
  all_definitions = service_store.all_definitions.values
14
15
 
15
16
  included_services, excluded_services = split_by_inclusion(services)
@@ -41,6 +42,10 @@ class KuberKit::ServiceDeployer::ServiceListResolver
41
42
  included_services = included_services.select{ |s| !disabled_services.include?(s) }
42
43
  end
43
44
 
45
+ if included_services.any?
46
+ included_services += default_services
47
+ end
48
+
44
49
  included_services
45
50
  end
46
51
 
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
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.6.0
4
+ version: 0.6.1
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-07-08 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite
@@ -236,7 +236,7 @@ files:
236
236
  - lib/kuber_kit/actions/service_reader.rb
237
237
  - lib/kuber_kit/actions/template_reader.rb
238
238
  - lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb
239
- - lib/kuber_kit/artifacts_sync/artifacts_updater.rb
239
+ - lib/kuber_kit/artifacts_sync/artifact_updater.rb
240
240
  - lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
241
241
  - lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb
242
242
  - lib/kuber_kit/cli.rb