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

Enforce config types #61852

Merged
merged 3 commits into from
Apr 19, 2022
Merged

Enforce config types #61852

merged 3 commits into from
Apr 19, 2022

Conversation

twangboy
Copy link
Contributor

What does this PR do?

Enforces config types as specified in the VALID_OPTS dictionary.

What issues does this PR fix or reference?

Fixes: #57873

Previous Behavior

Config types were not enforced in all cases. This allowed for a config type that was supposed to be a list that was passed a string would end up with something like ['s', 't', 'r', 'i', 'n', 'g']

New Behavior

Does not allow config types where they cannot be cleanly converted to the expected type

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@twangboy twangboy requested a review from a team as a code owner March 24, 2022 21:43
@twangboy twangboy requested review from garethgreenaway and removed request for a team March 24, 2022 21:43
@twangboy twangboy force-pushed the fix_57873 branch 3 times, most recently from cb5b9a2 to 4fa487a Compare March 24, 2022 22:17
@github-actions
Copy link

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- duration: 1.06s
- exit code: 1

Traceback (most recent call last):
File "/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/bin/invoke", line 8, in
sys.exit(program.run())
File "/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/lib/python3.9/site-packages/invoke/program.py", line 373, in run
self.parse_collection()
File "/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/lib/python3.9/site-packages/invoke/program.py", line 465, in parse_collection
self.load_collection()
File "/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/lib/python3.9/site-packages/invoke/program.py", line 696, in load_collection
module, parent = loader.load(coll_name)
File "/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/lib/python3.9/site-packages/invoke/loader.py", line 76, in load
module = imp.load_module(name, fd, path, desc)
File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/imp.py", line 244, in load_module
return load_package(name, filename)
File "/opt/hostedtoolcache/Python/3.9.10/x64/lib/python3.9/imp.py", line 216, in load_package
return _load(spec)
File "", line 711, in _load
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/home/runner/work/salt/salt/tasks/init.py", line 3, in
from . import docs, docstrings, filemap, loader
File "/home/runner/work/salt/salt/tasks/docstrings.py", line 13, in
from salt.loader import SALT_INTERNAL_LOADERS_PATHS
File "/home/runner/work/salt/salt/salt/loader/init.py", line 15, in
import salt.config
File "/home/runner/work/salt/salt/salt/config/init.py", line 101, in
_DFLT_IPC_WBUFFER = _gather_buffer_space() * 0.5
File "/home/runner/work/salt/salt/salt/config/init.py", line 89, in _gather_buffer_space
import salt.grains.core
File "/home/runner/work/salt/salt/salt/grains/core.py", line 32, in
import salt.modules.cmdmod
File "/home/runner/work/salt/salt/salt/modules/cmdmod.py", line 31, in
import salt.utils.templates
File "/home/runner/work/salt/salt/salt/utils/templates.py", line 20, in
import salt.utils.jinja
File "/home/runner/work/salt/salt/salt/utils/jinja.py", line 29, in
from jinja2 import BaseLoader, Markup, TemplateNotFound, nodes
ImportError: cannot import name 'Markup' from 'jinja2' (/home/runner/.cache/pre-commit/repodwrtm30m/py_env-python3/lib/python3.9/site-packages/jinja2/init.py)


Thanks again!

@twangboy twangboy force-pushed the fix_57873 branch 2 times, most recently from 4fa487a to 90c9502 Compare March 25, 2022 13:48
@twangboy twangboy added the Phosphorus v3005.0 Release code name and version label Mar 25, 2022
@twangboy twangboy added this to the Phosphorus v3005.0 milestone Mar 25, 2022
@twangboy twangboy force-pushed the fix_57873 branch 2 times, most recently from fdcc461 to 42a39f4 Compare March 31, 2022 22:18
Copy link
Contributor

@waynew waynew left a comment

Choose a reason for hiding this comment

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

Will check the rest of this after our meeting

salt/config/__init__.py Show resolved Hide resolved
Copy link
Contributor

@waynew waynew left a comment

Choose a reason for hiding this comment

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

👍

@garethgreenaway garethgreenaway merged commit d1bb1bf into saltstack:master Apr 19, 2022
@twangboy twangboy deleted the fix_57873 branch March 23, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Phosphorus v3005.0 Release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] list options will treat strings as lists
4 participants