github.com/grafana/tanka@v0.26.1-0.20240506093700-c22cfc35c21a/pkg/jsonnet/jpath/testdata/precedence/README.md (about) 1 ## `precedence` test 2 3 This directory contains some Jsonnet testdata for testing correct import precedence. 4 5 The desired precedence looks like the following (most specific wins): 6 7 1. consider baseDir (dir containing `main.jsonnet`) first: The current 8 environment is most important 9 2. then `/lib`: project libraries are more specific than any vendors 10 3. then `<baseDir>/vendor`: to allow overriding project vendor on a environment level 11 4. finally `/vendor`: external packages are least specific 12 13 ## internals 14 15 How the test works: 16 17 We basically put the same jsonnet file in multiple locations: 18 19 ```jsonnet 20 { 21 value: "<location>" 22 } 23 ``` 24 25 For example to check for `/lib` to precede both vendor folders, the following is used: 26 27 - `/vendor/project_lib.jsonnet`: `value: "/vendor"` 28 - `/<baseDir>/vendor/project_lib.jsonnet`: `value: "/baseDir-vendor"` 29 - `/lib/project_lib.jsonnet`: `value: "/lib"` 30 31 Then in `<baseDir>/main.jsonnet` we put `import "project_lib.jsonnet"` and 32 expect `value` to be `/lib`.