class JamesBond::MissionKubernetes::PatchDeployHandler
Attributes
config[RW]
Public Class Methods
new(command, config)
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 9 def initialize(command, config) @command = command @config = config.for( env: command.options[:environment], command: command.main_command ) end
Public Instance Methods
run()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 17 def run command = [ "kubectl", "patch", "deployment #{app_name}", "-p '#{JSON.dump(spec)}'", ] command = switch_environment(command).join(' ') puts command Open3.popen3(command) do |stdin, stdout, stderr, thread| Thread.new do until (line = stdout.gets).nil? do puts line end end Thread.new do until (line = stderr.gets).nil? do puts line end end thread.join end end
Private Instance Methods
app_name()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 59 def app_name @config["app_name"] end
image_name()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 63 def image_name @config["image_name"] end
kubeconfig()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 55 def kubeconfig File.join(Dir.pwd, @config["kubeconfig_path"]) end
spec()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 71 def spec { spec: { template: { spec: { containers: [ { name: app_name, image: target } ] } } } } end
switch_environment(patch_command)
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 47 def switch_environment(patch_command) if @command.options[:environment] == 'production' patch_command << ["--kubeconfig=#{kubeconfig}"] else patch_command end end
target()
click to toggle source
# File lib/james_bond/mission_kubernetes/patch_deploy_handler.rb, line 67 def target "#{image_name}:#{@command.options[:tag]}" end