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