Sha256: 501e604dc2d30002439f4205b8b3073223de68a5ab2a2b02506f770f538e4176

Contents?: true

Size: 1.65 KB

Versions: 70

Compression:

Stored size: 1.65 KB

Contents

module Katello
  module Validators
    class ContentViewPuppetModuleValidator < ActiveModel::Validator
      def validate(record)
        if record.uuid.blank? && (record.name.blank? || record.author.blank?)
          record.errors[:base] << _("Invalid puppet module parameters specified. \
                                    Either 'uuid' or 'name' and 'author' must be specified.")
        elsif record.name && record.author &&
          !PuppetModule.exists?(name: record.name, author: record.author)
          record.errors[:base] << _("Puppet Module with name='%{name}' and author='%{author}' does\
                                    not exist") % { name: record.name, author: record.author }
        elsif record.uuid && !PuppetModule.exists?(pulp_id: record.uuid)
          record.errors[:base] << _("Puppet Module with uuid='%{uuid}' does not\
                                    exist") % { uuid: record.uuid }
        else
          puppet_modules = if record.uuid.blank?
                             PuppetModule.where(name: record.name, author: record.author)
                           else
                             PuppetModule.where(pulp_id: record.uuid)
                           end
          repositories = puppet_modules.flat_map(&:repositories)

          if repositories.present? && record.content_view.present? &&
              !repositories.map(&:organization).include?(record.content_view.organization)
            record.errors[:base] << _("Puppet Module does not belong to content view organization\
                                      '%{name}'" % { name: record.content_view.organization.name })
          end
        end
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
katello-3.18.5 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.4 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.3.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.3 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.2.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.2 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.3 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.1.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.2 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.0 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.16.2 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.0.rc2.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.0.rc2 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.0 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.18.0.rc1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.0.rc2.2 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.17.0.rc2.1 app/lib/katello/validators/content_view_puppet_module_validator.rb
katello-3.16.1.2 app/lib/katello/validators/content_view_puppet_module_validator.rb