Skip to content

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