Skip to content

Commit

Permalink
Fixes #37988 - migrate container repo naming to use slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Nov 22, 2024
1 parent 7150ba2 commit 9c98533
Show file tree
Hide file tree
Showing 23 changed files with 8,004 additions and 9,782 deletions.
12 changes: 6 additions & 6 deletions app/models/katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ def generate_docker_repo_path
view = self.content_view.label
product = self.product.label
env = cve.label.split('/').first
"#{org}-#{env.downcase}-#{view}-#{product}-#{self.root.label}"
"#{org}/#{env.downcase}/#{view}/#{product}/#{self.root.label}"
else
"#{org}-#{self.content_view.label}-#{self.content_view_version.version}-#{self.root.product.label}-#{self.root.label}"
"#{org}/#{self.content_view.label}/#{self.content_view_version.version}/#{self.root.product.label}/#{self.root.label}"
end
end

Expand Down Expand Up @@ -936,9 +936,9 @@ def self.safe_render_container_name(repository, pattern = nil)
# the container provided. Branches numbered as ordered below.
#
# 1 - Render promotion pattern (or env pattern if no promo pattern)
# 2 - <org label>-<product label>-<repo label>
# 3 - <org label>-<env label>-<cv label>-<product label>-<repo label>
# 4 - <org label>-<cv label>-<cvv label>-<product label>-<repo label>
# 2 - <org label>/<product label>/<repo label>
# 3 - <org label>/<env label>/<cv label>/<product label>/<repo label>
# 4 - <org label>/<cv label>/<cvv label>/<product label>/<repo label>
is_pattern_provided = pattern.present?
env_exists = repository.environment.present?
is_env_pattern_provided = env_exists && repository.environment.registry_name_pattern.present?
Expand Down Expand Up @@ -967,7 +967,7 @@ def self.safe_render_container_name(repository, pattern = nil)
else
items = [repository.organization.label, repository.content_view.label, repository.content_view_version.version, repository.product.label, repository.label]
end
Repository.clean_container_name(items.compact.join("-"))
Repository.clean_container_name(items.compact.join("/"))
end

def self.clean_container_name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h4 translate>Container Image Registry</h4>
</div>
<div bst-alert='info'>
<span translate>
The <i>Registry Name Pattern</i> overrides the default name by which container images may be pulled from the server. (By default this name is a combination of Organization, Lifecycle Environment, Content View, Product, and Repository labels.)
The <i>Registry Name Pattern</i> overrides the default name by which container images may be pulled from the server. (By default this name is a combination of Organization, Lifecycle Environment, Content View, Product, and Repository labels delimited by forward slashes "/".)

<br/><br/>The name may be constructed using ERB syntax. Variables available for use are:

Expand Down
1 change: 1 addition & 0 deletions test/actions/pulp3/orchestration/docker_delete_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def setup
@repo = katello_repositories(:busybox)
ensure_creatable(@repo, @primary)
create_repo(@repo, @primary)
@repo.root.update(include_tags: ['latest'])
ForemanTasks.sync_task(
::Actions::Katello::Repository::MetadataGenerate, @repo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def setup_permissions
body = JSON.parse(response.body)
assert_equal(body['repositories'].compact.sort,
["busybox",
"empty_organization-dev_label-published_dev_view-puppet_product-busybox",
"#{org.label.downcase}-puppet_product-busybox"])
"empty_organization/dev_label/published_dev_view/puppet_product/busybox",
"#{org.label.downcase}-puppet_product-busybox"].sort)
end

it "shows only available images for unauthenticated requests" do
Expand Down Expand Up @@ -315,8 +315,8 @@ def setup_permissions
assert_equal(body,
"num_results" => 2,
"query" => "abc",
"results" => [{ "name" => "#{org.label.downcase}-puppet_product-busybox", "description" => nil },
{ "name" => "#{org.label.downcase}-published_library_view-1_0-puppet_product-busybox", "description" => nil }]
"results" => [{ "name" => "#{org.label.downcase}/puppet_product/busybox", "description" => nil },
{ "name" => "#{org.label.downcase}/published_library_view/1_0/puppet_product/busybox", "description" => nil }]
)
end

Expand All @@ -342,7 +342,7 @@ def setup_permissions
assert_response 200
body = JSON.parse(response.body)
assert_equal 1, body["results"].length
assert_equal "#{repo.organization.label.downcase}-dev_label-published_dev_view-puppet_product-busybox", body["results"][0]["name"]
assert_equal "#{repo.organization.label.downcase}/dev_label/published_dev_view/puppet_product/busybox", body["results"][0]["name"]
end

it "show unauthenticated repositories for head requests" do
Expand Down
Loading

0 comments on commit 9c98533

Please sign in to comment.