Sha256: 0cd8df61f35899b02e2c21a865e08cc231319cc2083d97eab58465bca99d2ac4

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Krane
  module CLI
    class RenderCommand
      OPTIONS = {
        bindings: { type: :array, banner: "foo=bar abc=def", desc: 'Bindings for erb' },
        filenames: { type: :array, banner: 'config/deploy/production config/deploy/my-extra-resource.yml',
                     required: true, aliases: 'f', desc: 'Directories and files to render' },
        'current-sha': { type: :string, banner: "SHA", desc: "Expose SHA `current_sha` in ERB bindings" },
      }

      def self.from_options(options)
        require 'krane/render_task'
        require 'krane/bindings_parser'
        require 'krane/options_helper'

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

        ::Krane::OptionsHelper.with_processed_template_paths(options[:filenames]) do |paths|
          runner = ::Krane::RenderTask.new(
            current_sha: options['current-sha'],
            template_paths: paths,
            bindings: bindings_parser.parse,
          )
          runner.run!(STDOUT)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kubernetes-deploy-0.31.1 lib/krane/cli/render_command.rb
kubernetes-deploy-0.31.0 lib/krane/cli/render_command.rb