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

rhsm_repository: refactor handling of subscription-manager #6783

Conversation

ptoscano
Copy link
Contributor

SUMMARY

Create a small helper class Rhsm, so all the logic related to the interaction with subscription-manager is grouped there:

  • create the Rhsm object in main(), once the initial checks are done
  • search subscription-manager as required (so there is no need to manually check it), and store its path for reuse
  • store the common arguments for running subscription-manager
  • move run_subscription_manager() to Rhsm as run_repos()
  • get rid of the different list parameters: we list only all the repositories, so the other cases are not needed (and can be added easily, if needed)
  • move get_repository_list() to Rhsm as list_repositories()

The execution of subscription-manager is improved as well:

  • pass the arguments to run_command() directly as list, rather than joining the arguments to string, which run_command() will need to split again
  • move the repos parameter directly in run_repos()
  • explicitly disable the shell, already off by default
  • disable the expansions of variables, as there are none

Adapt the unit test to the different way run_command() is called.

There should be no behaviour changes.

ISSUE TYPE
  • Refactoring Pull Request
COMPONENT NAME

rhsm_repository

@ansibullbot

This comment was marked as outdated.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR plugins plugin (any type) tests tests unit tests/unit labels Jun 24, 2023
Create a small helper class Rhsm, so all the logic related to the
interaction with subscription-manager is grouped there:
- create the Rhsm object in main(), once the initial checks are done
- search subscription-manager as required (so there is no need to
  manually check it), and store its path for reuse
- store the common arguments for running subscription-manager
- move run_subscription_manager() to Rhsm as run_repos()
- get rid of the different list parameters: we list only all the
  repositories, so the other cases are not needed (and can be added
  easily, if needed)
- move get_repository_list() to Rhsm as list_repositories()

The execution of subscription-manager is improved as well:
- pass the arguments to run_command() directly as list, rather than
  joining the arguments to string, which run_command() will need to
  split again
- move the "repos" parameter directly in run_repos()
- explicitly disable the shell, already off by default
- disable the expansions of variables, as there are none

Adapt the unit test to the different way run_command() is called.

There should be no behaviour changes.
@ptoscano ptoscano force-pushed the rhsm_repository-refactor-subman branch from bb97463 to 93a2955 Compare June 25, 2023 08:10
@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Jun 25, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 labels Jun 25, 2023
@felixfontein felixfontein merged commit 867704d into ansible-collections:main Jul 2, 2023
@patchback
Copy link

patchback bot commented Jul 2, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/867704dd75415d46b2d9cb6576d5e4cf7d5f18d9/pr-6783

Backported as #6830

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jul 2, 2023
patchback bot pushed a commit that referenced this pull request Jul 2, 2023
Create a small helper class Rhsm, so all the logic related to the
interaction with subscription-manager is grouped there:
- create the Rhsm object in main(), once the initial checks are done
- search subscription-manager as required (so there is no need to
  manually check it), and store its path for reuse
- store the common arguments for running subscription-manager
- move run_subscription_manager() to Rhsm as run_repos()
- get rid of the different list parameters: we list only all the
  repositories, so the other cases are not needed (and can be added
  easily, if needed)
- move get_repository_list() to Rhsm as list_repositories()

The execution of subscription-manager is improved as well:
- pass the arguments to run_command() directly as list, rather than
  joining the arguments to string, which run_command() will need to
  split again
- move the "repos" parameter directly in run_repos()
- explicitly disable the shell, already off by default
- disable the expansions of variables, as there are none

Adapt the unit test to the different way run_command() is called.

There should be no behaviour changes.

(cherry picked from commit 867704d)
@felixfontein
Copy link
Collaborator

Thanks for improving the module!

felixfontein pushed a commit that referenced this pull request Jul 2, 2023
…ling of subscription-manager (#6830)

rhsm_repository: refactor handling of subscription-manager (#6783)

Create a small helper class Rhsm, so all the logic related to the
interaction with subscription-manager is grouped there:
- create the Rhsm object in main(), once the initial checks are done
- search subscription-manager as required (so there is no need to
  manually check it), and store its path for reuse
- store the common arguments for running subscription-manager
- move run_subscription_manager() to Rhsm as run_repos()
- get rid of the different list parameters: we list only all the
  repositories, so the other cases are not needed (and can be added
  easily, if needed)
- move get_repository_list() to Rhsm as list_repositories()

The execution of subscription-manager is improved as well:
- pass the arguments to run_command() directly as list, rather than
  joining the arguments to string, which run_command() will need to
  split again
- move the "repos" parameter directly in run_repos()
- explicitly disable the shell, already off by default
- disable the expansions of variables, as there are none

Adapt the unit test to the different way run_command() is called.

There should be no behaviour changes.

(cherry picked from commit 867704d)

Co-authored-by: Pino Toscano <ptoscano@redhat.com>
@ptoscano ptoscano deleted the rhsm_repository-refactor-subman branch July 3, 2023 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module module plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants