Class: Krane::CLI::RenderCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/krane/cli/render_command.rb

Constant Summary collapse

OPTIONS =
{
  bindings: { type: :array, desc: 'Bindings for erb' },
  filenames: { type: :array, required: true, aliases: 'f', desc: 'Directories and files to render' },
}

Class Method Summary collapse

Class Method Details

.from_options(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/krane/cli/render_command.rb', line 11

def self.from_options(options)
  require 'kubernetes-deploy/render_task'
  require 'kubernetes-deploy/bindings_parser'
  require 'kubernetes-deploy/options_helper'

  bindings_parser = KubernetesDeploy::BindingsParser.new
  options[:bindings]&.each { |b| bindings_parser.add(b) }

  KubernetesDeploy::OptionsHelper.with_processed_template_paths(options[:filenames]) do |paths|
    runner = KubernetesDeploy::RenderTask.new(
      current_sha: ENV["REVISION"],
      template_paths: paths,
      bindings: bindings_parser.parse,
    )
    runner.run!(STDOUT)
  end
end