Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9224 - Not setting docker upstream name on clones #4978

Merged
merged 1 commit into from Feb 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions app/lib/katello/validators/repo_docker_upstream_validator.rb

This file was deleted.

13 changes: 10 additions & 3 deletions app/models/katello/repository.rb
Expand Up @@ -69,8 +69,7 @@ class Repository < Katello::Model
validates :product_id, :presence => true
validates :pulp_id, :presence => true, :uniqueness => true, :if => proc { |r| r.name.present? }
validates :checksum_type, :inclusion => {:in => CHECKSUM_TYPES, :allow_blank => true}
validates_with Validators::RepoDockerUpstreamValidator
validates :docker_upstream_name, :allow_nil => true, :if => :docker?, :format => {
validates :docker_upstream_name, :allow_blank => true, :if => :docker?, :format => {
:with => /^([a-z0-9\-_]{4,30}\/)?[a-z0-9\-_\.]{3,30}$/,
:message => (_("must be a valid docker name"))
}
Expand All @@ -87,6 +86,7 @@ class Repository < Katello::Model
:allow_blank => false,
:message => (_("must be one of the following: %s") % TYPES.join(', '))
}
validate :ensure_valid_docker_attributes, :if => :docker?

# TODO: remove this default scope
# rubocop:disable Rails/DefaultScope
Expand Down Expand Up @@ -358,7 +358,6 @@ def build_clone(options)
:content_id => self.content_id,
:content_view_version => to_version,
:content_type => self.content_type,
:docker_upstream_name => self.docker_upstream_name,
:unprotected => self.unprotected) do |clone|
clone.checksum_type = self.checksum_type
clone.pulp_id = clone.clone_id(to_env, content_view, version.try(:version))
Expand Down Expand Up @@ -491,5 +490,13 @@ def downcase_pulp_id
self.pulp_id = self.pulp_id.downcase
end
end

def ensure_valid_docker_attributes
if url.blank? != docker_upstream_name.blank?
field = url.blank? ? :url : :docker_upstream_name
errors.add(field, N_("cannot be blank. Either provide all or no sync information."))
errors.add(:base, N_("Repository URL or Upstream Name is empty. Both are required for syncing from the upstream."))
end
end
end
end
Expand Up @@ -2,6 +2,7 @@ class AddUpstreamNameToRepository < ActiveRecord::Migration
def up
add_column :katello_repositories, :docker_upstream_name, :string
Katello::Repository.docker_type.each do |repo|
next if repo.url.blank?
update %(
update #{Katello::Repository.table_name}
set docker_upstream_name=#{ActiveRecord::Base.sanitize(repo.name)}
Expand Down
Expand Up @@ -64,7 +64,7 @@ <h6 ng-show="repository.content_type === 'docker'" translate>
type="text"
tabindex="1"/>
<h6 translate>
Name of the upstream repository you want to sync. Example: 'busybox' or 'fedora/ssh;.
Name of the upstream repository you want to sync. Example: 'busybox' or 'fedora/ssh'.
</h6>

</div>
Expand Down