kuber_kit 0.3.9 → 0.4.2
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 +35 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/TODO.md +2 -3
- data/example/configurations/review.rb +1 -0
- data/example/infrastructure/artifacts.rb +1 -1
- data/example/services/docker_app.rb +12 -0
- data/lib/kuber_kit.rb +6 -4
- data/lib/kuber_kit/actions/configuration_loader.rb +12 -19
- data/lib/kuber_kit/actions/env_file_reader.rb +1 -0
- data/lib/kuber_kit/actions/image_compiler.rb +10 -6
- data/lib/kuber_kit/actions/service_deployer.rb +24 -11
- data/lib/kuber_kit/actions/template_reader.rb +1 -0
- data/lib/kuber_kit/artifacts_sync/artifacts_updater.rb +3 -2
- data/lib/kuber_kit/cli.rb +49 -31
- data/lib/kuber_kit/container.rb +5 -1
- data/lib/kuber_kit/core/configuration.rb +26 -24
- data/lib/kuber_kit/core/configuration_definition.rb +17 -10
- data/lib/kuber_kit/core/configuration_factory.rb +10 -9
- data/lib/kuber_kit/core/configuration_store.rb +2 -2
- data/lib/kuber_kit/core/image_store.rb +2 -2
- data/lib/kuber_kit/core/service_store.rb +2 -2
- data/lib/kuber_kit/image_compiler/compiler.rb +3 -1
- data/lib/kuber_kit/image_compiler/image_builder.rb +9 -1
- data/lib/kuber_kit/service_deployer/strategies/docker.rb +23 -5
- data/lib/kuber_kit/service_deployer/strategies/docker_compose.rb +4 -4
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +3 -1
- data/lib/kuber_kit/shell/commands/docker_commands.rb +52 -11
- data/lib/kuber_kit/shell/commands/docker_compose_commands.rb +1 -1
- data/lib/kuber_kit/shell/local_shell.rb +6 -6
- data/lib/kuber_kit/shell/ssh_shell.rb +4 -4
- data/lib/kuber_kit/tools/logger_factory.rb +1 -1
- data/lib/kuber_kit/ui/api.rb +48 -0
- data/lib/kuber_kit/ui/debug.rb +31 -0
- data/lib/kuber_kit/ui/interactive.rb +15 -0
- data/lib/kuber_kit/ui/simple.rb +34 -5
- data/lib/kuber_kit/version.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b58c988d13591ad950347cc3c2af370ab1604006d1ad0d04cf9cf43093ca36
|
4
|
+
data.tar.gz: 9b821db9a6f199ba10d9c8e509ba8f20eba2f91ecf400254f179d8e8099e2a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 911c9304545c3182c42d8dab5dcdb52208b59479318cf8324d8b0654a3315865c73fa10f430fbe16618a1deae5fabeb45a783fa6e3430e2da86777d06689987e
|
7
|
+
data.tar.gz: bf884a9e9f0cbbc35b88069d532baa021e973ad425c0bd9b2236aac12736448c53d99798da8abbcab1bf284484de5ac850bbee5e2cf0d7d8004326ceb836271c
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Rspec
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ main ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ main ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.5', '2.7']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec spec/
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# KuberKit
|
2
2
|
|
3
|
-
[](https://github.com/ArtStation/kuber_kit/actions?query=workflow%3ARspec)
|
4
4
|
|
5
5
|
Solution for building & deploying applications on Kubernetes, written in Ruby.
|
6
6
|
|
data/TODO.md
CHANGED
@@ -1,8 +1,7 @@
|
|
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
|
8
|
-
- template should be able to depend on image?
|
6
|
+
- template should be able to depend on image?
|
7
|
+
- cleanup image builds older than some date
|
data/lib/kuber_kit.rb
CHANGED
@@ -177,6 +177,8 @@ module KuberKit
|
|
177
177
|
module UI
|
178
178
|
autoload :Interactive, 'ui/interactive'
|
179
179
|
autoload :Simple, 'ui/simple'
|
180
|
+
autoload :Debug, 'ui/debug'
|
181
|
+
autoload :Api, 'ui/api'
|
180
182
|
end
|
181
183
|
|
182
184
|
autoload :CLI, 'cli'
|
@@ -205,12 +207,12 @@ module KuberKit
|
|
205
207
|
@current_configuration = nil
|
206
208
|
end
|
207
209
|
|
208
|
-
def
|
209
|
-
@
|
210
|
+
def set_ui_mode(value)
|
211
|
+
@ui_mode = value
|
210
212
|
end
|
211
213
|
|
212
|
-
def
|
213
|
-
|
214
|
+
def ui_mode
|
215
|
+
@ui_mode
|
214
216
|
end
|
215
217
|
|
216
218
|
def deprecation_warnings_disabled?
|
@@ -1,13 +1,10 @@
|
|
1
1
|
class KuberKit::Actions::ConfigurationLoader
|
2
|
-
APP_CONFIG_FILENAME = "config.rb".freeze
|
3
|
-
|
4
2
|
include KuberKit::Import[
|
5
3
|
"core.registry_store",
|
6
4
|
"core.image_store",
|
7
5
|
"core.service_store",
|
8
6
|
"core.configuration_store",
|
9
7
|
"artifacts_sync.artifacts_updater",
|
10
|
-
"tools.logger",
|
11
8
|
"shell.local_shell",
|
12
9
|
"ui",
|
13
10
|
"configs"
|
@@ -16,29 +13,24 @@ class KuberKit::Actions::ConfigurationLoader
|
|
16
13
|
Contract Hash => Any
|
17
14
|
def call(options)
|
18
15
|
root_path = options[:path] || File.join(Dir.pwd, configs.kuber_kit_dirname)
|
19
|
-
|
20
|
-
# require config file first, in case if other dirs are overriden in config
|
21
|
-
config_file_path = File.join(root_path, APP_CONFIG_FILENAME)
|
22
|
-
if File.exists?(config_file_path)
|
23
|
-
require config_file_path
|
24
|
-
end
|
25
|
-
|
26
16
|
images_path = options[:images_path] || File.join(root_path, configs.images_dirname)
|
27
17
|
services_path = options[:services_path] || File.join(root_path, configs.services_dirname)
|
28
18
|
infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
|
29
19
|
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
30
20
|
configuration_name = ENV["KUBER_KIT_CONFIGURATION"] || options[:configuration]
|
31
21
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
ui.print_debug "ConfigurationLoader", "Launching kuber_kit with:"
|
23
|
+
ui.print_debug "ConfigurationLoader", " Root path: #{root_path.to_s.yellow}"
|
24
|
+
ui.print_debug "ConfigurationLoader", " Images path: #{images_path.to_s.yellow}"
|
25
|
+
ui.print_debug "ConfigurationLoader", " Services path: #{services_path.to_s.yellow}"
|
26
|
+
ui.print_debug "ConfigurationLoader", " Infrastructure path: #{infra_path.to_s.yellow}"
|
27
|
+
ui.print_debug "ConfigurationLoader", " Configurations path: #{configurations_path.to_s.yellow}"
|
28
|
+
ui.print_debug "ConfigurationLoader", " Configuration name: #{configuration_name.to_s.yellow}"
|
29
|
+
|
30
|
+
ui.print_info("Logs", "See logs at: #{configs.log_file_path}")
|
39
31
|
|
40
32
|
unless File.exists?(root_path)
|
41
|
-
ui.print_warning "
|
33
|
+
ui.print_warning "ConfigurationLoader", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
42
34
|
end
|
43
35
|
|
44
36
|
if Gem::Version.new(KuberKit::VERSION) < Gem::Version.new(configs.kuber_kit_min_version)
|
@@ -72,6 +64,7 @@ class KuberKit::Actions::ConfigurationLoader
|
|
72
64
|
true
|
73
65
|
rescue KuberKit::Error => e
|
74
66
|
ui.print_error("Error", e.message)
|
67
|
+
|
75
68
|
false
|
76
69
|
end
|
77
70
|
|
@@ -104,6 +97,6 @@ class KuberKit::Actions::ConfigurationLoader
|
|
104
97
|
require(path)
|
105
98
|
end
|
106
99
|
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
107
|
-
|
100
|
+
ui.print_warning("ConfigurationLoader", "Directory with infrastructure not found: #{infra_path}")
|
108
101
|
end
|
109
102
|
end
|
@@ -3,7 +3,6 @@ class KuberKit::Actions::ImageCompiler
|
|
3
3
|
"image_compiler.image_dependency_resolver",
|
4
4
|
"image_compiler.build_server_pool_factory",
|
5
5
|
"shell.local_shell",
|
6
|
-
"tools.logger",
|
7
6
|
"ui",
|
8
7
|
image_compiler: "image_compiler.action_handler",
|
9
8
|
]
|
@@ -13,14 +12,17 @@ class KuberKit::Actions::ImageCompiler
|
|
13
12
|
build_id = generate_build_id
|
14
13
|
build_server_pool = build_server_pool_factory.create()
|
15
14
|
|
15
|
+
compiled_images = []
|
16
|
+
compilation_result = {}
|
16
17
|
image_dependency_resolver.each_with_deps(image_names) do |dep_image_names|
|
17
18
|
result = compile_simultaneously(dep_image_names, build_id, build_server_pool)
|
18
|
-
|
19
|
+
compiled_images += dep_image_names
|
20
|
+
compilation_result = compilation_result.merge(result)
|
19
21
|
end
|
20
22
|
|
21
23
|
build_server_pool.disconnect_all
|
22
24
|
|
23
|
-
|
25
|
+
{ images: compiled_images, compilation: compilation_result }
|
24
26
|
rescue KuberKit::Error => e
|
25
27
|
ui.print_error("Error", e.message)
|
26
28
|
|
@@ -30,20 +32,22 @@ class KuberKit::Actions::ImageCompiler
|
|
30
32
|
private
|
31
33
|
def compile_simultaneously(image_names, build_id, build_server_pool)
|
32
34
|
task_group = ui.create_task_group
|
35
|
+
compiler_result = {}
|
33
36
|
image_names.map do |image_name|
|
34
37
|
|
35
|
-
|
38
|
+
ui.print_debug("ImageCompiler", "Started compiling: #{image_name.to_s.green}")
|
36
39
|
task_group.add("Compiling #{image_name.to_s.yellow}") do |task|
|
37
40
|
shell = build_server_pool.get_shell
|
38
41
|
|
39
|
-
image_compiler.call(shell, image_name, build_id)
|
42
|
+
compiler_result[image_name] = image_compiler.call(shell, image_name, build_id)
|
40
43
|
|
41
44
|
task.update_title("Compiled #{image_name.to_s.green}")
|
42
|
-
|
45
|
+
ui.print_debug("ImageCompiler", "Finished compiling: #{image_name}")
|
43
46
|
end
|
44
47
|
|
45
48
|
end
|
46
49
|
task_group.wait
|
50
|
+
compiler_result
|
47
51
|
end
|
48
52
|
|
49
53
|
def generate_build_id
|
@@ -4,17 +4,17 @@ class KuberKit::Actions::ServiceDeployer
|
|
4
4
|
"service_deployer.service_list_resolver",
|
5
5
|
"core.service_store",
|
6
6
|
"shell.local_shell",
|
7
|
-
"tools.logger",
|
8
7
|
"ui",
|
9
8
|
service_deployer: "service_deployer.action_handler",
|
10
9
|
]
|
11
10
|
|
12
11
|
Contract KeywordArgs[
|
13
|
-
services:
|
14
|
-
tags:
|
15
|
-
skip_compile:
|
12
|
+
services: Maybe[ArrayOf[String]],
|
13
|
+
tags: Maybe[ArrayOf[String]],
|
14
|
+
skip_compile: Maybe[Bool],
|
15
|
+
require_confirmation: Maybe[Bool],
|
16
16
|
] => Any
|
17
|
-
def call(services:, tags:, skip_compile: false)
|
17
|
+
def call(services:, tags:, skip_compile: false, require_confirmation: false)
|
18
18
|
if services.empty? && tags.empty?
|
19
19
|
services, tags = show_tags_selection
|
20
20
|
end
|
@@ -25,7 +25,16 @@ class KuberKit::Actions::ServiceDeployer
|
|
25
25
|
)
|
26
26
|
|
27
27
|
unless service_names.any?
|
28
|
-
ui.print_warning "
|
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
|
29
38
|
end
|
30
39
|
|
31
40
|
services = service_names.map do |service_name|
|
@@ -35,9 +44,9 @@ class KuberKit::Actions::ServiceDeployer
|
|
35
44
|
images_names = services.map(&:images).flatten.uniq
|
36
45
|
|
37
46
|
compile_images(images_names) unless skip_compile
|
38
|
-
deploy_services(service_names)
|
47
|
+
deployment_result = deploy_services(service_names)
|
39
48
|
|
40
|
-
|
49
|
+
{ services: service_names, deployment: deployment_result }
|
41
50
|
rescue KuberKit::Error => e
|
42
51
|
ui.print_error("Error", e.message)
|
43
52
|
|
@@ -47,18 +56,22 @@ class KuberKit::Actions::ServiceDeployer
|
|
47
56
|
def deploy_services(service_names)
|
48
57
|
task_group = ui.create_task_group
|
49
58
|
|
59
|
+
deployer_result = {}
|
60
|
+
|
50
61
|
service_names.each do |service_name|
|
51
62
|
|
52
|
-
|
63
|
+
ui.print_debug("ServiceDeployer", "Started deploying: #{service_name.to_s.green}")
|
53
64
|
task_group.add("Deploying #{service_name.to_s.yellow}") do |task|
|
54
|
-
service_deployer.call(local_shell, service_name.to_sym)
|
65
|
+
deployer_result[service_name] = service_deployer.call(local_shell, service_name.to_sym)
|
55
66
|
|
56
67
|
task.update_title("Deployed #{service_name.to_s.green}")
|
57
|
-
|
68
|
+
ui.print_debug("ServiceDeployer", "Finished deploying: #{service_name.to_s.green}")
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
61
72
|
task_group.wait
|
73
|
+
|
74
|
+
deployer_result
|
62
75
|
end
|
63
76
|
|
64
77
|
def compile_images(images_names)
|
@@ -4,7 +4,8 @@ class KuberKit::ArtifactsSync::ArtifactsUpdater
|
|
4
4
|
include KuberKit::Import[
|
5
5
|
"artifacts_sync.git_artifact_resolver",
|
6
6
|
"artifacts_sync.null_artifact_resolver",
|
7
|
-
|
7
|
+
|
8
|
+
"ui"
|
8
9
|
]
|
9
10
|
|
10
11
|
def use_resolver(artifact_resolver, artifact_class:)
|
@@ -23,7 +24,7 @@ class KuberKit::ArtifactsSync::ArtifactsUpdater
|
|
23
24
|
artifacts.each do |artifact|
|
24
25
|
resolver = @@resolvers[artifact.class]
|
25
26
|
|
26
|
-
|
27
|
+
ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
|
27
28
|
|
28
29
|
raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
|
29
30
|
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'thor'
|
2
2
|
|
3
3
|
class KuberKit::CLI < Thor
|
4
|
+
APP_CONFIG_FILENAME = "config.rb".freeze
|
5
|
+
|
4
6
|
class_option :path, :type => :string
|
5
7
|
class_option :images_path, :type => :string
|
6
8
|
class_option :infra_path, :type => :string
|
7
9
|
class_option :configurations_path, :type => :string
|
10
|
+
class_option :ui, :type => :string, :desc => "UI mode (interactive|debug|simple)"
|
8
11
|
class_option :debug, :type => :boolean, aliases: ["-d"]
|
9
12
|
class_option :configuration, :type => :string, aliases: ["-C"]
|
10
13
|
|
11
14
|
desc "compile IMAGE_NAMES", "Compile image with IMAGE_NAMES (comma-separated)"
|
12
15
|
def compile(image_names_str)
|
13
|
-
|
16
|
+
setup(options)
|
14
17
|
|
15
18
|
image_names = image_names_str.split(",").map(&:strip).map(&:to_sym)
|
16
19
|
|
@@ -18,48 +21,43 @@ class KuberKit::CLI < Thor
|
|
18
21
|
result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
|
19
22
|
end
|
20
23
|
|
21
|
-
logger = KuberKit::Container['tools.logger']
|
22
24
|
if result
|
23
|
-
|
24
|
-
logger.info("Image compilation finished!")
|
25
|
-
logger.info("---------------------------")
|
25
|
+
print_result("Image compilation finished!", result: result)
|
26
26
|
else
|
27
|
-
|
28
|
-
logger.info("Image compilation failed!".red)
|
29
|
-
logger.info("-------------------------".red)
|
27
|
+
exit 1
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
|
34
|
-
method_option :services,
|
35
|
-
method_option :tags,
|
36
|
-
method_option :skip_compile,
|
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"]
|
37
36
|
def deploy
|
38
|
-
|
37
|
+
setup(options)
|
39
38
|
|
40
39
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
40
|
+
require_confirmation = options[:require_confirmation] ||
|
41
|
+
KuberKit.current_configuration.deployer_require_confirimation ||
|
42
|
+
false
|
41
43
|
result = KuberKit::Container['actions.service_deployer'].call(
|
42
|
-
services:
|
43
|
-
tags:
|
44
|
-
skip_compile:
|
44
|
+
services: options[:services] || [],
|
45
|
+
tags: options[:tags] || [],
|
46
|
+
skip_compile: options[:skip_compile] || false,
|
47
|
+
require_confirmation: require_confirmation
|
45
48
|
)
|
46
49
|
end
|
47
50
|
|
48
|
-
logger = KuberKit::Container['tools.logger']
|
49
51
|
if result
|
50
|
-
|
51
|
-
logger.info("Service deployment finished!")
|
52
|
-
logger.info("---------------------------")
|
52
|
+
print_result("Service deployment finished!", result: result)
|
53
53
|
else
|
54
|
-
|
55
|
-
logger.info("Service deployment failed!".red)
|
56
|
-
logger.info("-------------------------".red)
|
54
|
+
exit 1
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
desc "env ENV_FILE_NAME", "Return content of Env File ENV_FILE_NAME"
|
61
59
|
def env(env_file_name)
|
62
|
-
|
60
|
+
setup(options)
|
63
61
|
|
64
62
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
65
63
|
KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options)
|
@@ -68,7 +66,7 @@ class KuberKit::CLI < Thor
|
|
68
66
|
|
69
67
|
desc "template TEMPLATE_NAME", "Return content of Template TEMPLATE_NAME"
|
70
68
|
def template(template_name)
|
71
|
-
|
69
|
+
setup(options)
|
72
70
|
|
73
71
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
74
72
|
KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options)
|
@@ -77,7 +75,7 @@ class KuberKit::CLI < Thor
|
|
77
75
|
|
78
76
|
desc "service SERVICE_NAME", "Return content of Service SERVICE_NAME"
|
79
77
|
def service(service_name)
|
80
|
-
|
78
|
+
setup(options)
|
81
79
|
|
82
80
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
83
81
|
KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options)
|
@@ -86,7 +84,7 @@ class KuberKit::CLI < Thor
|
|
86
84
|
|
87
85
|
desc "apply FILE_PATH", "Apply FILE_PATH with kubectl"
|
88
86
|
def apply(file_path)
|
89
|
-
|
87
|
+
setup(options)
|
90
88
|
|
91
89
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
92
90
|
KuberKit::Container['actions.kubectl_applier'].call(File.expand_path(file_path), options)
|
@@ -95,26 +93,26 @@ class KuberKit::CLI < Thor
|
|
95
93
|
|
96
94
|
desc "attach POD_NAME", "Attach to POD_NAME using kubectl"
|
97
95
|
def attach(pod_name = nil)
|
98
|
-
|
96
|
+
setup(options)
|
99
97
|
|
100
98
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
101
99
|
KuberKit::Container['actions.kubectl_attacher'].call(pod_name, options)
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
|
-
desc "
|
103
|
+
desc "console POD_NAME", "Attach to POD_NAME using kubectl & launch bin/console"
|
106
104
|
def console(pod_name = nil)
|
107
|
-
|
105
|
+
setup(options)
|
108
106
|
|
109
107
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
110
108
|
KuberKit::Container['actions.kubectl_console'].call(pod_name, options)
|
111
109
|
end
|
112
110
|
end
|
113
111
|
|
114
|
-
desc "
|
112
|
+
desc "logs POD_NAME", "Show logs for POD_NAME using kubectl"
|
115
113
|
method_option :follow, :type => :boolean, aliases: ["-f"]
|
116
114
|
def logs(pod_name = nil)
|
117
|
-
|
115
|
+
setup(options)
|
118
116
|
|
119
117
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
120
118
|
KuberKit::Container['actions.kubectl_logs'].call(pod_name, options)
|
@@ -129,4 +127,24 @@ class KuberKit::CLI < Thor
|
|
129
127
|
def self.exit_on_failure?
|
130
128
|
true
|
131
129
|
end
|
130
|
+
|
131
|
+
private
|
132
|
+
def setup(options)
|
133
|
+
if options[:debug]
|
134
|
+
KuberKit.set_ui_mode(:debug)
|
135
|
+
elsif options[:ui]
|
136
|
+
KuberKit.set_ui_mode(options[:ui].to_sym)
|
137
|
+
end
|
138
|
+
|
139
|
+
# We should load config before loading any bean, to make sure that bean won't be built with default config
|
140
|
+
root_path = options[:path] || File.join(Dir.pwd, KuberKit::Container['configs'].kuber_kit_dirname)
|
141
|
+
config_file_path = File.join(root_path, APP_CONFIG_FILENAME)
|
142
|
+
if File.exists?(config_file_path)
|
143
|
+
require config_file_path
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def print_result(message, data = {})
|
148
|
+
KuberKit::Container['ui'].print_result(message, data)
|
149
|
+
end
|
132
150
|
end
|