Sha256: 9174d773df07e7e8947b35fa205b90a457427727d9f84e8f1f013aae3ed24bdf

Contents?: true

Size: 1018 Bytes

Versions: 1

Compression:

Stored size: 1018 Bytes

Contents

module Kubes::Compiler::Shared::Helpers
  module ConfigMapHelper
    def config_map_files(options={})
      indent = options[:indent] || 2

      shared_config_map = "#{Kubes.root}/.kubes/resources/shared/config_map"
      layers = [
        [shared_config_map, "base.txt"],
        [shared_config_map, "#{Kubes.env}.txt"],
      ]
      if Kubes.app
        layers += [
          [shared_config_map, Kubes.app, "base.txt"],
          [shared_config_map, Kubes.app, "#{Kubes.env}.txt"],
        ]
      end
      layers.map! { |layer| layer.compact.join('/') }
      data = {}
      layers.each do |path|
        next unless File.exist?(path)
        text = RenderMePretty.result(path, context: self)
        lines = text.split("\n")
        lines.each do |line|
          key, value = parse_env_like_line(line)
          data[key] = value
        end
      end

      spacing = " " * indent
      lines = data.map do |key,value|
        "#{spacing}#{key}: #{value}"
      end
      lines.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kubes-0.8.5 lib/kubes/compiler/shared/helpers/config_map_helper.rb