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 #38071 - Add content_type field to container manifests #11250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/models/katello/docker_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions app/models/katello/docker_manifest_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions app/services/katello/pulp3/docker_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/services/katello/pulp3/docker_manifest_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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
Expand Down
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
Expand Down
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
Loading