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

opkg: refactor module to use StateModuleHelper and CmdRunner #5718

Merged
merged 17 commits into from
Jan 12, 2023

Conversation

russoz
Copy link
Collaborator

@russoz russoz commented Dec 21, 2022

SUMMARY

Refactor the module to use StateModuleHelper and CmdRunner. As a side effect, running opkg is now passing parameters in a safer way.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

plugins/modules/opkg.py

@ansibullbot
Copy link
Collaborator

cc @skinp
click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module os packaging plugins plugin (any type) feature This issue/PR relates to a feature request labels Dec 21, 2022
@felixfontein
Copy link
Collaborator

CC @joergho who contributed to this module recently.

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Dec 22, 2022
@felixfontein
Copy link
Collaborator

This conflicts with #5688, which is going to be merged before this. Also note that this module has no tests, so this needs to be verified with manual testing whether it works.

@russoz
Copy link
Collaborator Author

russoz commented Dec 22, 2022

I am happy to adjust this one after the other PR gets merged.

And I could get unit tests done, in the meantime. Though they will not support the "old way" of calling run_command with a single string for cmd line.

Copy link
Contributor

@joergho joergho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes included, the opkg module behaves as before (I ran some tests).
However, in the old implementation there was the output installed/removed %d package(s) which is now missing. Assigning self.vars.msg is not possible. Is there another way to do this? Alternatively, I set the install_c and remove_c variables as output, so the the information how many packages got installed / removed is still available as output.

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 22, 2022
@russoz
Copy link
Collaborator Author

russoz commented Dec 22, 2022

With the changes included, the opkg module behaves as before (I ran some tests). However, in the old implementation there was the output installed/removed %d package(s) which is now missing. Assigning self.vars.msg is not possible. Is there another way to do this? Alternatively, I set the install_c and remove_c variables as output, so the the information how many packages got installed / removed is still available as output.

@joergho thanks for the thorough check (and catching the typo). We can set the msg output same as before. And I will respond other to other reviews on a case by case.

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 22, 2022
@felixfontein
Copy link
Collaborator

I merged #5688, this one now has conflicts.

@ansibullbot ansibullbot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI labels Dec 22, 2022
@russoz
Copy link
Collaborator Author

russoz commented Dec 22, 2022

I will still create unit tests for this, kinda cookiecutting from previous tests using CmdRunner

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 22, 2022
@russoz
Copy link
Collaborator Author

russoz commented Jan 9, 2023

Rebasing the PR

@russoz
Copy link
Collaborator Author

russoz commented Jan 9, 2023

before this PR:

TASK [install] ******************
changed: [agent] => {"changed": true, "msg": "installed 1 package(s)"}

after this PR:

TASK [install] ******************
changed: [agent] => {"_msg": "installed 1 package(s)", "changed": true}

If you update to the latest version of c.g. from the main branch, the result will always be in msg.

@russoz
Copy link
Collaborator Author

russoz commented Jan 10, 2023

@felixfontein I think everybody is happy with this one now

@felixfontein felixfontein merged commit 682bb4b into ansible-collections:main Jan 12, 2023
@patchback
Copy link

patchback bot commented Jan 12, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/682bb4b88a00b880756a891f9280083164dc8fb2/pr-5718

Backported as #5824

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

patchback bot pushed a commit that referenced this pull request Jan 12, 2023
* opkg: refactor module to use StateModuleHelper and CmdRunner

* add changelog fragment

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* generate message outcome as before

* aggregated changes from 5688

* fix package query

* add unit tests

* fix sanity error

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* add test for specifying version

* refactor parameter name

Co-authored-by: joergho <[email protected]>
(cherry picked from commit 682bb4b)
@felixfontein
Copy link
Collaborator

@russoz thanks for doing this!
@joergho thanks for testing and reviewing!

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jan 12, 2023
felixfontein pushed a commit that referenced this pull request Jan 12, 2023
…tateModuleHelper and CmdRunner (#5824)

opkg: refactor module to use StateModuleHelper and CmdRunner (#5718)

* opkg: refactor module to use StateModuleHelper and CmdRunner

* add changelog fragment

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* generate message outcome as before

* aggregated changes from 5688

* fix package query

* add unit tests

* fix sanity error

* Update plugins/modules/opkg.py

Co-authored-by: joergho <[email protected]>

* add test for specifying version

* refactor parameter name

Co-authored-by: joergho <[email protected]>
(cherry picked from commit 682bb4b)

Co-authored-by: Alexei Znamensky <[email protected]>
@russoz russoz deleted the opkg-refactor branch January 12, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug feature This issue/PR relates to a feature request module module new_plugin New plugin os packaging plugins plugin (any type) tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants