Skip to content

Commit

Permalink
Fixes #37232 - Added extra info for CV & repos
Browse files Browse the repository at this point in the history
  • Loading branch information
parthaa committed Mar 7, 2024
1 parent 19ea6f3 commit ab4c18b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/hammer_cli_katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'hammer_cli_katello/filter'
require 'hammer_cli_katello/content_view_version'
require 'hammer_cli_katello/content_view_component'

module HammerCLIKatello
class ContentView < HammerCLIKatello::Command
resource :content_views
Expand Down Expand Up @@ -100,9 +99,12 @@ class InfoCommand < HammerCLIKatello::InfoCommand
field :published, _("Published"), Fields::Date
end

collection :components, _("Components"), hide_blank: true, hide_empty: true do
collection :cv_components, _("Components"), hide_blank: true, hide_empty: true do
field :id, _("Id")
field :name, _("Name")
field :latest, _("Latest version"), Fields::Boolean
field :unpublished, _("Not yet published"), Fields::Boolean
field :always_latest, _("Always update to the latest"), Fields::Boolean
end

collection :activation_keys, _("Activation Keys"), hide_blank: true, hide_empty: true do
Expand All @@ -117,6 +119,18 @@ def extend_data(data)
end
end

if data["composite"]
data["cv_components"] = data["content_view_components"]&.map do |component|
cv_latest = component.dig("content_view", "latest_version")
{
"id" => component.dig("content_view_version", "id"),
"name" => component.dig("content_view_version", "name") || component.dig("content_view", "name"),
"always_latest" => component["latest"],
"latest" => cv_latest == component.dig("content_view_version", "version"),
"unpublished" => component["content_view_version"].nil?
}
end
end
data
end

Expand Down
15 changes: 15 additions & 0 deletions lib/hammer_cli_katello/repository.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'pry-byebug'
module HammerCLIKatello
class Repository < HammerCLIKatello::Command
resource :repositories
Expand Down Expand Up @@ -85,6 +86,11 @@ class InfoCommand < HammerCLIKatello::InfoCommand
Fields::Field, :hide_blank => true
field :ignorable_content, _("Ignorable Content Units"), Fields::List, :hide_blank => true

label _("Publish Settings") do
field :restrict_to_arch, _("Restrict to architecture")
field :restrict_to_os_versions, _("Restrict to OS Version")
end

label _("HTTP Proxy") do
from :http_proxy do
field :id, _("Id"), Fields::Field, :hide_blank => true
Expand Down Expand Up @@ -156,13 +162,22 @@ def extend_data(data)
data["gpg_key_name"] = data["gpg_key"]["name"]
end

setup_arch_and_os(data)
setup_sync_state(data)
setup_booleans(data)
setup_mirroring_policy(data)
setup_content_counts(data) if data["content_counts"]
data
end

def setup_arch_and_os(data)
arch = data["arch"]
data["restrict_to_arch"] = arch == 'noarch' ? _('No restriction') : arch
os_versions = data["os_versions"] || []
data["restrict_to_os_versions"] = _('No restriction')
data["restrict_to_os_versions"] = os_versions.join(", ") unless os_versions.empty?
end

def setup_booleans(data)
data["_redhat_repo"] = data.dig("product", "redhat") ? _("yes") : _("no")
data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
Expand Down

0 comments on commit ab4c18b

Please sign in to comment.