diff --git a/Gemfile b/Gemfile index b6f2310a9b9..0131b805520 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # load Katello configuration path = File.expand_path('../lib', __FILE__) $LOAD_PATH << path unless $LOAD_PATH.include? path -require 'katello_config' +require 'katello/load_configuration' # When adding new version requirement check out EPEL6 repository first # and use this version if possible. Also check Fedora version (usually higher). diff --git a/Gemfile32 b/Gemfile32 index 7b1f4d6117b..32bf341886f 100644 --- a/Gemfile32 +++ b/Gemfile32 @@ -7,7 +7,7 @@ end # load Katello configuration path = File.expand_path('../lib', __FILE__) $LOAD_PATH << path unless $LOAD_PATH.include? path -require 'katello_config' +require 'katello/load_configuration' # When adding new version requirement check out EPEL6 repository first # and use this version if possible. Also check Fedora version (usually higher). diff --git a/config/application.rb b/config/application.rb index 1f55fa5e667..cc217176a4a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,8 +9,8 @@ path = File.expand_path("../lib", File.dirname(__FILE__)) $LOAD_PATH << path unless $LOAD_PATH.include? path -require 'katello_config' -require 'katello_logging' +require 'katello/load_configuration' +require 'katello/logging' # If you have a Gemfile, require the gems listed there, including any gems diff --git a/config/compass.rb b/config/compass.rb index 082d7f6a645..c35831564f8 100644 --- a/config/compass.rb +++ b/config/compass.rb @@ -1,7 +1,7 @@ path = File.expand_path('../lib', File.dirname(__FILE__)) $LOAD_PATH << path unless $LOAD_PATH.include? path -require 'katello_config' +require 'katello/load_configuration' require 'ninesixty' # Set this to the root of your project when deployed: diff --git a/katello.spec b/katello.spec index 714603cb22f..ef97d15b3ec 100644 --- a/katello.spec +++ b/katello.spec @@ -596,6 +596,7 @@ usermod -a -G katello-shared tomcat %{homedir}/db/seeds.rb %{homedir}/integration_spec %{homedir}/lib/*.rb +%{homedir}/lib/katello/ %exclude %{homedir}/lib/README %exclude %{homedir}/app/lib/README %{homedir}/app/lib/*.rb diff --git a/lib/configuration.rb b/lib/configuration.rb deleted file mode 100644 index d50b2486998..00000000000 --- a/lib/configuration.rb +++ /dev/null @@ -1,368 +0,0 @@ -# -# Copyright 2012 Red Hat, Inc. -# -# This software is licensed to you under the GNU General Public -# License as published by the Free Software Foundation; either version -# 2 of the License (GPLv2) or (at your option) any later version. -# There is NO WARRANTY for this software, express or implied, -# including the implied warranties of MERCHANTABILITY, -# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should -# have received a copy of GPLv2 along with this software; if not, see -# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - -require 'yaml' -require 'erb' - -# Katello::Configuration module contains all necessary code for Katello configuration. -# Configuration is not dependent on any gem which allows loading configuration very early -# (even before Rails). Therefore this configuration can be used anywhere -# (Gemfile, boot scripts, stand-alone) -# -# Configuration access points are methods {Katello.config} and {Katello.early_config}, see method documentation. -# -# Default configuration values are stored in `src/config/katello_defaults.yml`. Default values can be overridden -# in configuration files (`config/katello.yml` or `/etc/katello/katello.yml`) -# -# Configuration is represented with tree-like-structure defined with Configuration::Node. Node has -# minimal Hash-like interface. Node is more strict than Hash. Differences: -# * If undefined key is accessed an error NoKey is raised (keys with nil values has to be -# defined explicitly). -# * Keys can be accessed by methods. `config.host` is equivalent to `config[:host]` -# * All keys has to be Symbols, otherwise you get an ArgumentError -# -# AppConfig will work for now, but warning is printed to `$stderr`. -# -# Some examples -# -# !!!txt -# # create by a Hash which is converted to Node instance -# irb> n = Katello::Configuration::Node.new 'a' => nil -# => #nil}> -# -# # assign a value, also converted -# irb> n[:a] = {'a' => 12} -# => {:a=>12} -# irb> n -# => ##12}>}> -# -# # accessing a key -# irb> n['a'] -# ArgumentError: "a" should be a Symbol -# irb> n[:a] -# => #12}> -# irb> n[:not] -# Katello::Configuration::Node::NoKey: missing key 'not' in configuration -# -# # supports deep_merge and #to_hash -# irb> n.deep_merge!('a' => {:b => 34}) -# => ##12, :b=>34}>}> -# irb> n.to_hash -# => {:a=>{:a=>12, :b=>34}} -# -module Configuration - - # Hash like container for configuration - # @example allows access by method - # Config.new('a' => {:b => 2}).a.b # => 2 - class Node - class NoKey < StandardError - def initialize(message = nil) - #noinspection RubyArgCount - super(" missing key '#{message}' in configuration") - end - end - - def initialize(data = {}) - @data = convert_hash data - end - - include Enumerable - - def each(&block) - @data.each &block - end - - # get configuration for `key` - # @param [Symbol] key - # @raise [NoKye] when key is missing - def [](key) - raise ArgumentError, "#{key.inspect} should be a Symbol" unless Symbol === key - if has_key? key - @data[key].is_a?(Proc) ? @data[key].call : @data[key] - else - raise NoKey, key.to_s - end - end - - # converts `value` to Config - # @see #convert - def []=(key, value) - @data[key.to_sym] = convert value - end - - def has_key?(key) - @data.has_key? key - end - - # @example does node contain value at `node[:key1][:key2]` - # node.present? :key1, :key2 - def present?(*keys) - key, rest = keys.first, keys[1..-1] - raise ArgumentError, 'supply at least one key' unless key - has_key? key and self[key] and if rest.empty? - true - elsif Node === self[key] - self[key].present?(*rest) - else - false - end - end - - # allows access keys by method call - # @raise [NoKye] when `key` is missing - def method_missing(method, *args, &block) - if has_key?(method) - self[method] - else - begin - super - rescue NoMethodError => e - raise NoKey, method.to_s - end - end - end - - # respond to implementation according to method missing - def respond_to?(symbol, include_private=false) - has_key?(symbol) || super - end - - - # does not supports Hashes in Arrays - def deep_merge!(hash_or_config) - return self if hash_or_config.nil? - other_config = convert hash_or_config - other_config.each do |key, other_value| - value = has_key?(key) && self[key] - self[key] = if Node === value && Node === other_value - value.deep_merge!(other_value) - elsif Node === value && other_value.nil? - self[key] - else - other_value - end - end - self - end - - def to_hash - @data.inject({}) do |hash, (k, v)| - hash.update k => (Node === v ? v.to_hash : v) - end - end - - private - - # converts config like deep structure by finding Hashes deeply and converting them to Config - def convert(obj) - case obj - when Node - obj - when Hash - Node.new convert_hash obj - when Array - obj.map { |o| convert o } - else - obj - end - end - - # converts Hash by symbolizing keys and allowing only symbols as keys - def convert_hash(hash) - raise ArgumentError, "#{hash.inspect} is not a Hash" unless Hash === hash - - hash.keys.each do |key| - hash[(key.to_sym rescue key) || key] = convert hash.delete(key) - end - - hash.keys.all? do |k| - Symbol === k or raise ArgumentError, "keys must be Symbols, #{k.inspect} is not" - end - hash - end - end - - # defines small dsl for validating configuration - class Validator - attr_reader :config, :environment, :path - - # @param [Node] config - # @param [nil, Symbol] environment use nil for early or Symbol for environment - # @yield block with validations - def initialize(config, environment, path = [], &validations) - @config, @environment, @path = config, environment, path - instance_eval &validations - end - - private - - def early? - !environment - end - - # validate sub key - # @yield block with validations - def validate(key, &block) - Validator.new config[key] || Node.new, environment, (self.path + [key]), &block - end - - def are_booleans(*keys) - keys.each { |key| is_boolean key } - end - - def is_boolean(key) - has_values key, [true, false] - end - - def has_values(key, values, options = {}) - values << nil if options[:allow_nil] - return true if values.include?(config[key]) - raise ArgumentError, error_format(key, "should be one of #{values.inspect}, but was #{config[key].inspect}") - end - - def has_keys(*keys) - keys.each { |key| has_key key } - end - - def has_key(key) - unless config.has_key? key.to_sym - raise error_format(key.to_sym, 'is required') - end - end - - private - - def error_format(key, message) - key_path = (path + [key]).join('.') - env = environment ? "'#{environment}' environment" : 'early configuration' - "Key: '#{key_path}' in #{env} #{message}" - end - - def is_not_empty(key) - if config[key].nil? || config[key].empty? - raise error_format(key.to_sym, "must not be empty") - end - end - end - - # processes configuration loading from config_files - class Loader - attr_reader :config_file_paths, - :validation, - :default_config_file_path, - :config_post_process, - :load_yml_post_process - - # @param [Hash] options - # @option options [Array] :config_file_paths possible configuration file paths - # @option options [String] :default_config_file_path path to default configuration values - # @option options [Proc] :validation validating the configuration - # @option options [Proc] :config_post_process called on each full configuration after it's constructed - # e.g. to add config[:katello?] = lambda { config.app_mode == 'katello' } - # @option options [Proc] :load_yml_post_process called on each configuration loaded from yaml file - # e.g. to decrypt db password - def initialize(options = {}) - @config_file_paths = options[:config_file_paths] || raise(ArgumentError) - @default_config_file_path = options[:default_config_file_path] || raise(ArgumentError) - @validation = options[:validation] || raise(ArgumentError) - @config_post_process = options[:config_post_process] || lambda {} - @load_yml_post_process = options[:load_yml_post_process] || lambda {} - end - - # raw config data from katello.yml represented with Node - def config_data - @config_data ||= Node.new.tap do |c| - c.deep_merge! default_config_data - c.deep_merge! load_yml_file(config_file_path) - end - end - - # raw config data from katello_defaults.yml represented with Node - def default_config_data - @default_config_data ||= load_yml_file default_config_file_path - end - - # access point for Katello configuration - def config - @config ||= load(environment) - end - - # Configuration without environment applied, use in early stages (before Rails are loaded) - # like Gemfile and other scripts - def early_config - @early_config ||= load - end - - # @return [Hash{String => Hash}] database configurations - def database_configs - @database_configs ||= begin - %w(production development test).inject({}) do |hash, environment| - common = config_data.common.database.to_hash - if config_data.present?(environment.to_sym, :database) - hash.update( - environment => - common.merge(config_data[environment.to_sym].database.to_hash).stringify_keys) - else - hash - end - end - end - end - - private - - def load(environment = nil) - Node.new.tap do |c| - load_config_file c, environment - config_post_process.call c, environment - validate c, environment - end - end - - def load_yml_file(file_path) - raw_parsed_yml = YAML::load(ERB.new(File.read(file_path)).result(Object.new.send(:binding))) - hash_parsed_yml = case raw_parsed_yml - when Hash - raw_parsed_yml - when nil, false, '' - {} - else - raise "malformed yml file '#{file_path}'" - end - - Node.new(hash_parsed_yml).tap do |config| - load_yml_post_process.call(config) - end - end - - def environment - Rails.env.to_sym rescue raise 'Rails.env is not accessible, try to use #early_config instead' - end - - def load_config_file(config, environment = nil) - config.deep_merge! config_data[:common] - config.deep_merge! config_data[environment] if environment - end - - def validate(config, environment) - Validator.new config, environment, &validation - end - - def config_file_path - @config_file_path ||= config_file_paths.find { |path| File.exist? path } or - raise "no config file found, candidates: #{config_file_paths.join ' '}" - end - end -end diff --git a/lib/katello/configuration.rb b/lib/katello/configuration.rb new file mode 100644 index 00000000000..a14c1b9b9d6 --- /dev/null +++ b/lib/katello/configuration.rb @@ -0,0 +1,71 @@ +# +# Copyright 2012 Red Hat, Inc. +# +# This software is licensed to you under the GNU General Public +# License as published by the Free Software Foundation; either version +# 2 of the License (GPLv2) or (at your option) any later version. +# There is NO WARRANTY for this software, express or implied, +# including the implied warranties of MERCHANTABILITY, +# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should +# have received a copy of GPLv2 along with this software; if not, see +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + + +# Katello::Configuration module contains all necessary code for Katello configuration. +# Configuration is not dependent on any gem which allows loading configuration very early +# (even before Rails). Therefore this configuration can be used anywhere +# (Gemfile, boot scripts, stand-alone) +# +# Configuration access points are methods {Katello.config} and {Katello.early_config}, see method documentation. +# +# Default configuration values are stored in `src/config/katello_defaults.yml`. Default values can be overridden +# in configuration files (`config/katello.yml` or `/etc/katello/katello.yml`) +# +# Configuration is represented with tree-like-structure defined with Configuration::Node. Node has +# minimal Hash-like interface. Node is more strict than Hash. Differences: +# * If undefined key is accessed an error NoKey is raised (keys with nil values has to be +# defined explicitly). +# * Keys can be accessed by methods. `config.host` is equivalent to `config[:host]` +# * All keys has to be Symbols, otherwise you get an ArgumentError +# +# AppConfig will work for now, but warning is printed to `$stderr`. +# +# Some examples +# +# !!!txt +# # create by a Hash which is converted to Node instance +# irb> n = Katello::Configuration::Node.new 'a' => nil +# => #nil}> +# +# # assign a value, also converted +# irb> n[:a] = {'a' => 12} +# => {:a=>12} +# irb> n +# => ##12}>}> +# +# # accessing a key +# irb> n['a'] +# ArgumentError: "a" should be a Symbol +# irb> n[:a] +# => #12}> +# irb> n[:not] +# Katello::Configuration::Node::NoKey: missing key 'not' in configuration +# +# # supports deep_merge and #to_hash +# irb> n.deep_merge!('a' => {:b => 34}) +# => ##12, :b=>34}>}> +# irb> n.to_hash +# => {:a=>{:a=>12, :b=>34}} +# +module Katello + module Configuration + path = File.expand_path(File.join(File.dirname(__FILE__), '..')) + $LOAD_PATH << path unless $LOAD_PATH.include? path + + require 'katello/configuration/node' + require 'katello/configuration/validator' + require 'katello/configuration/loader' + end +end diff --git a/lib/katello/configuration/loader.rb b/lib/katello/configuration/loader.rb new file mode 100644 index 00000000000..a4a3f80d1c1 --- /dev/null +++ b/lib/katello/configuration/loader.rb @@ -0,0 +1,128 @@ +# +# Copyright 2013 Red Hat, Inc. +# +# This software is licensed to you under the GNU General Public +# License as published by the Free Software Foundation; either version +# 2 of the License (GPLv2) or (at your option) any later version. +# There is NO WARRANTY for this software, express or implied, +# including the implied warranties of MERCHANTABILITY, +# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should +# have received a copy of GPLv2 along with this software; if not, see +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + +require 'yaml' +require 'erb' + +module Katello + module Configuration + + # processes configuration loading from config_files + class Loader + attr_reader :config_file_paths, + :validation, + :default_config_file_path, + :config_post_process, + :load_yml_post_process + + # @param [Hash] options + # @option options [Array] :config_file_paths possible configuration file paths + # @option options [String] :default_config_file_path path to default configuration values + # @option options [Proc] :validation validating the configuration + # @option options [Proc] :config_post_process called on each full configuration after it's constructed + # e.g. to add config[:katello?] = lambda { config.app_mode == 'katello' } + # @option options [Proc] :load_yml_post_process called on each configuration loaded from yaml file + # e.g. to decrypt db password + def initialize(options = {}) + @config_file_paths = options[:config_file_paths] || raise(ArgumentError) + @default_config_file_path = options[:default_config_file_path] || raise(ArgumentError) + @validation = options[:validation] || raise(ArgumentError) + @config_post_process = options[:config_post_process] || lambda {} + @load_yml_post_process = options[:load_yml_post_process] || lambda {} + end + + # raw config data from katello.yml represented with Node + def config_data + @config_data ||= Node.new.tap do |c| + c.deep_merge! default_config_data + c.deep_merge! load_yml_file(config_file_path) + end + end + + # raw config data from katello_defaults.yml represented with Node + def default_config_data + @default_config_data ||= load_yml_file default_config_file_path + end + + # access point for Katello configuration + def config + @config ||= load(environment) + end + + # Configuration without environment applied, use in early stages (before Rails are loaded) + # like Gemfile and other scripts + def early_config + @early_config ||= load + end + + # @return [Hash{String => Hash}] database configurations + def database_configs + @database_configs ||= begin + %w(production development test).inject({}) do |hash, environment| + common = config_data.common.database.to_hash + if config_data.present?(environment.to_sym, :database) + hash.update( + environment => + common.merge(config_data[environment.to_sym].database.to_hash).stringify_keys) + else + hash + end + end + end + end + + private + + def load(environment = nil) + Node.new.tap do |c| + load_config_file c, environment + config_post_process.call c, environment + validate c, environment + end + end + + def load_yml_file(file_path) + raw_parsed_yml = YAML::load(ERB.new(File.read(file_path)).result(Object.new.send(:binding))) + hash_parsed_yml = case raw_parsed_yml + when Hash + raw_parsed_yml + when nil, false, '' + {} + else + raise "malformed yml file '#{file_path}'" + end + + Node.new(hash_parsed_yml).tap do |config| + load_yml_post_process.call(config) + end + end + + def environment + Rails.env.to_sym rescue raise 'Rails.env is not accessible, try to use #early_config instead' + end + + def load_config_file(config, environment = nil) + config.deep_merge! config_data[:common] + config.deep_merge! config_data[environment] if environment + end + + def validate(config, environment) + Validator.new config, environment, &validation + end + + def config_file_path + @config_file_path ||= config_file_paths.find { |path| File.exist? path } or + raise "no config file found, candidates: #{config_file_paths.join ' '}" + end + end + end +end \ No newline at end of file diff --git a/lib/katello/configuration/node.rb b/lib/katello/configuration/node.rb new file mode 100644 index 00000000000..bf8596f4ea5 --- /dev/null +++ b/lib/katello/configuration/node.rb @@ -0,0 +1,147 @@ +# +# Copyright 2013 Red Hat, Inc. +# +# This software is licensed to you under the GNU General Public +# License as published by the Free Software Foundation; either version +# 2 of the License (GPLv2) or (at your option) any later version. +# There is NO WARRANTY for this software, express or implied, +# including the implied warranties of MERCHANTABILITY, +# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should +# have received a copy of GPLv2 along with this software; if not, see +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + +module Katello + module Configuration + + # Hash like container for configuration + # @example allows access by method + # Config.new('a' => {:b => 2}).a.b # => 2 + class Node + class NoKey < StandardError + def initialize(message = nil) + #noinspection RubyArgCount + super(" missing key '#{message}' in configuration") + end + end + + def initialize(data = {}) + @data = convert_hash data + end + + include Enumerable + + def each(&block) + @data.each &block + end + + # get configuration for `key` + # @param [Symbol] key + # @raise [NoKye] when key is missing + def [](key) + raise ArgumentError, "#{key.inspect} should be a Symbol" unless Symbol === key + if has_key? key + @data[key].is_a?(Proc) ? @data[key].call : @data[key] + else + raise NoKey, key.to_s + end + end + + # converts `value` to Config + # @see #convert + def []=(key, value) + @data[key.to_sym] = convert value + end + + def has_key?(key) + @data.has_key? key + end + + # @example does node contain value at `node[:key1][:key2]` + # node.present? :key1, :key2 + def present?(*keys) + key, rest = keys.first, keys[1..-1] + raise ArgumentError, 'supply at least one key' unless key + has_key? key and self[key] and if rest.empty? + true + elsif Node === self[key] + self[key].present?(*rest) + else + false + end + end + + # allows access keys by method call + # @raise [NoKye] when `key` is missing + def method_missing(method, *args, &block) + if has_key?(method) + self[method] + else + begin + super + rescue NoMethodError => e + raise NoKey, method.to_s + end + end + end + + # respond to implementation according to method missing + def respond_to?(symbol, include_private=false) + has_key?(symbol) || super + end + + + # does not supports Hashes in Arrays + def deep_merge!(hash_or_config) + return self if hash_or_config.nil? + other_config = convert hash_or_config + other_config.each do |key, other_value| + value = has_key?(key) && self[key] + self[key] = if Node === value && Node === other_value + value.deep_merge!(other_value) + elsif Node === value && other_value.nil? + self[key] + else + other_value + end + end + self + end + + def to_hash + @data.inject({}) do |hash, (k, v)| + hash.update k => (Node === v ? v.to_hash : v) + end + end + + private + + # converts config like deep structure by finding Hashes deeply and converting them to Config + def convert(obj) + case obj + when Node + obj + when Hash + Node.new convert_hash obj + when Array + obj.map { |o| convert o } + else + obj + end + end + + # converts Hash by symbolizing keys and allowing only symbols as keys + def convert_hash(hash) + raise ArgumentError, "#{hash.inspect} is not a Hash" unless Hash === hash + + hash.keys.each do |key| + hash[(key.to_sym rescue key) || key] = convert hash.delete(key) + end + + hash.keys.all? do |k| + Symbol === k or raise ArgumentError, "keys must be Symbols, #{k.inspect} is not" + end + hash + end + end + end +end \ No newline at end of file diff --git a/lib/katello/configuration/validator.rb b/lib/katello/configuration/validator.rb new file mode 100644 index 00000000000..806744ae256 --- /dev/null +++ b/lib/katello/configuration/validator.rb @@ -0,0 +1,79 @@ +# +# Copyright 2013 Red Hat, Inc. +# +# This software is licensed to you under the GNU General Public +# License as published by the Free Software Foundation; either version +# 2 of the License (GPLv2) or (at your option) any later version. +# There is NO WARRANTY for this software, express or implied, +# including the implied warranties of MERCHANTABILITY, +# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should +# have received a copy of GPLv2 along with this software; if not, see +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + +module Katello + module Configuration + + # defines small dsl for validating configuration + class Validator + attr_reader :config, :environment, :path + + # @param [Node] config + # @param [nil, Symbol] environment use nil for early or Symbol for environment + # @yield block with validations + def initialize(config, environment, path = [], &validations) + @config, @environment, @path = config, environment, path + instance_eval &validations + end + + private + + def early? + !environment + end + + # validate sub key + # @yield block with validations + def validate(key, &block) + Validator.new config[key] || Node.new, environment, (self.path + [key]), &block + end + + def are_booleans(*keys) + keys.each { |key| is_boolean key } + end + + def is_boolean(key) + has_values key, [true, false] + end + + def has_values(key, values, options = {}) + values << nil if options[:allow_nil] + return true if values.include?(config[key]) + raise ArgumentError, error_format(key, "should be one of #{values.inspect}, but was #{config[key].inspect}") + end + + def has_keys(*keys) + keys.each { |key| has_key key } + end + + def has_key(key) + unless config.has_key? key.to_sym + raise error_format(key.to_sym, 'is required') + end + end + + private + + def error_format(key, message) + key_path = (path + [key]).join('.') + env = environment ? "'#{environment}' environment" : 'early configuration' + "Key: '#{key_path}' in #{env} #{message}" + end + + def is_not_empty(key) + if config[key].nil? || config[key].empty? + raise error_format(key.to_sym, "must not be empty") + end + end + end + end +end diff --git a/lib/katello_config.rb b/lib/katello/load_configuration.rb similarity index 97% rename from lib/katello_config.rb rename to lib/katello/load_configuration.rb index 6f0a8eeba59..21666d79908 100644 --- a/lib/katello_config.rb +++ b/lib/katello/load_configuration.rb @@ -10,17 +10,17 @@ # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. -path = File.expand_path(File.dirname(__FILE__)) +path = File.expand_path(File.join(File.dirname(__FILE__), '..')) $LOAD_PATH << path unless $LOAD_PATH.include? path +require 'katello/configuration' require 'app_config' -require 'configuration' require 'util/password' module Katello # @return [Configuration::Loader] def self.configuration_loader - root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) @configuration_loader ||= Configuration::Loader.new( :config_file_paths => %W(#{root}/config/katello.yml /etc/katello/katello.yml), diff --git a/lib/katello_logging.rb b/lib/katello/logging.rb similarity index 100% rename from lib/katello_logging.rb rename to lib/katello/logging.rb diff --git a/script/rails b/script/rails index 908efb89296..e7e84a8982f 100755 --- a/script/rails +++ b/script/rails @@ -12,7 +12,7 @@ require 'yaml' # load Katello configuration path = File.expand_path('../../lib', __FILE__) $LOAD_PATH << path unless $LOAD_PATH.include? path -require 'katello_config' +require 'katello/load_configuration' # # this is to enable ssl and ssl cert-based client authentication diff --git a/spec/lib/logging_spec.rb b/spec/lib/logging_spec.rb index 27c90dcc544..3b1d3ef4333 100644 --- a/spec/lib/logging_spec.rb +++ b/spec/lib/logging_spec.rb @@ -14,7 +14,7 @@ describe Katello::Logging do let(:testing_config) do - Configuration::Node.new( + Katello::Configuration::Node.new( { :logging => { :colorize => false, :console_inline => false, :log_trace => false,