Sha256: 4ffb02f47f3fc3c29a982d8414a83452c82de4449f970749a7892504f09a4b29

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

#
# Copyright 2014 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.

# various user-configurable mappings defined in /etc/katello/mapping.yml

require 'yaml'

module Katello
  module Mapping
    def self.configuration
      return @config if @config
      mapping_file = '/etc/katello/mapping.yml'
      if File.readable?(mapping_file)
        @config = YAML.load_file(mapping_file)
      else
        @config = {}
      end
    end

    class ImageFactoryNaming
      def self.translate(name = '', version = '')
        matched_name = "#{name} #{version}"
        naming = Mapping.configuration['imagefactory_naming'] || {}
        naming.each do |key, values|
          regexp_str = "^#{Regexp.escape(key).gsub('\*', '.*')}$"
          if Regexp.new(regexp_str) =~ matched_name
            return values.map(&:to_s)
          end
        end
        return [name.to_s, version.to_s]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/lib/katello/mapping.rb