Skip to content

Add salt.modules.container_resource - #11

Merged
m-czernek merged 27 commits into
mainfrom
container-resource-add
Sep 21, 2026
Merged

m-czernek merged 27 commits into
mainfrom
container-resource-add

Conversation

@m-czernek

Copy link
Copy Markdown
Contributor

What does this PR do?

In this PR, I am:

What issues does this PR fix or reference?

Related to #6 (without this PR, release is blocked)

Previous Behavior

Extension worked for 3006 and 3007, but would be failing on 3008.

New Behavior

Extension works for 3008 as well.

Merge requirements satisfied?

[NOTICE] Bug fixes or new features require tests.

Commits signed with GPG?

Yes/No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

terminalmage and others added 24 commits September 20, 2026 12:19
Also consolidated the lxc-attach/nsenter command building into
container_resource.run to allow the docker module to use the
common code.
Also rename exec_method argument to exec_driver
Added a versionadded directive and also updated the short one-paragraph
description to include docker-ng.
Signed-off-by: Mathieu Le Marec - Pasquet <[email protected]>
Signed-off-by: Mathieu Le Marec - Pasquet <[email protected]>
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
This fixes violations found in salt/modules/ (A-M)
@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.02151% with 119 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.03%. Comparing base (fe8aee9) to head (78c2fb2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/saltext/dockermod/modules/container_resource.py 36.31% 85 Missing and 29 partials ⚠️
src/saltext/dockermod/modules/dockermod.py 28.57% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   42.21%   42.03%   -0.19%     
==========================================
  Files          25       26       +1     
  Lines        6360     6545     +185     
  Branches     1092     1138      +46     
==========================================
+ Hits         2685     2751      +66     
- Misses       3458     3547      +89     
- Partials      217      247      +30     
Flag Coverage Δ
Linux 42.03% <36.02%> (-0.19%) ⬇️
project 37.61% <36.02%> (-0.09%) ⬇️
py310 42.03% <36.02%> (-0.19%) ⬇️
salt_3006_19 42.03% <36.02%> (-0.19%) ⬇️
salt_3007_11 42.03% <36.02%> (-0.19%) ⬇️
tests 50.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m-czernek
m-czernek force-pushed the container-resource-add branch from 10758dd to 78c2fb2 Compare September 20, 2026 11:04
@m-czernek
m-czernek merged commit a4116fd into main Sep 21, 2026
17 checks passed
@m-czernek
m-czernek deleted the container-resource-add branch September 21, 2026 09:21
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.

8 participants