Sha256: be056f92e939042906f51c80e48c305173eca6fba97b80668da6205fd65568ab

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

# rubocop:disable AccessModifierIndentation
#
# 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.

module Katello
  module Services
    module PuppetClassImporterExtensions
      extend ActiveSupport::Concern

      included do
        def update_environment
          change_types = %w(new obsolete updated)
          changed  = self.changes

          change_types.each do |kind|
            changed[kind].slice!(@environment) unless changed[kind].empty?
          end

          #prevent the puppet environment from being deleted, by removing special '_destroy_' String
          if changed['obsolete'][@environment]
            changed['obsolete'][@environment] =
              changed['obsolete'][@environment].select { |klass| klass != '_destroy_' }
          end

          # PuppetClassImporter expects [kind][env] to be in json format
          change_types.each do |kind|
            unless (envs = changed[kind]).empty?
              envs.keys.sort.each do |env|
                changed[kind][env] = changed[kind][env].to_json
              end
            end
          end

          self.obsolete_and_new(changed)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/services/katello/puppet_class_importer_extensions.rb