Tanka works with a minimal set of assumptions on its environment. Unlike tools
ksonnet, it does expect code to be placed in strictly named directories.
Instead, it relies on two directories to find your code:
Root Directory (
rootDir marks the start of a directory tree that represents a Tanka
project. It behaves similar to a
A marker file (
git has its
.git/) indicates the beginning of the tree. Regardless of how deep
you are in it, Tanka can always discover the project by searching for a
jsonnetfile.json in the parent directories.
Base Directory (
The base directory is the directory that contains a file called
This file is used as the entrypoint for evaluating
baseDir must be in the tree of the
rootDir or the
main.jsonnet in the same directory).
In this example,
baseDir are the same.
1 2 3 4 5
. ├── jsonnetfile.json ├── lib/ ├── main.jsonnet └── vendor/
To enable a behavior close to what
ksonnet used to call an Environment,
baseDirs can be created in sub-directories.
1 2 3 4 5 6 7 8 9
. ├── environments │ ├── dev │ │ └── main.jsonnet │ └── prod │ └── main.jsonnet ├── jsonnetfile.json ├── lib/ └── vendor/
There are three places, imported files can come from:
Imports may be relative to the current file. Use a relative path (
import "./whatever.jsonnet") for this.
If a folder called
lib exists in
rootDir, imports from here are possible as well.
Place code here, that is used multiple times across this project. However, when this code needs to be re-used across project boundaries, consider moving it into its own Git repository and vendor it in using Jsonnet bundler.
vendor folder is to hold shared libraries, that are downloaded
using a package manager.
This folder shall be managed by Jsonnet bundler or another comparable tool. Do not modify the files in here by hand. Change them on the remote if required.
The most specific import takes precedence:
- Relative import
- Local library (
- Shared library (
The higher an import appears in this list, the more likely it is taken.