feat: Allow entrypoints other than main.jsonnet when searching for environments #1250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When using inline environments, some
tk
commands produce empty results when using an entrypoint whose filename is anything other thanmain.jsonnet
.Example
You can reproduce the behavior by creating a simple project with an inline environments having two entrypoint files:
main.jsonnet
other.jsonnet
With this setup running the commands:
tk env list main.jsonnet tk export export-dir main.jsonnet --recursive
Will produce the expected result, either listing the environment or exporting a
ConfigMap
manifest. However running:tk env list other.jsonnet tk export export-dir other.jsonnet --recursive
will not print any environments and exports nothing. Running
tk export export-dir other.jsonnet --name main
will, however, export the manifests for the environment. This behavior feels inconsistent. I'm not sure if supporting this should be considered a feature or bug.Rationale
My organization's tanka-based stack makes heavy use of inline environments to generate its manifests. In the never-ending search for "the cleanest way to do things" we sometimes find it convenient to create two entrypoints for a project where one selectively uses manifests from the other. But only one can be named
main.jsonnet
, which has made building automated tooling that depends on usingenv list
or--recursive
to find environments troublesome. Admittedly, this may be a niche use case and it could be solved using external variables.Solution
I've modified
find.go
such that if the requested search path for environments is exactly the name of the found file, then it is considered a mainfile. this seems to resolve the inconsistency in behavior for inline environments and I struggle to think of a way it could cause problems.