Class: KuberKit::CLI

Inherits:
Thor show all
Defined in:
lib/kuber_kit/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure? ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/kuber_kit/cli.rb', line 129

def self.exit_on_failure?
  true
end

Instance Method Details

#apply(file_path) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/kuber_kit/cli.rb', line 88

def apply(file_path)
  KuberKit.set_debug_mode(options[:debug])

  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) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/kuber_kit/cli.rb', line 97

def attach(pod_name = nil)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.kubectl_attacher'].call(pod_name, options)
  end
end

#compile(image_names_str) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kuber_kit/cli.rb', line 12

def compile(image_names_str)
  KuberKit.set_debug_mode(options[:debug])
  
  image_names = image_names_str.split(",").map(&:strip).map(&:to_sym)

  if KuberKit::Container['actions.configuration_loader'].call(options)
    result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
  end

  logger = KuberKit::Container['tools.logger']
  if result
    logger.info("---------------------------")
    logger.info("Image compilation finished!")
    logger.info("---------------------------")
  else
    logger.info("-------------------------".red)
    logger.info("Image compilation failed!".red)
    logger.info("-------------------------".red)
  end
end

#console(pod_name = nil) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/kuber_kit/cli.rb', line 106

def console(pod_name = nil)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.kubectl_console'].call(pod_name, options)
  end
end

#deploy ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/kuber_kit/cli.rb', line 37

def deploy
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    result = KuberKit::Container['actions.service_deployer'].call(
      services:     options[:services] || [], 
      tags:         options[:tags] || [],
      skip_compile: options[:skip_compile] || false
    )
  end

  logger = KuberKit::Container['tools.logger']
  if result
    logger.info("---------------------------")
    logger.info("Service deployment finished!")
    logger.info("---------------------------")
  else
    logger.info("-------------------------".red)
    logger.info("Service deployment failed!".red)
    logger.info("-------------------------".red)
  end
end

#env(env_file_name) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/kuber_kit/cli.rb', line 61

def env(env_file_name)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options)
  end
end

#logs(pod_name = nil) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/kuber_kit/cli.rb', line 116

def logs(pod_name = nil)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.kubectl_logs'].call(pod_name, options)
  end
end

#service(service_name) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/kuber_kit/cli.rb', line 79

def service(service_name)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options)
  end
end

#template(template_name) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/kuber_kit/cli.rb', line 70

def template(template_name)
  KuberKit.set_debug_mode(options[:debug])

  if KuberKit::Container['actions.configuration_loader'].call(options)
    KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options)
  end
end

#version ⇒ Object



125
126
127
# File 'lib/kuber_kit/cli.rb', line 125

def version
  puts KuberKit::VERSION
end