kuber_kit 0.4.1 → 0.4.2

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: f98d973c015745f6a4ccf054e3b97edbd8302683f747842ad6c9c5b3e4e49087
4
- data.tar.gz: f2e8eb96e320bc73c1c3b03c611d1990515bd55182a93f30b28966b63da0c591
3
+ metadata.gz: b6b58c988d13591ad950347cc3c2af370ab1604006d1ad0d04cf9cf43093ca36
4
+ data.tar.gz: 9b821db9a6f199ba10d9c8e509ba8f20eba2f91ecf400254f179d8e8099e2a82
5
5
  SHA512:
6
- metadata.gz: d550a0a8738447c939b5f6085ef71c7b79898854ede9c6e526e07f73fd4cf6a660b5a18c4e9277f80b081dc41f21f3371aafa69099d6383c884e954b7d15d9ae
7
- data.tar.gz: 8b8ae8685c357608a6db776443171a1ea34d387272fe72f4802164e3345c7b6bf37d558d7967e5315d8718dbcf2a6a902cad2c1e3e84bb4de0b5811b1d075574
6
+ metadata.gz: 911c9304545c3182c42d8dab5dcdb52208b59479318cf8324d8b0654a3315865c73fa10f430fbe16618a1deae5fabeb45a783fa6e3430e2da86777d06689987e
7
+ data.tar.gz: bf884a9e9f0cbbc35b88069d532baa021e973ad425c0bd9b2236aac12736448c53d99798da8abbcab1bf284484de5ac850bbee5e2cf0d7d8004326ceb836271c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.4.1)
4
+ kuber_kit (0.4.2)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
data/TODO.md CHANGED
@@ -1,7 +1,5 @@
1
1
  - https://ttytoolkit.org/
2
2
  - kit status should show the list of services and their status, with ability to select & view logs
3
- - list services and require confirmation before deployment
4
- - add kit logs support, should work similar to kit attach
5
3
  - allow deploying only services enabled for specific configuration
6
4
  - find a way to always deploy some service, e.g. for migrations and env_files
7
5
  - template should be able to set default attributes
@@ -2,4 +2,5 @@ KuberKit
2
2
  .define_configuration(:review)
3
3
  .use_registry(:review_default, as: :default)
4
4
  .use_artifact(:kuber_kit_repo, as: :kuber_kit_repo)
5
+ .deployer_require_confirimation
5
6
  #.use_build_server(:remote_bs)
@@ -9,11 +9,12 @@ class KuberKit::Actions::ServiceDeployer
9
9
  ]
10
10
 
11
11
  Contract KeywordArgs[
12
- services: Maybe[ArrayOf[String]],
13
- tags: Maybe[ArrayOf[String]],
14
- skip_compile: Maybe[Bool],
12
+ services: Maybe[ArrayOf[String]],
13
+ tags: Maybe[ArrayOf[String]],
14
+ skip_compile: Maybe[Bool],
15
+ require_confirmation: Maybe[Bool],
15
16
  ] => Any
16
- def call(services:, tags:, skip_compile: false)
17
+ def call(services:, tags:, skip_compile: false, require_confirmation: false)
17
18
  if services.empty? && tags.empty?
18
19
  services, tags = show_tags_selection
19
20
  end
@@ -25,6 +26,15 @@ class KuberKit::Actions::ServiceDeployer
25
26
 
26
27
  unless service_names.any?
27
28
  ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
29
+ return false
30
+ end
31
+
32
+ services_list = service_names.map(&:to_s).map(&:yellow).join(", ")
33
+ ui.print_info "ServiceDeployer", "The following services will be deployed: #{services_list}"
34
+
35
+ if require_confirmation
36
+ result = ui.prompt("Please confirm to continue deployment", ["confirm".green, "cancel".red])
37
+ return false unless result == "confirm".green
28
38
  end
29
39
 
30
40
  services = service_names.map do |service_name|
@@ -29,17 +29,22 @@ class KuberKit::CLI < Thor
29
29
  end
30
30
 
31
31
  desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
32
- method_option :services, :type => :array, aliases: ["-s"]
33
- method_option :tags, :type => :array, aliases: ["-t"]
34
- method_option :skip_compile, :type => :boolean, aliases: ["-B"]
32
+ method_option :services, :type => :array, aliases: ["-s"]
33
+ method_option :tags, :type => :array, aliases: ["-t"]
34
+ method_option :skip_compile, :type => :boolean, aliases: ["-B"]
35
+ method_option :require_confirmation, :type => :boolean, aliases: ["-r"]
35
36
  def deploy
36
37
  setup(options)
37
38
 
38
39
  if KuberKit::Container['actions.configuration_loader'].call(options)
40
+ require_confirmation = options[:require_confirmation] ||
41
+ KuberKit.current_configuration.deployer_require_confirimation ||
42
+ false
39
43
  result = KuberKit::Container['actions.service_deployer'].call(
40
- services: options[:services] || [],
41
- tags: options[:tags] || [],
42
- skip_compile: options[:skip_compile] || false
44
+ services: options[:services] || [],
45
+ tags: options[:tags] || [],
46
+ skip_compile: options[:skip_compile] || false,
47
+ require_confirmation: require_confirmation
43
48
  )
44
49
  end
45
50
 
@@ -1,35 +1,37 @@
1
1
  class KuberKit::Core::Configuration
2
2
  attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
3
- :deployer_strategy, :deployer_namespace, :services_attributes, :build_servers,
4
- :global_build_vars
3
+ :services_attributes, :build_servers, :global_build_vars,
4
+ :deployer_strategy, :deployer_namespace, :deployer_require_confirimation
5
5
 
6
6
  Contract KeywordArgs[
7
- name: Symbol,
8
- artifacts: Hash,
9
- registries: Hash,
10
- env_files: Hash,
11
- templates: Hash,
12
- kubeconfig_path: Maybe[String],
13
- deployer_strategy: Symbol,
14
- deployer_namespace: Maybe[Symbol],
15
- services_attributes: HashOf[Symbol => Hash],
16
- build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
17
- global_build_vars: HashOf[Symbol => Any],
7
+ name: Symbol,
8
+ artifacts: Hash,
9
+ registries: Hash,
10
+ env_files: Hash,
11
+ templates: Hash,
12
+ kubeconfig_path: Maybe[String],
13
+ services_attributes: HashOf[Symbol => Hash],
14
+ build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
15
+ global_build_vars: HashOf[Symbol => Any],
16
+ deployer_strategy: Symbol,
17
+ deployer_namespace: Maybe[Symbol],
18
+ deployer_require_confirimation: Bool,
18
19
  ] => Any
19
20
  def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
20
- deployer_strategy:, deployer_namespace:, services_attributes:, build_servers:,
21
- global_build_vars:)
22
- @name = name
23
- @artifacts = artifacts
24
- @registries = registries
25
- @env_files = env_files
26
- @templates = templates
27
- @kubeconfig_path = kubeconfig_path
28
- @deployer_strategy = deployer_strategy
29
- @deployer_namespace = deployer_namespace
30
- @build_servers = build_servers
21
+ services_attributes:, build_servers:, global_build_vars:,
22
+ deployer_strategy:, deployer_namespace:, deployer_require_confirimation:)
23
+ @name = name
24
+ @artifacts = artifacts
25
+ @registries = registries
26
+ @env_files = env_files
27
+ @templates = templates
28
+ @kubeconfig_path = kubeconfig_path
29
+ @build_servers = build_servers
31
30
  @services_attributes = services_attributes
32
31
  @global_build_vars = global_build_vars
32
+ @deployer_strategy = deployer_strategy
33
+ @deployer_namespace = deployer_namespace
34
+ @deployer_require_confirimation = deployer_require_confirimation
33
35
  end
34
36
 
35
37
  def service_attributes(service_name)
@@ -17,18 +17,19 @@ class KuberKit::Core::ConfigurationDefinition
17
17
 
18
18
  def to_attrs
19
19
  OpenStruct.new(
20
- name: @configuration_name,
21
- artifacts: @artifacts,
22
- registries: @registries,
23
- env_files: @env_files,
24
- templates: @templates,
25
- kubeconfig_path: @kubeconfig_path,
26
- deployer_strategy: @deployer_strategy,
27
- deployer_namespace: @deployer_namespace,
28
- enabled_services: @enabled_services,
29
- build_servers: @build_servers,
20
+ name: @configuration_name,
21
+ artifacts: @artifacts,
22
+ registries: @registries,
23
+ env_files: @env_files,
24
+ templates: @templates,
25
+ kubeconfig_path: @kubeconfig_path,
26
+ enabled_services: @enabled_services,
27
+ build_servers: @build_servers,
30
28
  services_attributes: @services_attributes,
31
29
  global_build_vars: @global_build_vars,
30
+ deployer_strategy: @deployer_strategy,
31
+ deployer_namespace: @deployer_namespace,
32
+ deployer_require_confirimation: @deployer_require_confirimation || false,
32
33
  )
33
34
  end
34
35
 
@@ -94,6 +95,12 @@ class KuberKit::Core::ConfigurationDefinition
94
95
  self
95
96
  end
96
97
 
98
+ def deployer_require_confirimation
99
+ @deployer_require_confirimation = true
100
+
101
+ self
102
+ end
103
+
97
104
  def enabled_services(services)
98
105
  if services.is_a?(Hash)
99
106
  @enabled_services += services.keys.map(&:to_sym)
@@ -20,17 +20,18 @@ class KuberKit::Core::ConfigurationFactory
20
20
  build_servers = fetch_build_servers(configuration_attrs.build_servers)
21
21
 
22
22
  KuberKit::Core::Configuration.new(
23
- name: configuration_attrs.name,
24
- artifacts: artifacts,
25
- registries: registries,
26
- env_files: env_files,
27
- templates: templates,
28
- kubeconfig_path: configuration_attrs.kubeconfig_path,
29
- deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
30
- deployer_namespace: configuration_attrs.deployer_namespace,
31
- build_servers: build_servers,
23
+ name: configuration_attrs.name,
24
+ artifacts: artifacts,
25
+ registries: registries,
26
+ env_files: env_files,
27
+ templates: templates,
28
+ kubeconfig_path: configuration_attrs.kubeconfig_path,
29
+ build_servers: build_servers,
32
30
  services_attributes: configuration_attrs.services_attributes,
33
31
  global_build_vars: configuration_attrs.global_build_vars || {},
32
+ deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
33
+ deployer_namespace: configuration_attrs.deployer_namespace,
34
+ deployer_require_confirimation: configuration_attrs.deployer_require_confirimation,
34
35
  )
35
36
  end
36
37
 
@@ -25,8 +25,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
25
25
  end
26
26
 
27
27
  container_name = strategy_options.fetch(:container_name, service.uri)
28
- command_name = strategy_options.fetch(:command_name, "bash")
29
- custom_args = strategy_options.fetch(:custom_args, nil)
28
+ command_name = strategy_options.fetch(:command_name, nil)
29
+ custom_args = strategy_options.fetch(:custom_args, nil)
30
30
  networks = strategy_options.fetch(:networks, [])
31
31
  volumes = strategy_options.fetch(:volumes, [])
32
32
 
@@ -50,7 +50,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
50
50
  custom_args << "--network #{network}"
51
51
  end
52
52
  volumes.each do |volume|
53
- docker_commands.create_volume(shell, volume)
53
+ volume_name, _ = volume.split(":")
54
+ docker_commands.create_volume(shell, volume_name) unless volume_name.start_with?("/")
54
55
  custom_args << "--volume #{volume}"
55
56
  end
56
57
 
@@ -25,8 +25,8 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
25
25
  end
26
26
 
27
27
  service_name = strategy_options.fetch(:service_name, service.name.to_s)
28
- command_name = strategy_options.fetch(:command_name, "bash")
29
- custom_args = strategy_options.fetch(:custom_args, nil)
28
+ command_name = strategy_options.fetch(:command_name, nil)
29
+ custom_args = strategy_options.fetch(:custom_args, nil)
30
30
 
31
31
  docker_compose_commands.run(shell, config_path,
32
32
  service: service_name,
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuber_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev