Class: JamesBond::MissionKubernetes::BuildHandler
- Inherits:
-
Object
- Object
- JamesBond::MissionKubernetes::BuildHandler
- Defined in:
- lib/james_bond/mission_kubernetes/build_handler.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(command, config) ⇒ BuildHandler
constructor
A new instance of BuildHandler.
- #run ⇒ Object
- #tag ⇒ Object
Constructor Details
#initialize(command, config) ⇒ BuildHandler
Returns a new instance of BuildHandler.
9 10 11 12 |
# File 'lib/james_bond/mission_kubernetes/build_handler.rb', line 9 def initialize(command, config) @command = command @config = config.for(env: command.env, command: command.main_command) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/james_bond/mission_kubernetes/build_handler.rb', line 7 def config @config end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/james_bond/mission_kubernetes/build_handler.rb', line 14 def run target = "#{config["image_name"]}:#{tag}" command = "docker build -t #{target} ." Open3.popen3(command) do |stdin, stdout, stderr, thread| Thread.new do until (line = stdout.gets).nil? do puts line end end thread.join end { tag: tag } end |
#tag ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/james_bond/mission_kubernetes/build_handler.rb', line 31 def tag = @command. time_tag = "devel-#{Time.now.to_i}" @tag ||= if && [:tag] [:tag] else time_tag end end |