Skip to content

Commit

Permalink
fix: subscription-manager list --installed call failure
Browse files Browse the repository at this point in the history
The `subscription-manager list --installed` was failing with RC 1, after
printing stdout it visible that it reported that it was called
incorrectly and thus printed help text.

Issue was caused by the way how parameters were passed, now each is
passed separately as the exec.Command expects it.

https://issues.redhat.com/browse/HMS-3279

Signed-off-by: Petr Vobornik <[email protected]>
  • Loading branch information
pvoborni committed Dec 18, 2023
1 parent a841853 commit 38c79ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions hostinfo/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func GetSocketCount(facts SubManValues) (string, error) {
}

func GetProduct(facts SubManValues) ([]string, error) {
output, _ := execSubManCommand("list --installed")
output, _ := execSubManCommand("list", "--installed")
values := parseSubManOutputMultiVal(output)
return values.get("Product ID")
}
Expand Down Expand Up @@ -109,8 +109,8 @@ func GetBillingInfo(facts SubManValues) (BillingInfo, error) {
return BillingInfo{}, err
}

func execSubManCommand(command string) (string, error) {
cmd := exec.Command("subscription-manager", command)
func execSubManCommand(command ...string) (string, error) {
cmd := exec.Command("subscription-manager", command...)
logger.Debugf("Executing `subscription-manager %s`...\n", command)

var stdout, stderr bytes.Buffer
Expand Down
10 changes: 6 additions & 4 deletions mocks/subscription-manager
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,12 @@ hard_coded() {
show_facts
;;
list)
show_list_installed
;;
"list --installed")
show_list_installed
if [ "${2}" == "--installed" ]; then
show_list_installed
else
echo "Unsupported command: ${command}" >&2
exit 1
fi
;;
*)
echo "Unsupported command: ${command}" >&2
Expand Down

0 comments on commit 38c79ec

Please sign in to comment.