kuber_kit 1.1.8 → 1.2.0
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/.github/workflows/rspec.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +0 -48
- data/README.md +2 -2
- data/kuber_kit.gemspec +3 -3
- data/lib/kuber_kit/actions/configuration_loader.rb +3 -13
- data/lib/kuber_kit/actions/kubectl_attacher.rb +4 -7
- data/lib/kuber_kit/actions/kubectl_get.rb +3 -3
- data/lib/kuber_kit/actions/kubectl_logs.rb +4 -7
- data/lib/kuber_kit/actions/service_deployer.rb +27 -40
- data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +5 -0
- data/lib/kuber_kit/artifacts_sync/artifact_updater.rb +9 -19
- data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +31 -0
- data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +7 -0
- data/lib/kuber_kit/cli.rb +2 -36
- data/lib/kuber_kit/configs.rb +1 -4
- data/lib/kuber_kit/container.rb +4 -28
- data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +0 -8
- data/lib/kuber_kit/core/artifacts/git.rb +1 -10
- data/lib/kuber_kit/core/artifacts/local.rb +0 -8
- data/lib/kuber_kit/core/configuration.rb +6 -10
- data/lib/kuber_kit/core/configuration_definition.rb +9 -30
- data/lib/kuber_kit/core/configuration_factory.rb +1 -3
- data/lib/kuber_kit/core/context_helper/base_helper.rb +7 -1
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +1 -3
- data/lib/kuber_kit/core/context_helper/context_vars.rb +19 -33
- data/lib/kuber_kit/core/context_helper/service_helper.rb +1 -15
- data/lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb +0 -7
- data/lib/kuber_kit/core/service.rb +5 -8
- data/lib/kuber_kit/core/service_definition.rb +4 -16
- data/lib/kuber_kit/core/service_factory.rb +1 -2
- data/lib/kuber_kit/defaults.rb +4 -13
- data/lib/kuber_kit/image_compiler/image_builder.rb +1 -1
- data/lib/kuber_kit/service_deployer/service_dependency_resolver.rb +1 -1
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +2 -8
- data/lib/kuber_kit/service_reader/reader.rb +10 -2
- data/lib/kuber_kit/shell/commands/bash_commands.rb +6 -6
- data/lib/kuber_kit/shell/commands/docker_commands.rb +5 -5
- data/lib/kuber_kit/shell/commands/docker_compose_commands.rb +1 -1
- data/lib/kuber_kit/shell/commands/git_commands.rb +12 -19
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +4 -5
- data/lib/kuber_kit/shell/commands/rsync_commands.rb +1 -1
- data/lib/kuber_kit/shell/commands/system_commands.rb +1 -1
- data/lib/kuber_kit/shell/local_shell.rb +8 -12
- data/lib/kuber_kit/shell/ssh_session.rb +1 -5
- data/lib/kuber_kit/shell/ssh_shell.rb +2 -2
- data/lib/kuber_kit/shell_launcher/strategies/kubernetes.rb +1 -10
- data/lib/kuber_kit/template_reader/reader.rb +0 -1
- data/lib/kuber_kit/template_reader/strategies/artifact_file.rb +0 -1
- data/lib/kuber_kit/tools/logger_factory.rb +1 -1
- data/lib/kuber_kit/version.rb +1 -1
- data/lib/kuber_kit.rb +3 -23
- metadata +13 -24
- data/lib/kuber_kit/actions/service_generator.rb +0 -20
- data/lib/kuber_kit/artifacts_sync/strategies/abstract.rb +0 -9
- data/lib/kuber_kit/artifacts_sync/strategies/git_updater.rb +0 -46
- data/lib/kuber_kit/artifacts_sync/strategies/null_updater.rb +0 -12
- data/lib/kuber_kit/core/context_helper/abstract_helper.rb +0 -5
- data/lib/kuber_kit/core/context_helper/local_context_helper.rb +0 -14
- data/lib/kuber_kit/service_deployer/strategies/helm.rb +0 -41
- data/lib/kuber_kit/service_generator/action_handler.rb +0 -16
- data/lib/kuber_kit/service_generator/generator.rb +0 -26
- data/lib/kuber_kit/service_generator/strategies/abstract.rb +0 -5
- data/lib/kuber_kit/service_generator/strategies/helm.rb +0 -33
- data/lib/kuber_kit/service_generator/strategy_detector.rb +0 -6
- data/lib/kuber_kit/shell/commands/helm_commands.rb +0 -42
- data/lib/kuber_kit/template_reader/renderer.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41f8c55add7e426b80fa74ec7f39b2af312e9d8bc94ffc412d6046d228af1bcf
|
4
|
+
data.tar.gz: 55f2921894f99cd9aa68a868c87c0059e59e2405355154015571cc5d8676575c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13312d069ddfbddbd5972b2fbdc3e87970e366dfb2bb12caa94ac76979ecf511c92887c17567c521846648cf10a6e2c725d20baa0d2739ee5288d2497fbd6817
|
7
|
+
data.tar.gz: f9d35c210a01f77f3083a6ac2a92c9452ce3d26703d941fac175b78d4838fc0dca6d63eb5fe1de0b3bae1135a8ed1276601044193ce814677191747712f1fead
|
data/.github/workflows/rspec.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.2
|
data/CHANGELOG.md
CHANGED
@@ -1,51 +1,3 @@
|
|
1
|
-
**1.3.6**
|
2
|
-
- Remove dependency on ed25519 gem since it makes installation too complex
|
3
|
-
|
4
|
-
**1.3.5**
|
5
|
-
- Update git force_pull_repo command to improve performance
|
6
|
-
|
7
|
-
**1.3.4**
|
8
|
-
- Fix checking branch name in git artifact update
|
9
|
-
- Make LocalContextHelper compatible with ruby 3
|
10
|
-
|
11
|
-
**1.3.3**
|
12
|
-
- Support "partials" in the templates with "render" method.
|
13
|
-
- Cleanup artifacts after deployment if cache_result: false
|
14
|
-
- Improve fetching git artifact when branch name has changed
|
15
|
-
|
16
|
-
**1.3.2**
|
17
|
-
- Added an ability to generate helm templates using `kit generate` command
|
18
|
-
|
19
|
-
**1.3.1**
|
20
|
-
- Fix upgrade command for helm strategy
|
21
|
-
|
22
|
-
**1.3.0**
|
23
|
-
- Allow sending custom apply command for k8s deploy strategy
|
24
|
-
- Added initial support for helm deploy strategy
|
25
|
-
|
26
|
-
**1.2.7**
|
27
|
-
- Added an option to skip deployment and only build images for `deploy` command
|
28
|
-
|
29
|
-
**1.2.6**
|
30
|
-
- Lock cli-ui version on 2.1.0 (2.2.x has some bugs)
|
31
|
-
|
32
|
-
**1.2.5**
|
33
|
-
- Improve handling ContextVars, ability to convert context var to OpenStruct
|
34
|
-
|
35
|
-
**1.2.4**
|
36
|
-
- Fix a mistake in setting env variables
|
37
|
-
- Added an option to set "use local deployment" variable
|
38
|
-
- Allow finding job resources in kit attach and kit log
|
39
|
-
|
40
|
-
**1.2.2**
|
41
|
-
- Support Ruby 3.2.0
|
42
|
-
|
43
|
-
**1.2.1**
|
44
|
-
- Update shell commands so that STDERR stream won't be merged for commands using the command result.
|
45
|
-
- kit sh would also set current default configuration
|
46
|
-
- kit get supports "api" ui
|
47
|
-
- show sync description (git/local) for artifact sync
|
48
|
-
|
49
1
|
**1.2.0**
|
50
2
|
- Change minimal ruby version to 3
|
51
3
|
|
data/README.md
CHANGED
@@ -19,8 +19,8 @@ Please install specific kuber_kit version, depending on Ruby version.
|
|
19
19
|
| Ruby Version | KuberKit Version |
|
20
20
|
| ------------ | ------------ |
|
21
21
|
| 2.6 | 1.0.1 |
|
22
|
-
| 2.7 | 1.1.
|
23
|
-
| > 3.0 | 1.
|
22
|
+
| 2.7 | 1.1.1 |
|
23
|
+
| > 3.0 | 1.2.0 |
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
data/kuber_kit.gemspec
CHANGED
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.required_ruby_version = ">=
|
26
|
+
spec.required_ruby_version = ">= 3.0.0"
|
27
27
|
|
28
|
-
spec.add_dependency "contracts", '0.
|
28
|
+
spec.add_dependency "contracts", '0.17.0'
|
29
29
|
|
30
30
|
spec.add_dependency "dry-auto_inject", "~> 0.9.0"
|
31
31
|
spec.add_dependency "dry-core", "~> 0.8.1"
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency "dry-container", "~> 0.10.1"
|
34
34
|
|
35
35
|
spec.add_dependency "thor"
|
36
|
-
spec.add_dependency "cli-ui"
|
36
|
+
spec.add_dependency "cli-ui"
|
37
37
|
spec.add_dependency "net-ssh"
|
38
38
|
spec.add_dependency "tty-prompt"
|
39
39
|
|
@@ -20,7 +20,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
20
20
|
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
21
21
|
configuration_name = options[:configuration] || ENV["KUBER_KIT_CONFIGURATION"]
|
22
22
|
load_inventory = options.fetch(:load_inventory, true)
|
23
|
-
use_local_deploy = options.fetch(:use_local_deploy, false)
|
24
23
|
|
25
24
|
ui.print_debug "ConfigurationLoader", "Launching kuber_kit with:"
|
26
25
|
ui.print_debug "ConfigurationLoader", " Root path: #{root_path.to_s.yellow}"
|
@@ -29,11 +28,10 @@ class KuberKit::Actions::ConfigurationLoader
|
|
29
28
|
ui.print_debug "ConfigurationLoader", " Infrastructure path: #{infra_path.to_s.yellow}"
|
30
29
|
ui.print_debug "ConfigurationLoader", " Configurations path: #{configurations_path.to_s.yellow}"
|
31
30
|
ui.print_debug "ConfigurationLoader", " Configuration name: #{configuration_name.to_s.yellow}"
|
32
|
-
ui.print_debug "ConfigurationLoader", " Use local deploy: #{use_local_deploy.to_s.yellow}"
|
33
31
|
|
34
32
|
ui.print_info("Logs", "See logs at: #{configs.log_file_path}")
|
35
33
|
|
36
|
-
unless File.
|
34
|
+
unless File.exists?(root_path)
|
37
35
|
ui.print_warning "ConfigurationLoader", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
38
36
|
end
|
39
37
|
|
@@ -41,10 +39,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
41
39
|
raise KuberKit::Error, "The minimal required kuber_kit version is #{configs.kuber_kit_min_version}"
|
42
40
|
end
|
43
41
|
|
44
|
-
if use_local_deploy
|
45
|
-
ENV["KUBER_KIT_USE_LOCAL_DEPLOYMENT"] = "true"
|
46
|
-
end
|
47
|
-
|
48
42
|
load_configurations(configurations_path, configuration_name)
|
49
43
|
load_infrastructure(infra_path)
|
50
44
|
|
@@ -90,10 +84,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
90
84
|
configuration_name = first_configurations.configuration_name
|
91
85
|
end
|
92
86
|
|
93
|
-
if configuration_store.count > 1 && configuration_name
|
94
|
-
ui.print_info("Configuration", "Using configuration: #{configuration_name.to_s.cyan}")
|
95
|
-
end
|
96
|
-
|
97
87
|
if configuration_store.count > 1 && configuration_name.nil?
|
98
88
|
options = all_configurations.map(&:configuration_name).map(&:to_s)
|
99
89
|
configuration_name = ui.prompt("Please select configuration name (or set it using -C option)", options)
|
@@ -119,9 +109,9 @@ class KuberKit::Actions::ConfigurationLoader
|
|
119
109
|
|
120
110
|
artifact_task_group = ui.create_task_group
|
121
111
|
not_local_artifacts.each do |artifact|
|
122
|
-
artifact_task_group.add("Updating #{artifact.name.to_s.yellow}
|
112
|
+
artifact_task_group.add("Updating #{artifact.name.to_s.yellow}") do |task|
|
123
113
|
artifact_updater.update(local_shell, artifact)
|
124
|
-
task.update_title("
|
114
|
+
task.update_title("Updated #{artifact.name.to_s.green}")
|
125
115
|
end
|
126
116
|
end
|
127
117
|
artifact_task_group.wait
|
@@ -7,20 +7,17 @@ class KuberKit::Actions::KubectlAttacher
|
|
7
7
|
]
|
8
8
|
|
9
9
|
Contract Maybe[String], Hash => Any
|
10
|
-
def call(
|
10
|
+
def call(pod_name, options)
|
11
11
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
12
12
|
kubectl_entrypoint = KuberKit.current_configuration.kubectl_entrypoint
|
13
13
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
14
14
|
|
15
|
-
if !
|
16
|
-
|
17
|
-
KuberKit::Kubernetes::Resources::POD,
|
18
|
-
KuberKit::Kubernetes::Resources::JOB
|
19
|
-
])
|
15
|
+
if !pod_name
|
16
|
+
pod_name = resource_selector.call("attach")
|
20
17
|
end
|
21
18
|
|
22
19
|
kubectl_commands.exec(
|
23
|
-
local_shell,
|
20
|
+
local_shell, pod_name, "bash", args: "-it",
|
24
21
|
kubeconfig_path: kubeconfig_path,
|
25
22
|
interactive: true,
|
26
23
|
namespace: deployer_namespace,
|
@@ -6,7 +6,7 @@ class KuberKit::Actions::KubectlGet
|
|
6
6
|
"ui"
|
7
7
|
]
|
8
8
|
|
9
|
-
Contract Maybe[String], Hash =>
|
9
|
+
Contract Maybe[String], Hash => Any
|
10
10
|
def call(resource_name, options)
|
11
11
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
12
12
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
@@ -23,10 +23,10 @@ class KuberKit::Actions::KubectlGet
|
|
23
23
|
|
24
24
|
ui.print_info("Pods", resources.join("\n"))
|
25
25
|
|
26
|
-
|
26
|
+
true
|
27
27
|
rescue KuberKit::Error => e
|
28
28
|
ui.print_error("Error", e.message)
|
29
29
|
|
30
|
-
|
30
|
+
false
|
31
31
|
end
|
32
32
|
end
|
@@ -7,15 +7,12 @@ class KuberKit::Actions::KubectlLogs
|
|
7
7
|
]
|
8
8
|
|
9
9
|
Contract Maybe[String], Hash => Any
|
10
|
-
def call(
|
10
|
+
def call(pod_name, options)
|
11
11
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
12
12
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
13
13
|
|
14
|
-
if !
|
15
|
-
|
16
|
-
KuberKit::Kubernetes::Resources::POD,
|
17
|
-
KuberKit::Kubernetes::Resources::JOB
|
18
|
-
])
|
14
|
+
if !pod_name
|
15
|
+
pod_name = resource_selector.call("attach")
|
19
16
|
end
|
20
17
|
|
21
18
|
args = nil
|
@@ -24,7 +21,7 @@ class KuberKit::Actions::KubectlLogs
|
|
24
21
|
end
|
25
22
|
|
26
23
|
kubectl_commands.logs(
|
27
|
-
local_shell,
|
24
|
+
local_shell, pod_name,
|
28
25
|
args: args,
|
29
26
|
kubeconfig_path: kubeconfig_path,
|
30
27
|
namespace: deployer_namespace
|
@@ -18,10 +18,9 @@ class KuberKit::Actions::ServiceDeployer
|
|
18
18
|
skip_services: Maybe[ArrayOf[String]],
|
19
19
|
skip_compile: Maybe[Bool],
|
20
20
|
skip_dependencies: Maybe[Bool],
|
21
|
-
skip_deployment: Maybe[Bool],
|
22
21
|
require_confirmation: Maybe[Bool],
|
23
22
|
] => Any
|
24
|
-
def call(services:, tags:, skip_services: nil, skip_compile: false, skip_dependencies: false,
|
23
|
+
def call(services:, tags:, skip_services: nil, skip_compile: false, skip_dependencies: false, require_confirmation: false)
|
25
24
|
deployment_result = KuberKit::Actions::ActionResult.new()
|
26
25
|
current_configuration = KuberKit.current_configuration
|
27
26
|
|
@@ -29,11 +28,11 @@ class KuberKit::Actions::ServiceDeployer
|
|
29
28
|
services, tags = deployment_options_selector.call()
|
30
29
|
end
|
31
30
|
|
32
|
-
disabled_services
|
33
|
-
disabled_services
|
34
|
-
default_services
|
35
|
-
|
36
|
-
|
31
|
+
disabled_services = current_configuration.disabled_services.map(&:to_s)
|
32
|
+
disabled_services += skip_services if skip_services
|
33
|
+
default_services = current_configuration.default_services.map(&:to_s) - disabled_services
|
34
|
+
initial_services = current_configuration.initial_services.map(&:to_s) - disabled_services
|
35
|
+
initial_service_names = initial_services.map(&:to_sym)
|
37
36
|
|
38
37
|
service_names = service_list_resolver.resolve(
|
39
38
|
services: services || [],
|
@@ -50,55 +49,50 @@ class KuberKit::Actions::ServiceDeployer
|
|
50
49
|
all_service_names = service_dependency_resolver.get_all(service_names)
|
51
50
|
end
|
52
51
|
|
53
|
-
all_service_names_with_hooks = (pre_deploy_services.map(&:to_sym) + all_service_names + post_deploy_services.map(&:to_sym)).uniq
|
54
|
-
|
55
52
|
unless all_service_names.any?
|
56
53
|
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
57
54
|
return false
|
58
55
|
end
|
59
56
|
|
60
|
-
unless allow_deployment?(require_confirmation: require_confirmation, service_names:
|
57
|
+
unless allow_deployment?(require_confirmation: require_confirmation, service_names: (initial_service_names + all_service_names).uniq)
|
61
58
|
return false
|
62
59
|
end
|
63
60
|
|
64
61
|
# Compile images for all services and dependencies
|
65
|
-
images_names = get_image_names(service_names:
|
62
|
+
images_names = get_image_names(service_names: (initial_service_names + all_service_names).uniq)
|
66
63
|
unless skip_compile
|
67
64
|
compilation_result = compile_images(images_names)
|
68
65
|
|
69
66
|
return false unless compilation_result && compilation_result.succeeded?
|
70
67
|
end
|
71
68
|
|
72
|
-
#
|
73
|
-
if skip_deployment
|
74
|
-
return deployment_result
|
75
|
-
end
|
76
|
-
|
77
|
-
# First, deploy pre-deploy services.
|
69
|
+
# First deploy initial services.
|
78
70
|
# This feature is used to deploy some services, required for deployment of other services, e.g. env files
|
79
71
|
# Note: Initial services are deployed without dependencies
|
80
|
-
|
81
|
-
|
82
|
-
end
|
72
|
+
initial_services.map(&:to_sym).each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
73
|
+
ui.print_debug("ServiceDeployer", "Scheduling to compile: #{batch_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
83
74
|
|
84
|
-
|
85
|
-
# Note: In earlier versions, KuberKit would deploy all dependencies in the order defined by dependency tree.
|
86
|
-
# Now it would deploy all dependencies (initializers) at the same time, even if one initializer depends on another initializer.
|
87
|
-
unless skip_dependencies
|
88
|
-
initializers = service_dependency_resolver.get_all_deps(service_names)
|
89
|
-
initializers.map(&:to_sym).each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
75
|
+
if deployment_result.succeeded?
|
90
76
|
deploy_simultaneously(batch_service_names, deployment_result)
|
91
77
|
end
|
92
78
|
end
|
93
79
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
80
|
+
if skip_dependencies
|
81
|
+
service_names.each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
82
|
+
ui.print_debug("ServiceDeployer", "Scheduling to deploy: #{batch_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
98
83
|
|
99
|
-
|
100
|
-
|
101
|
-
|
84
|
+
if deployment_result.succeeded?
|
85
|
+
deploy_simultaneously(batch_service_names, deployment_result)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
else
|
89
|
+
service_dependency_resolver.each_with_deps(service_names) do |dep_service_names|
|
90
|
+
ui.print_debug("ServiceDeployer", "Scheduling to deploy: #{dep_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
91
|
+
|
92
|
+
if deployment_result.succeeded?
|
93
|
+
deploy_simultaneously(dep_service_names, deployment_result)
|
94
|
+
end
|
95
|
+
end
|
102
96
|
end
|
103
97
|
|
104
98
|
deployment_result
|
@@ -116,13 +110,6 @@ class KuberKit::Actions::ServiceDeployer
|
|
116
110
|
|
117
111
|
private
|
118
112
|
def deploy_simultaneously(service_names, deployment_result)
|
119
|
-
unless deployment_result.succeeded?
|
120
|
-
ui.print_debug("ServiceDeployer", "Deploymet already failed. Canceling: #{service_names.inspect}")
|
121
|
-
return
|
122
|
-
end
|
123
|
-
|
124
|
-
ui.print_debug("ServiceDeployer", "Scheduling to deploy: #{service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
125
|
-
|
126
113
|
task_group = ui.create_task_group
|
127
114
|
|
128
115
|
service_names.each do |service_name|
|
@@ -1,37 +1,27 @@
|
|
1
1
|
class KuberKit::ArtifactsSync::ArtifactUpdater
|
2
|
-
|
2
|
+
ResolverNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
3
|
|
4
4
|
include KuberKit::Import[
|
5
5
|
"ui"
|
6
6
|
]
|
7
7
|
|
8
|
-
def
|
9
|
-
@@
|
8
|
+
def use_resolver(artifact_resolver, artifact_class:)
|
9
|
+
@@resolvers ||= {}
|
10
10
|
|
11
|
-
if !
|
12
|
-
raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::
|
11
|
+
if !artifact_resolver.is_a?(KuberKit::ArtifactsSync::AbstractArtifactResolver)
|
12
|
+
raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::AbstractArtifactResolver, got: #{artifact_resolver.inspect}")
|
13
13
|
end
|
14
14
|
|
15
|
-
@@
|
15
|
+
@@resolvers[artifact_class] = artifact_resolver
|
16
16
|
end
|
17
17
|
|
18
18
|
def update(shell, artifact)
|
19
|
-
|
19
|
+
resolver = @@resolvers[artifact.class]
|
20
20
|
|
21
21
|
ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
|
22
22
|
|
23
|
-
raise
|
23
|
+
raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
|
24
24
|
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def cleanup(shell, artifact)
|
29
|
-
strategy = @@strategies[artifact.class]
|
30
|
-
|
31
|
-
ui.print_debug "ArtifactUpdater", "Cleaning artifact #{artifact.name.to_s.green}"
|
32
|
-
|
33
|
-
raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil?
|
34
|
-
|
35
|
-
strategy.cleanup(shell, artifact)
|
25
|
+
resolver.resolve(shell, artifact)
|
36
26
|
end
|
37
27
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class KuberKit::ArtifactsSync::GitArtifactResolver < KuberKit::ArtifactsSync::AbstractArtifactResolver
|
2
|
+
|
3
|
+
include KuberKit::Import[
|
4
|
+
"shell.git_commands",
|
5
|
+
]
|
6
|
+
|
7
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
|
8
|
+
def resolve(shell, artifact)
|
9
|
+
already_cloned = artifact_already_cloned?(
|
10
|
+
shell: shell,
|
11
|
+
target_path: artifact.cloned_path,
|
12
|
+
remote_url: artifact.remote_url,
|
13
|
+
)
|
14
|
+
|
15
|
+
if already_cloned
|
16
|
+
git_commands.force_pull_repo(shell,
|
17
|
+
path: artifact.cloned_path, branch: artifact.branch
|
18
|
+
)
|
19
|
+
else
|
20
|
+
git_commands.download_repo(shell,
|
21
|
+
remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def artifact_already_cloned?(shell:, target_path:, remote_url:)
|
28
|
+
target_remote_url = git_commands.get_remote_url(shell, target_path)
|
29
|
+
target_remote_url == remote_url
|
30
|
+
end
|
31
|
+
end
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -11,7 +11,6 @@ class KuberKit::CLI < Thor
|
|
11
11
|
class_option :debug, :type => :boolean, aliases: ["-d"]
|
12
12
|
class_option :configuration, :type => :string, aliases: ["-C"]
|
13
13
|
class_option :user, :type => :string, aliases: ["-u"]
|
14
|
-
class_option :use_local_deploy, :type => :boolean, aliases: ["-l"]
|
15
14
|
|
16
15
|
desc "compile IMAGE_NAMES", "Compile image with IMAGE_NAMES (comma-separated)"
|
17
16
|
def compile(image_names_str)
|
@@ -24,8 +23,6 @@ class KuberKit::CLI < Thor
|
|
24
23
|
action_result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
|
25
24
|
end
|
26
25
|
|
27
|
-
clean_artifacts(options)
|
28
|
-
|
29
26
|
if action_result && action_result.succeeded?
|
30
27
|
time = (Time.now.to_i - started_at)
|
31
28
|
print_result("Image compilation finished! (#{time}s)", result: {
|
@@ -45,7 +42,6 @@ class KuberKit::CLI < Thor
|
|
45
42
|
method_option :skip_dependencies, :type => :boolean, aliases: ["-D"]
|
46
43
|
method_option :require_confirmation, :type => :boolean, aliases: ["-r"]
|
47
44
|
method_option :skip_confirmation, :type => :boolean, aliases: ["-R"]
|
48
|
-
method_option :skip_deployment, :type => :boolean, aliases: ["-K"]
|
49
45
|
def deploy
|
50
46
|
setup(options)
|
51
47
|
|
@@ -61,13 +57,10 @@ class KuberKit::CLI < Thor
|
|
61
57
|
skip_services: (options[:skip_services] || []).flatten.uniq,
|
62
58
|
skip_compile: options[:skip_compile] || false,
|
63
59
|
skip_dependencies: options[:skip_dependencies] || false,
|
64
|
-
skip_deployment: options[:skip_deployment] || false,
|
65
60
|
require_confirmation: require_confirmation
|
66
61
|
)
|
67
62
|
end
|
68
63
|
|
69
|
-
clean_artifacts(options)
|
70
|
-
|
71
64
|
if action_result && action_result.succeeded?
|
72
65
|
time = (Time.now.to_i - started_at)
|
73
66
|
print_result("Service deployment finished! (#{time}s)", result: {
|
@@ -115,16 +108,6 @@ class KuberKit::CLI < Thor
|
|
115
108
|
end
|
116
109
|
end
|
117
110
|
|
118
|
-
|
119
|
-
desc "generate SERVICE_NAME PATH_NAME", "Generates a template for a given service in a given path"
|
120
|
-
def generate(service_name, path)
|
121
|
-
setup(options)
|
122
|
-
|
123
|
-
if KuberKit::Container['actions.configuration_loader'].call(options)
|
124
|
-
KuberKit::Container['actions.service_generator'].call(service_name.to_sym, path)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
111
|
desc "apply FILE_PATH", "Apply FILE_PATH with kubectl"
|
129
112
|
def apply(file_path)
|
130
113
|
setup(options)
|
@@ -194,11 +177,7 @@ class KuberKit::CLI < Thor
|
|
194
177
|
setup(options)
|
195
178
|
|
196
179
|
if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false))
|
197
|
-
|
198
|
-
|
199
|
-
print_result("Fetched list of pods", result: {
|
200
|
-
pods: pods
|
201
|
-
})
|
180
|
+
KuberKit::Container['actions.kubectl_get'].call(pod_name, options)
|
202
181
|
end
|
203
182
|
end
|
204
183
|
|
@@ -226,7 +205,7 @@ class KuberKit::CLI < Thor
|
|
226
205
|
# We should load config before loading any bean, to make sure that bean won't be built with default config
|
227
206
|
root_path = KuberKit::Container['tools.workdir_detector'].call(options)
|
228
207
|
config_file_path = File.join(root_path, APP_CONFIG_FILENAME)
|
229
|
-
if File.
|
208
|
+
if File.exists?(config_file_path)
|
230
209
|
require config_file_path
|
231
210
|
end
|
232
211
|
end
|
@@ -234,17 +213,4 @@ class KuberKit::CLI < Thor
|
|
234
213
|
def print_result(message, data = {})
|
235
214
|
KuberKit::Container['ui'].print_result(message, data)
|
236
215
|
end
|
237
|
-
|
238
|
-
def clean_artifacts(options)
|
239
|
-
artifacts = KuberKit.current_configuration.artifacts.values
|
240
|
-
artifacts_to_clean = artifacts.select(&:cleanup_needed?)
|
241
|
-
|
242
|
-
return unless artifacts_to_clean.any?
|
243
|
-
|
244
|
-
artifacts_to_clean.each do |artifact|
|
245
|
-
KuberKit::Container['artifacts_sync.artifact_updater'].cleanup(
|
246
|
-
KuberKit::Container['shell.local_shell'], artifact
|
247
|
-
)
|
248
|
-
end
|
249
|
-
end
|
250
216
|
end
|
data/lib/kuber_kit/configs.rb
CHANGED
@@ -5,8 +5,7 @@ class KuberKit::Configs
|
|
5
5
|
:image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir, :remote_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, :env_file_compile_dir, :shell_launcher_strategy
|
9
|
-
:shell_launcher_sets_configration, :generator_strategy
|
8
|
+
:additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir, :shell_launcher_strategy
|
10
9
|
]
|
11
10
|
DOCKER_IGNORE_LIST = [
|
12
11
|
'Dockerfile',
|
@@ -60,8 +59,6 @@ class KuberKit::Configs
|
|
60
59
|
set :deprecation_warnings_disabled, false
|
61
60
|
set :log_file_path, File.join(absolute_kuber_kit_path, "deploy.log")
|
62
61
|
set :env_file_compile_dir, File.join(absolute_kuber_kit_path, "env_files")
|
63
|
-
set :shell_launcher_sets_configration, true
|
64
|
-
set :generator_strategy, :helm
|
65
62
|
end
|
66
63
|
|
67
64
|
def items
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -25,10 +25,6 @@ class KuberKit::Container
|
|
25
25
|
KuberKit::Actions::ServiceChecker.new
|
26
26
|
end
|
27
27
|
|
28
|
-
register "actions.service_generator" do
|
29
|
-
KuberKit::Actions::ServiceGenerator.new
|
30
|
-
end
|
31
|
-
|
32
28
|
register "actions.configuration_loader" do
|
33
29
|
KuberKit::Actions::ConfigurationLoader.new
|
34
30
|
end
|
@@ -185,10 +181,6 @@ class KuberKit::Container
|
|
185
181
|
KuberKit::Shell::Commands::SystemCommands.new
|
186
182
|
end
|
187
183
|
|
188
|
-
register "shell.helm_commands" do
|
189
|
-
KuberKit::Shell::Commands::HelmCommands.new
|
190
|
-
end
|
191
|
-
|
192
184
|
register "shell.local_shell" do
|
193
185
|
KuberKit::Shell::LocalShell.new
|
194
186
|
end
|
@@ -237,12 +229,12 @@ class KuberKit::Container
|
|
237
229
|
KuberKit::ArtifactsSync::ArtifactUpdater.new
|
238
230
|
end
|
239
231
|
|
240
|
-
register "artifacts_sync.
|
241
|
-
KuberKit::ArtifactsSync::
|
232
|
+
register "artifacts_sync.git_artifact_resolver" do
|
233
|
+
KuberKit::ArtifactsSync::GitArtifactResolver.new
|
242
234
|
end
|
243
235
|
|
244
|
-
register "artifacts_sync.
|
245
|
-
KuberKit::ArtifactsSync::
|
236
|
+
register "artifacts_sync.null_artifact_resolver" do
|
237
|
+
KuberKit::ArtifactsSync::NullArtifactResolver.new
|
246
238
|
end
|
247
239
|
|
248
240
|
register "env_file_reader.action_handler" do
|
@@ -277,10 +269,6 @@ class KuberKit::Container
|
|
277
269
|
KuberKit::TemplateReader::Reader.new
|
278
270
|
end
|
279
271
|
|
280
|
-
register "template_reader.renderer" do
|
281
|
-
KuberKit::TemplateReader::Renderer.new
|
282
|
-
end
|
283
|
-
|
284
272
|
register "template_reader.strategies.artifact_file" do
|
285
273
|
KuberKit::TemplateReader::Strategies::ArtifactFile.new
|
286
274
|
end
|
@@ -309,18 +297,6 @@ class KuberKit::Container
|
|
309
297
|
KuberKit::ServiceDeployer::ServiceDependencyResolver.new
|
310
298
|
end
|
311
299
|
|
312
|
-
register "service_generator.action_handler" do
|
313
|
-
KuberKit::ServiceGenerator::ActionHandler.new
|
314
|
-
end
|
315
|
-
|
316
|
-
register "service_generator.strategy_detector" do
|
317
|
-
KuberKit::ServiceGenerator::StrategyDetector.new
|
318
|
-
end
|
319
|
-
|
320
|
-
register "service_generator.generator" do
|
321
|
-
KuberKit::ServiceGenerator::Generator.new
|
322
|
-
end
|
323
|
-
|
324
300
|
register "service_reader.action_handler" do
|
325
301
|
KuberKit::ServiceReader::ActionHandler.new
|
326
302
|
end
|
@@ -10,12 +10,4 @@ class KuberKit::Core::Artifacts::AbstractArtifact
|
|
10
10
|
def namespace
|
11
11
|
raise KuberKit::NotImplementedError, "must be implemented"
|
12
12
|
end
|
13
|
-
|
14
|
-
def sync_description
|
15
|
-
raise KuberKit::NotImplementedError, "must be implemented"
|
16
|
-
end
|
17
|
-
|
18
|
-
def cleanup_needed?
|
19
|
-
raise KuberKit::NotImplementedError, "must be implemented"
|
20
|
-
end
|
21
13
|
end
|