Skip to content

Commit

Permalink
Fixes #37975 - Add bootc fields to host info and list
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Nov 5, 2024
1 parent d2c7a35 commit 4c2918c
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 264

Metrics/ModuleLength:
Max: 120

# Offense count: 5
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Expand Down
21 changes: 21 additions & 0 deletions lib/hammer_cli_katello/host_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ module HostExtensions
field :bugfix, _("Bugfix"), nil, :sets => ['ALL']
field :enhancement, _("Enhancement"), nil, :sets => ['ALL']
end
field :bootc_booted_image, _('Running image'), nil, :sets => ['ALL']
field :bootc_booted_digest, _('Running image digest'), nil, :sets => ['ALL']
field :bootc_staged_image, _('Staged image'), nil, :sets => ['ALL']
field :bootc_staged_digest, _('Staged image digest'), nil, :sets => ['ALL']
field :bootc_available_image, _('Available image'), nil, :sets => ['ALL']
field :bootc_available_digest, _('Available image digest'), nil, :sets => ['ALL']
field :bootc_rollback_image, _('Rollback image'), nil, :sets => ['ALL']
field :bootc_rollback_digest, _('Rollback image digest'), nil, :sets => ['ALL']
end
field :traces_status_label, _('Trace Status')
end
Expand Down Expand Up @@ -106,6 +114,19 @@ module HostExtensions
end
end

label _('bootc Image Information') do
from :content_facet_attributes do
field :bootc_booted_image, _('Running image')
field :bootc_booted_digest, _('Running image digest')
field :bootc_staged_image, _('Staged image')
field :bootc_staged_digest, _('Staged image digest')
field :bootc_available_image, _('Available image')
field :bootc_available_digest, _('Available image digest')
field :bootc_rollback_image, _('Rollback image')
field :bootc_rollback_digest, _('Rollback image digest')
end
end

field :traces_status_label, _('Trace Status')

collection :host_collections, _('Host Collections') do
Expand Down
1 change: 0 additions & 1 deletion test/functional/content_view/component/update_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require_relative '../../test_helper'
require 'hammer_cli_katello/content_view_component'
# rubocop:disable Metrics/ModuleLength
module HammerCLIKatello
describe ContentViewComponent::UpdateCommand do
before do
Expand Down
10 changes: 9 additions & 1 deletion test/functional/host/extensions/data/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@
"lifecycle_environment_library?":true,
"katello_agent_installed":true,
"applicable_package_count": 5,
"upgradable_package_count": 4
"upgradable_package_count": 4,
"bootc_booted_image":"potato",
"bootc_booted_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9ae",
"bootc_available_image":"potato2",
"bootc_available_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a2",
"bootc_staged_image":"potato3",
"bootc_staged_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a1",
"bootc_rollback_image":"potato4",
"bootc_rollback_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a9"
},
"traces_status_label":"Updated",
"subscription_facet_attributes":{
Expand Down
12 changes: 10 additions & 2 deletions test/functional/host/extensions/data/host_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@
"bugfix":0,
"enhancement":0,
"total":0
}
},
"bootc_booted_image":"potato",
"bootc_booted_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9ae",
"bootc_available_image":"potato2",
"bootc_available_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a2",
"bootc_staged_image":"potato3",
"bootc_staged_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a1",
"bootc_rollback_image":"potato4",
"bootc_rollback_digest":"sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9a9"
},
"subscription_facet_attributes":{
"id":2,
Expand All @@ -135,4 +143,4 @@
"content_host_id":2
}
]
}
}
5 changes: 4 additions & 1 deletion test/functional/host/extensions/info_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
['Purpose Usage', 'Production'],
['Purpose Role', 'Role'],
['Purpose Addons', 'Test Addon1, Test Addon2'],
['Trace Status', 'Updated']]
['Trace Status', 'Updated'],
['Running image', 'potato'],
['Running image digest',
'sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9ae']]
expected_results = expected_fields.map { |field| success_result(FieldMatcher.new(*field)) }
expected_results.each { |expected| assert_cmd(expected, result) }
end
Expand Down
14 changes: 14 additions & 0 deletions test/functional/host/extensions/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,18 @@
expected_result = success_result(IndexMatcher.new([fields, values]))
assert_cmd(expected_result, result)
end

it "list hosts bootc" do
ex = api_expects(:hosts, :index, 'Host index')

json_file = File.join(File.dirname(__FILE__), 'data', 'host_list.json')
ex.returns(JSON.parse(File.read(json_file)))

result = run_cmd(['host', 'list', "--fields=\"Running image\",\"Running image digest\""])

fields = ['RUNNING IMAGE', 'RUNNING IMAGE DIGEST']
values = ['sha256:a68293b8402890ba802f11fc2fab26e23c665be9e645836c3f32cbfe9e07f9ae']
expected_result = success_result(IndexMatcher.new([fields, values]))
assert_cmd(expected_result, result)
end
end
1 change: 0 additions & 1 deletion test/functional/package/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require_relative '../lifecycle_environment/lifecycle_environment_helpers'
require 'hammer_cli_katello/package'

# rubocop:disable ModuleLength
module HammerCLIKatello
describe PackageCommand::ListCommand do
include OrganizationHelpers
Expand Down
2 changes: 1 addition & 1 deletion test/functional/repository/update_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_relative '../organization/organization_helpers'
require 'hammer_cli_katello/repository'

module HammerCLIKatello # rubocop:disable Metrics/ModuleLength
module HammerCLIKatello
describe Repository::UpdateCommand do
include OrganizationHelpers

Expand Down

0 comments on commit 4c2918c

Please sign in to comment.