-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix: implement compose_target_name
#1138
Conversation
Will add tests for |
Currently this test fails: def test_compile_not_matching_targets(self):
with (
self.assertLogs(logger="kapitan.targets", level="ERROR") as cm,
contextlib.redirect_stdout(io.StringIO()),
):
# as of now, we cannot capture stdout with contextlib.redirect_stdout
# since we only do logger.error(e) in targets.py before exiting
with self.assertRaises(SystemExit) as ca:
unmatched_filename = "inventory/targets/minikube-es-fake.yml"
correct_filename = "inventory/targets/minikube-es.yml"
os.rename(src=correct_filename, dst=unmatched_filename)
sys.argv = ["kapitan", "compile"]
try:
main()
finally:
# correct the filename again, even if assertion fails
if os.path.exists(unmatched_filename):
os.rename(src=unmatched_filename, dst=correct_filename)
error_message_substr = "is missing the corresponding yml file"
self.assertTrue(" ".join(cm.output).find(error_message_substr) != -1) And this makes sense, because the test tests actually unintended behavior.
|
The error happens in the Now the question is, if we handle a mismatch of |
Context, we added this behaviour before starting using Reasoning... I usually have this setup: target: ${_reclass_:name:full}
target_name: ${_reclass_:name:short}
target_path: ${_reclass_:name:path}
...
kapitan:
vars:
target: ${target} IMHO for with
However with we should allow for someone to change the target in cases like:
as otherwise they would both be I believe long term |
This commit is based on the test case introduced in PR kapicorp#1138. We move the compose-node-name test implementation to `tests/` so it's stored in the same place as the other tests and make the test class inheritable so that we can reuse the test for reclass-rs. Additionally we extend the test to check that all targets found by `search_targets()` are rendered by `render_targets()`. This is needed since we don't use reclass(-rs)'s target discovery logic in `search_targets()` but instead use a simplified version that's implemented directly in Kapitan's inventory backend base class. However, `render_targets()` then renders whatever targets reclass(-rs)'s target discovery finds, so if there's a mismatch we'd want to be informed. Co-authored-by: Matteo Voges <matteo.voges@nexenio.com> Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
This commit is based on the test case introduced in PR kapicorp#1138. We move the compose-node-name test implementation to `tests/` so it's stored in the same place as the other tests and make the test class inheritable so that we can reuse the test for reclass-rs. Additionally we extend the test to check that all targets found by `search_targets()` are rendered by `render_targets()`. This is needed since we don't use reclass(-rs)'s target discovery logic in `search_targets()` but instead use a simplified version that's implemented directly in Kapitan's inventory backend base class. However, `render_targets()` then renders whatever targets reclass(-rs)'s target discovery finds, so if there's a mismatch we'd want to be informed. Co-authored-by: Matteo Voges <matteo.voges@nexenio.com> Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
This commit is based on the test case introduced in PR kapicorp#1138. We move the compose-node-name test implementation to `tests/` so it's stored in the same place as the other tests and make the test class inheritable so that we can reuse the test for reclass-rs. Additionally we extend the test to check that all targets found by `search_targets()` are rendered by `render_targets()`. This is needed since we don't use reclass(-rs)'s target discovery logic in `search_targets()` but instead use a simplified version that's implemented directly in Kapitan's inventory backend base class. However, `render_targets()` then renders whatever targets reclass(-rs)'s target discovery finds, so if there's a mismatch we'd want to be informed. Co-authored-by: Matteo Voges <matteo.voges@nexenio.com> Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
This commit is based on the test case introduced in PR kapicorp#1138. We move the compose-node-name test implementation to `tests/` so it's stored in the same place as the other tests and make the test class inheritable so that we can reuse the test for reclass-rs. Additionally we extend the test to check that all targets found by `search_targets()` are rendered by `render_targets()`. This is needed since we don't use reclass(-rs)'s target discovery logic in `search_targets()` but instead use a simplified version that's implemented directly in Kapitan's inventory backend base class. However, `render_targets()` then renders whatever targets reclass(-rs)'s target discovery finds, so if there's a mismatch we'd want to be informed. Co-authored-by: Matteo Voges <matteo.voges@nexenio.com> Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
partially implemented by #1164 which was an urgent fix. Please rebase from that. |
Proposed changes
compose-node-name
compose-node-name
tocompose-target-name
, because it should be kapitan-lingocompose-node-name
deprecatedcompose-target-name
for reclasscompose-target-name
(no breaking changes, just improvements)cached.args