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)


108
109
110
# File 'lib/kuber_kit/cli.rb', line 108

def self.exit_on_failure?
  true
end

Instance Method Details

#apply(file_path) ⇒ Object



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

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



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

def attach(pod_name)
  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

#deployObject



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

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] || []
    )
  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



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

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

#service(service_name) ⇒ Object



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

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



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

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

#versionObject



104
105
106
# File 'lib/kuber_kit/cli.rb', line 104

def version
  puts KuberKit::VERSION
end