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 #38127 - Add hammer host bootc images sub-commamd #980

Merged
merged 1 commit into from
Jan 17, 2025
Merged
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
5 changes: 5 additions & 0 deletions lib/hammer_cli_katello/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'hammer_cli_katello/host_deb'
require 'hammer_cli_katello/host_package_group'
require 'hammer_cli_katello/host_traces'
require 'hammer_cli_katello/host_bootc'

module HammerCLIKatello
HammerCLIForeman::Host.subcommand "errata",
Expand All @@ -31,4 +32,8 @@ module HammerCLIKatello
HammerCLIForeman::Host.subcommand "traces",
HammerCLIKatello::HostTraces.desc,
HammerCLIKatello::HostTraces

HammerCLIForeman::Host.subcommand "bootc",
HammerCLIKatello::HostBootc.desc,
HammerCLIKatello::HostBootc
end
34 changes: 34 additions & 0 deletions lib/hammer_cli_katello/host_bootc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module HammerCLIKatello
class HostBootc < HammerCLIKatello::Command
resource :host_bootc_images
desc "Manage bootc images on your hosts"

class ImagesCommand < HammerCLIKatello::ListCommand
action :bootc_images
command_name "images"

output do
field :bootc_booted_image, _("Running image")
field :bootc_booted_digest, _("Running image digest")
field :host_count, _("Host count")
end

def send_request
self.class.parse_data(super)
end

def self.parse_data(data_collection)
data = data_collection.inject([]) do |list, item|
list + item["digests"].collect do |digest|
digest.merge(:bootc_booted_image => item["bootc_booted_image"])
end
end
HammerCLI::Output::RecordCollection.new(data, :meta => data_collection.meta)
end

build_options
end

autoload_subcommands
end
end
1 change: 1 addition & 0 deletions lib/hammer_cli_katello/host_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'hammer_cli_katello/host_package'
require 'hammer_cli_katello/host_package_group'
require 'hammer_cli_katello/host_traces'
require 'hammer_cli_katello/host_bootc'

module HammerCLIKatello
module HostExtensions
Expand Down
Loading