diff --git a/hostinfo/subscription.go b/hostinfo/subscription.go index 8a132e8..f20096c 100644 --- a/hostinfo/subscription.go +++ b/hostinfo/subscription.go @@ -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") } @@ -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 diff --git a/mocks/subscription-manager b/mocks/subscription-manager index 4046f82..a7f78e5 100755 --- a/mocks/subscription-manager +++ b/mocks/subscription-manager @@ -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