Skip to content

Commit

Permalink
Fixes #38071 - Add content_type field to container manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Dec 6, 2024
1 parent 7ba19bd commit a401a5a
Showing 7 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/models/katello/docker_manifest.rb
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions app/models/katello/docker_manifest_list.rb
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 3 additions & 2 deletions app/services/katello/pulp3/docker_manifest.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions app/services/katello/pulp3/docker_manifest_list.rb
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/views/katello/api/v2/docker_manifests/show.json.rabl
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a401a5a

Please sign in to comment.