Sha256: 2386570c37503d35712fd2cf6ec3c497eab3f1dab78e0883481387198ed8258a

Contents?: true

Size: 678 Bytes

Versions: 8

Compression:

Stored size: 678 Bytes

Contents

require 'yaml'

module Kaname
  class Resource
    class << self
      def yaml(filename = 'keystone.yml')
        if File.exist?(filename)
          @_yaml ||= expand_all_tenants(YAML.load_file(filename))
        end
      end

      private

      def expand_all_tenants _yaml
        list_tenants = Kaname::Adapter::ReadOnly.new.list_tenants

        _yaml.each do |username, config|
          next unless config['all_tenants']
          tenants = list_tenants.map{|tenant| [tenant.name, config['all_tenants']]}
          config['tenants'] = Hash[*tenants.flatten].merge(config['tenants'] || {})
          config.delete('all_tenants')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kaname-0.10.0 lib/kaname/resource.rb
kaname-0.9.0 lib/kaname/resource.rb
kaname-0.8.2 lib/kaname/resource.rb
kaname-0.8.1 lib/kaname/resource.rb
kaname-0.8.0 lib/kaname/resource.rb
kaname-0.7.1 lib/kaname/resource.rb
kaname-0.7.0 lib/kaname/resource.rb
kaname-0.6.3 lib/kaname/resource.rb