Class: Kerby::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/kerby/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kerby/cli.rb', line 13

def exit_on_failure?
  true
end

Instance Method Details

#build(*src_manifests) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/kerby/cli.rb', line 20

def build(*src_manifests)
  load_k8s_node(options[:node_yaml])
  temp_name  = sprintf("/tmp/kerby-%s-%s.yml",
                       Time.now.strftime("%Y%m%d-%H%M%S"),
                       SecureRandom.alphanumeric(8).downcase)
  t = File.open(temp_name, 'w')
  for src_manifest in src_manifests do
    saved_file = @_curr_file; @_curr_file = src_manifest
    File.write(t.path, ERB.new(File.read(src_manifest)).result(binding))
  end
  t.close

  File.open(temp_name) do |f|
    while s = f.gets do
      print s
    end
  end
  
  FileUtils.rm_f(temp_name)
  @_curr_file = saved_file
end