Skip to content

feat: allow additional jpaths #1491

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

feat: allow additional jpaths #1491

wants to merge 5 commits into from

Conversation

zerok
Copy link
Contributor

@zerok zerok commented Jun 26, 2025

EXPERIMENTAL

In a few scenarios it would be extremely helpful to extend the JPATH defined by Tanka. Let's say we want to override certain dependencies for certain environments in order to test them there. Using <base>/vendor is an option but it would require those dependencies to be copied to every environment we want to test it it.

With this, we could use the tkrc.yaml file and define something like this:

# environment-jpath-rules can be used to inject an additional layer of vendor
# folders into the search path for Tanka. If a rule matches then the folder
# will be injected:
#
# Default weights:
# - 0: <base>
# - 100: <root>/lib
# - 200: <base>/vendor
# - 300: <root>/vendor
additionalJPaths:
  - name: Use shared test vendoring
    path: shared-vendors/test/vendor
    # Default weight is 250, so between <base>/vendor and <root>/vendor
    weight: 250

    # The expressions could even be automatically generated by a
    # preprocessor in order to get more complex scenarios:
    matchExpressions:
      - key: cluster_name
        operator: in
        values:
          - test-cluster-0
          - test-cluster-1

The configuration above would add the shared-vendors/test/vendor folder to the search path if the environments are targetting the clusters test-cluster-0 or test-cluster-1. Anything in that folder would be considered before the content of the <root>/vendor folder.

TODOs

  • Implement in export command
  • Implement in show command
  • Get this to work in tool-importers and tool-imports commands
  • Update documentation

zerok added 4 commits June 26, 2025 12:15
This will allow injecting additional jpath elements into the Resolve
function. Sorting happens now every time that function is called which
is not really ideal but also - given the size of the list - shouldn't
matter all that much.
This adds zero value to the end-user and also breaks various tests.
@zerok
Copy link
Contributor Author

zerok commented Jul 7, 2025

I don't think it will be possible to integrate this into the eval command since that is not necessarily operating on environments.

This is especially intended for `show`.
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.

1 participant