8000 Make rotate_artifacts accessible from env/settings by fkuep · Pull Request #1417 · ansible/ansible-runner · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make rotate_artifacts accessible from env/settings #1417

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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

fkuep
Copy link
@fkuep fkuep commented Feb 21, 2025

Related to #1415

Make rotate_artifacts accessible from the settings file.

  • Modify src/ansible_runner/config/_base.py:

    • Retrieve rotate_artifacts from settings dictionary in prepare_env method.
    • Set rotate_artifacts in __init__ method only if not provided in settings dictionary.
    • Ensure rotate_artifacts is set to 0 if not provided in command line or settings file.
    • Make rotate_artifacts default to 0 in __init__ method.
    • Set rotate_artifacts from command line if provided.
  • Modify demo/env/settings:

    • Add rotate_artifacts option to the settings file.

For more details, open the Copilot Workspace session.

Related to ansible#1415

Make `rotate_artifacts` accessible from the settings file.

* Modify `src/ansible_runner/config/_base.py`:
  - Retrieve `rotate_artifacts` from `settings` dictionary in `prepare_env` method.
  - Set `rotate_artifacts` in `__init__` method only if not provided in `settings` dictionary.
  - Ensure `rotate_artifacts` is set to 0 if not provided in command line or settings file.
  - Make `rotate_artifacts` default to 0 in `__init__` method.
  - Set `rotate_artifacts` from command line if provided.

* Modify `demo/env/settings`:
  - Add `rotate_artifacts` option to the settings file.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ansible/ansible-runner/issues/1415?shareId=XXXX-XXXX-XXXX-XXXX).
@fkuep fkuep requested a review from a team as a code owner February 21, 2025 16:04
@fkuep
Copy link
Author
fkuep commented Feb 21, 2025

This one seems to work, only I wonder if the settings file should really win over the command line argument.

Copy link
Contributor
@Shrews Shrews left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I think you're on the right track. I think all you really need is your change on line 230 of _base.py. The other changes seem unnecessary, unless there is something I'm not seeing?

As for the settings file contents winning over the command line, I probably would have reversed that if I had had a say at the time the project was created, but it is what it is, so let's just be consistent with the other settings values.

You'll also need to update the documentation in intro.rst for the env/settings section.

Also, you'll want to add some tests to validate this works as expected (we won't accept it without tests). You might need to be a bit creative here. When my group took over this code base, we worked to improve the existing set of tests, but we are lacking in certain areas still, and I'm not sure if we currently have a good example for you to use for a new test. I took a very quick look through the existing tests and didn't see any good candidates. See what you can come up with. If you have problems, I can try to assist you, but may be delayed in getting around to it.

@@ -81,7 +81,7 @@ def __init__(self,
container_workdir: str | None = None,
container_auth_data=None,
ident: str | None = None,
rotate_artifacts: int = 0,
rotate_artifacts: int | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing a reason for this change. If you revert it back, you can also just revert your change below on line 113, and it will work as you expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0