Skip to content

Commit

Permalink
Merge pull request #3968 from DavidKang/allow-on-package-group
Browse files Browse the repository at this point in the history
[webui][ci] Only allow different package groups
  • Loading branch information
bgeuken committed Oct 9, 2017
2 parents 156c972 + 58d6f8e commit 71a953b
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 39 deletions.
12 changes: 2 additions & 10 deletions src/api/app/models/kiwi/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Kiwi::Image < ApplicationRecord
validates :name, presence: true
validate :check_use_project_repositories
validate :check_package_groups
validate :check_package_group_type_image
accepts_nested_attributes_for :repositories, allow_destroy: true
accepts_nested_attributes_for :package_groups, allow_destroy: true
accepts_nested_attributes_for :kiwi_packages, allow_destroy: true
Expand Down Expand Up @@ -173,17 +172,10 @@ def check_use_project_repositories
"A repository with source_path=\"obsrepositories:/\" has been set. If you want to use it, please remove the other repositories.")
end

def check_package_group_type_image
return if package_groups.select(&:kiwi_type_image?).size <= 2

errors.add(:base, "Having more than 2 package groups with type='image' is not allowed.")
end

def check_package_groups
return if package_groups.group_by { |package_group| [package_group.kiwi_type, package_group.pattern_type] }
.select { |_key, value| value.count > 1 }.keys.empty?
return if package_groups.group_by(&:kiwi_type).select { |_key, value| value.count > 1 }.keys.empty?

errors.add(:base, "Multiple package groups with same attributes is not allowed.")
errors.add(:base, "Multiple package groups with same type are not allowed.")
end
end

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 71a953b

Please sign in to comment.