Sha256: 0dbd9a749c173cbdc6328ad35c88486b5e65a7f0ee25d7eda78304dfd371f1c0

Contents?: true

Size: 999 Bytes

Versions: 10

Compression:

Stored size: 999 Bytes

Contents

module Kubes::Compiler::Shared
  module CustomVariables
    include DslEvaluator

    # Load custom variables from project
    @@custom_variables_loaded = false
    def load_custom_variables
      return if Kubes.kustomize?

      ext = File.extname(@path)
      role = @path.sub(%r{.*\.kubes/resources/},'').sub(ext,'').split('/').first # IE: web
      kind = File.basename(@path).sub(ext,'') # IE: deployment
      all = "all"
      if @block_form
        kind = kind.pluralize
        all = all.pluralize
      end

      layers = [
        "base.rb",
        "#{Kubes.env}.rb",
        "base/all.rb",
        "base/all/#{Kubes.env}.rb",
        "base/#{kind}.rb",
        "base/#{kind}/base.rb",
        "base/#{kind}/#{Kubes.env}.rb",
        "#{role}/#{kind}.rb",
        "#{role}/#{kind}/base.rb",
        "#{role}/#{kind}/#{Kubes.env}.rb",
      ]

      layers.each do |layer|
        path = "#{Kubes.root}/.kubes/variables/#{layer}"
        evaluate_file(path)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kubes-0.7.0 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.8 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.7 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.6 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.5 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.4 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.3 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.2 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.1 lib/kubes/compiler/shared/custom_variables.rb
kubes-0.6.0 lib/kubes/compiler/shared/custom_variables.rb