Skip to content

Comments

(Fix #63636) terraform roster to use explicit priv value if defined in state#63637

Closed
ricekab wants to merge 3 commits intosaltstack:masterfrom
ricekab:fix/terraform-roster-priv
Closed

(Fix #63636) terraform roster to use explicit priv value if defined in state#63637
ricekab wants to merge 3 commits intosaltstack:masterfrom
ricekab:fix/terraform-roster-priv

Conversation

@ricekab
Copy link

@ricekab ricekab commented Feb 5, 2023

What does this PR do?

Fixes terraform roster from overriding explicit priv attributes with default behaviour.

This PR does not include test cases yet as I'm not sure how to do this for Salt.

What issues does this PR fix or reference?

Fixes: #63636

Previous Behavior

Explicit priv values from terraform state was overriden with default values.

New Behavior

If an explicit value for priv is defined, the default value determination is skipped.

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

@ricekab ricekab requested a review from a team as a code owner February 5, 2023 17:04
@ricekab ricekab requested review from cmcmarrow and removed request for a team February 5, 2023 17:04
@welcome
Copy link

welcome bot commented Feb 5, 2023

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@ricekab
Copy link
Author

ricekab commented Feb 21, 2023

Could I get feedback on this? I'd like to work on this PR to get it into a mergeable state.

Copy link
Contributor

@cmcmarrow cmcmarrow left a comment

Choose a reason for hiding this comment

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

@ricekab thx for the PR. I would add a unit test here https://github.com/saltstack/salt/blob/master/tests/pytests/unit/roster/test_terraform.py

You would need to test _add_ssh_key(ret) and make sure that you get the right ret into ret data. So one test might have ret = {"priv": some temp file}. Another test would check the behavior if ret = {}.

@ricekab
Copy link
Author

ricekab commented Mar 12, 2023

Thanks for the feedback! I'll look into implementing this in the coming week.

@ricekab ricekab force-pushed the fix/terraform-roster-priv branch from 7e964ed to f880fb9 Compare August 7, 2023 09:17
@ricekab
Copy link
Author

ricekab commented Aug 7, 2023

Hi @cmcmarrow , ended up taking me a while before I could come back around to it - I've added a test case for it to the PR. I opted to use a separate tfstate file since the other ones were testing the correct usage of default values (which this would override).

Tested on my setup using a Python 3.9 venv:

$ python -m nox -e "test-3(coverage=False)" -- tests/pytests/unit/roster/test_terraform.py
nox > Running session test-3(coverage=False)
nox > Re-using existing virtual environment at .nox/test-3-coverage-false.
nox > Session test-3(coverage=False) was successful.
nox > Running session test-parametrized-3(crypto=None, transport='zeromq', coverage=False)
nox > Re-using existing virtual environment at .nox/test-parametrized-3-crypto-none-transport-zeromq-coverage-false.
nox > python -m pip install --progress-bar=off -U 'pip>=20.2.4,<21.2' 'setuptools!=50.*,!=51.*,!=52.*,<59'
nox > python -m pip install --progress-bar=off -r requirements/static/ci/py3.9/linux.txt
nox > python -m pytest --rootdir /home/localadmin/salt --log-file-level=debug --show-capture=no -ra -s -vv --showlocals --log-file=/home/localadmin/salt/artifacts/logs/runtests-20230807145051.163828.log --transport=zeromq tests/pytests/unit/roster/test_terraform.py
======================================== test session starts =========================================
platform linux -- Python 3.9.15, pytest-7.3.2, pluggy-1.0.0 -- /home/localadmin/salt/.nox/test-parametrized-3-crypto-none-transport-zeromq-coverage-false/bin/python
cachedir: .pytest_cache
max open files; soft: 3072; hard: 4096
rootdir: /home/localadmin/salt
configfile: pytest.ini
plugins: httpserver-1.0.8, shell-utilities-1.8.0, salt-factories-1.0.0rc25, skip-markers-1.4.1, timeout-2.1.0, flaky-3.7.0, system-statistics-1.0.2, helpers-namespace-2021.12.29, custom-exit-code-0.3.0, subtests-0.11.0, anyio-3.7.0
collected 7 items

tests/pytests/unit/roster/test_terraform.py::test_default_output PASSED
tests/pytests/unit/roster/test_terraform.py::test_default_matching PASSED
tests/pytests/unit/roster/test_terraform.py::test_defaults_new PASSED
tests/pytests/unit/roster/test_terraform.py::test_defaults_new_matching PASSED
tests/pytests/unit/roster/test_terraform.py::test_specified_priv PASSED
tests/pytests/unit/roster/test_terraform.py::test_correct_handler_called_old PASSED
tests/pytests/unit/roster/test_terraform.py::test_correct_handler_called_new PASSED

========================================= 7 passed in 1.04s ==========================================
nox > Session test-parametrized-3(crypto=None, transport='zeromq', coverage=False) was successful.
nox > Ran multiple sessions:
nox > * test-3(coverage=False): success
nox > * test-parametrized-3(crypto=None, transport='zeromq', coverage=False): success

@ricekab ricekab requested a review from cmcmarrow August 7, 2023 12:53
@dwoz dwoz force-pushed the fix/terraform-roster-priv branch from 8f78a31 to 6437444 Compare December 17, 2023 02:47
@dwoz dwoz added this to the Argon v3008.0 milestone Dec 18, 2023
@dwoz dwoz requested a review from a team as a code owner March 16, 2025 22:09
@twangboy
Copy link
Contributor

twangboy commented Apr 4, 2025

This module and its associated states and tests have been transitioned to community support and are no longer maintained by the Salt Core team. The code has been removed from the Salt code-base and can be found in this repository: https://github.com/salt-extensions/community-extensions-holding/

There is currently discussion and work being done on the salt-extensions Discord channel (https://discordapp.com/channels/1200072194781368340/1208165123240370197) to document and build the infrastructure for community-supported salt extensions. There is also a Salt-Extensions Working Group that takes place on the 1st and 3rd Thursday of every month to coordinate salt-extension efforts.

@twangboy twangboy closed this Apr 4, 2025
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.

[BUG] Terraform roster overrides provided "priv" entry.

4 participants