class KuberKit::CLI
Constants
- APP_CONFIG_FILENAME
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/kuber_kit/cli.rb, line 176 def self.exit_on_failure? true end
Public Instance Methods
apply(file_path)
click to toggle source
# File lib/kuber_kit/cli.rb, line 108 def apply(file_path) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.kubectl_applier'].call(File.expand_path(file_path), options) end end
attach(pod_name = nil)
click to toggle source
# File lib/kuber_kit/cli.rb, line 117 def attach(pod_name = nil) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.kubectl_attacher'].call(pod_name, options) end end
check()
click to toggle source
# File lib/kuber_kit/cli.rb, line 99 def check() setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.service_checker'].call(options) end end
compile(image_names_str)
click to toggle source
# File lib/kuber_kit/cli.rb, line 16 def compile(image_names_str) setup(options) started_at = Time.now.to_i image_names = image_names_str.split(",").map(&:strip).map(&:to_sym) if KuberKit::Container['actions.configuration_loader'].call(options) action_result = KuberKit::Container['actions.image_compiler'].call(image_names, options) end if action_result && action_result.succeeded? time = (Time.now.to_i - started_at) print_result("Image compilation finished! (#{time}s)", result: { images: action_result.finished_tasks, compilation: action_result.all_results }) else exit 1 end end
console(pod_name = nil)
click to toggle source
# File lib/kuber_kit/cli.rb, line 126 def console(pod_name = nil) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false)) KuberKit::Container['actions.kubectl_console'].call(pod_name, options) end end
deploy()
click to toggle source
# File lib/kuber_kit/cli.rb, line 43 def deploy setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) require_confirmation = options[:require_confirmation] || KuberKit.current_configuration.deployer_require_confirmation || false started_at = Time.now.to_i action_result = KuberKit::Container['actions.service_deployer'].call( services: (options[:services] || []).flatten.uniq, tags: (options[:tags] || []).flatten.uniq, skip_services: (options[:skip_services] || []).flatten.uniq, skip_compile: options[:skip_compile] || false, require_confirmation: require_confirmation ) end if action_result && action_result.succeeded? time = (Time.now.to_i - started_at) print_result("Service deployment finished! (#{time}s)", result: { services: action_result.finished_tasks, deployment: action_result.all_results }) else exit 1 end end
describe(pod_name = nil)
click to toggle source
# File lib/kuber_kit/cli.rb, line 145 def describe(pod_name = nil) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false)) KuberKit::Container['actions.kubectl_describe'].call(pod_name, options) end end
env()
click to toggle source
# File lib/kuber_kit/cli.rb, line 154 def env() setup(options) if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false)) KuberKit::Container['actions.kubectl_env'].call(options) end end
envfile(env_file_name)
click to toggle source
# File lib/kuber_kit/cli.rb, line 72 def envfile(env_file_name) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options) end end
get(pod_name = nil)
click to toggle source
# File lib/kuber_kit/cli.rb, line 163 def get(pod_name = nil) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false)) KuberKit::Container['actions.kubectl_get'].call(pod_name, options) end end
logs(pod_name = nil)
click to toggle source
# File lib/kuber_kit/cli.rb, line 136 def logs(pod_name = nil) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false)) KuberKit::Container['actions.kubectl_logs'].call(pod_name, options) end end
service(service_name)
click to toggle source
# File lib/kuber_kit/cli.rb, line 90 def service(service_name) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options) end end
template(template_name)
click to toggle source
# File lib/kuber_kit/cli.rb, line 81 def template(template_name) setup(options) if KuberKit::Container['actions.configuration_loader'].call(options) KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options) end end
version()
click to toggle source
# File lib/kuber_kit/cli.rb, line 172 def version puts KuberKit::VERSION end
Private Instance Methods
print_result(message, data = {})
click to toggle source
# File lib/kuber_kit/cli.rb, line 200 def print_result(message, data = {}) KuberKit::Container['ui'].print_result(message, data) end
setup(options)
click to toggle source
# File lib/kuber_kit/cli.rb, line 181 def setup(options) if options[:debug] KuberKit.set_ui_mode(:debug) elsif options[:ui] KuberKit.set_ui_mode(options[:ui].to_sym) end if options[:user] KuberKit.set_user(options[:user]) end # We should load config before loading any bean, to make sure that bean won't be built with default config root_path = KuberKit::Container['tools.workdir_detector'].call(options) config_file_path = File.join(root_path, APP_CONFIG_FILENAME) if File.exists?(config_file_path) require config_file_path end end