From a401a5ae40633a4864b70876f75b637d4eb27e2d Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Fri, 6 Dec 2024 21:10:46 +0000 Subject: [PATCH] Fixes #38071 - Add content_type field to container manifests --- app/models/katello/docker_manifest.rb | 3 +++ app/models/katello/docker_manifest_list.rb | 3 +++ app/services/katello/pulp3/docker_manifest.rb | 5 +++-- app/services/katello/pulp3/docker_manifest_list.rb | 5 +++-- .../katello/api/v2/docker_manifest_lists/show.json.rabl | 2 +- app/views/katello/api/v2/docker_manifests/show.json.rabl | 2 +- ..._add_content_type_to_container_manifests_and_lists.rb | 9 +++++++++ 7 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20241206183052_add_content_type_to_container_manifests_and_lists.rb diff --git a/app/models/katello/docker_manifest.rb b/app/models/katello/docker_manifest.rb index f3c30600518..c75e201072c 100644 --- a/app/models/katello/docker_manifest.rb +++ b/app/models/katello/docker_manifest.rb @@ -11,12 +11,15 @@ class DockerManifest < Katello::Model CONTENT_TYPE = "docker_manifest".freeze scope :bootable, -> { where(:is_bootable => true) } + scope :flatpak, -> { where(:is_flatpak => true) } scoped_search :relation => :docker_tags, :on => :name, :rename => :tag, :complete_value => true scoped_search :on => :digest, :rename => :digest, :complete_value => true, :only_explicit => true scoped_search :on => :schema_version, :rename => :schema_version, :complete_value => true, :only_explicit => true scoped_search :relation => :docker_manifest_lists, :on => :digest, :rename => :manifest_list_digest, :complete_value => true, :only_explicit => true scoped_search :on => :is_bootable, :rename => :bootable, :complete_value => true, :only_explicit => true + scoped_search :on => :is_flatpak, :rename => :flatpak, :complete_value => true, :only_explicit => true + scoped_search :on => :content_type, :complete_value => true, :only_explicit => true def self.default_sort order(:schema_version) diff --git a/app/models/katello/docker_manifest_list.rb b/app/models/katello/docker_manifest_list.rb index 8bf10635431..a415fa6dcc0 100644 --- a/app/models/katello/docker_manifest_list.rb +++ b/app/models/katello/docker_manifest_list.rb @@ -12,11 +12,14 @@ class DockerManifestList < Katello::Model CONTENT_TYPE = "docker_manifest_list".freeze scope :bootable, -> { where(:is_bootable => true) } + scope :flatpak, -> { where(:is_flatpak => true) } scoped_search :relation => :docker_tags, :on => :name, :rename => :tag, :complete_value => true scoped_search :on => :digest, :rename => :digest, :complete_value => true, :only_explicit => true scoped_search :on => :schema_version, :rename => :schema_version, :complete_value => true, :only_explicit => true scoped_search :on => :is_bootable, :rename => :bootable, :complete_value => true, :only_explicit => true + scoped_search :on => :is_flatpak, :rename => :flatpak, :complete_value => true, :only_explicit => true + scoped_search :on => :content_type, :complete_value => true, :only_explicit => true def self.default_sort order(:schema_version) diff --git a/app/services/katello/pulp3/docker_manifest.rb b/app/services/katello/pulp3/docker_manifest.rb index 32c2a4d1c2e..dbbfea8d8b9 100644 --- a/app/services/katello/pulp3/docker_manifest.rb +++ b/app/services/katello/pulp3/docker_manifest.rb @@ -29,8 +29,9 @@ def self.generate_model_row(unit) pulp_id: unit[unit_identifier], annotations: unit['annotations'], labels: unit['labels'], - is_bootable: unit['is_bootable'], - is_flatpak: unit['is_flatpak'], + is_bootable: unit['is_bootable'] || unit['type'] == 'bootable', + is_flatpak: unit['is_flatpak'] || unit['type'] == 'flatpak', + content_type: unit['type'], } end end diff --git a/app/services/katello/pulp3/docker_manifest_list.rb b/app/services/katello/pulp3/docker_manifest_list.rb index 372403ecfd7..5b850d85223 100644 --- a/app/services/katello/pulp3/docker_manifest_list.rb +++ b/app/services/katello/pulp3/docker_manifest_list.rb @@ -31,8 +31,9 @@ def self.generate_model_row(unit) pulp_id: unit[unit_identifier], annotations: unit['annotations'], labels: unit['labels'], - is_bootable: unit['is_bootable'], - is_flatpak: unit['is_flatpak'], + is_bootable: unit['is_bootable'] || unit['type'] == 'bootable', + is_flatpak: unit['is_flatpak'] || unit['type'] == 'flatpak', + content_type: unit['type'], } end diff --git a/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl b/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl index eceab5b548a..7d94e3a4497 100644 --- a/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl +++ b/app/views/katello/api/v2/docker_manifest_lists/show.json.rabl @@ -1,6 +1,6 @@ object @resource -attributes :id, :schema_version, :digest, :manifest_type +attributes :id, :schema_version, :digest, :manifest_type, :content_type attributes :annotations, :labels, :is_bootable, :is_flatpak child :docker_tags => :tags do diff --git a/app/views/katello/api/v2/docker_manifests/show.json.rabl b/app/views/katello/api/v2/docker_manifests/show.json.rabl index f8468e1335d..f2c05c13097 100644 --- a/app/views/katello/api/v2/docker_manifests/show.json.rabl +++ b/app/views/katello/api/v2/docker_manifests/show.json.rabl @@ -1,6 +1,6 @@ object @resource -attributes :id, :schema_version, :digest, :manifest_type +attributes :id, :schema_version, :digest, :manifest_type, :content_type attributes :annotations, :labels, :is_bootable, :is_flatpak child :docker_tags => :tags do diff --git a/db/migrate/20241206183052_add_content_type_to_container_manifests_and_lists.rb b/db/migrate/20241206183052_add_content_type_to_container_manifests_and_lists.rb new file mode 100644 index 00000000000..05bfa794088 --- /dev/null +++ b/db/migrate/20241206183052_add_content_type_to_container_manifests_and_lists.rb @@ -0,0 +1,9 @@ +class AddContentTypeToContainerManifestsAndLists < ActiveRecord::Migration[6.1] + def change + add_column :katello_docker_manifests, :content_type, :string, :limit => 255 + add_column :katello_docker_manifest_lists, :content_type, :string, :limit => 255 + + add_index :katello_docker_manifests, :content_type + add_index :katello_docker_manifest_lists, :content_type + end +end