Sha256: 987f2c4881985835b935fd91810f9834ad6bb5635e781a9dc6288dcaf7e303a7

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

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}.txt"],
          [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

8 entries across 8 versions & 1 rubygems

Version Path
kubes-0.9.2 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.9.1 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.9.0 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.8.10 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.8.9 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.8.8 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.8.7 lib/kubes/compiler/shared/helpers/config_map_helper.rb
kubes-0.8.6 lib/kubes/compiler/shared/helpers/config_map_helper.rb