JSONNET dependency management based on go modules
git
or other vcs tool supported by go for vcs downloading.
go install github.com/jsonnetmod/jsonnetmod/cmd/jmod@latest
# build, will automately install deps if not exists.
jmod build ./path/to/jsonnetfile
# auto dep
jmod get ./...
# upgrade dep
jmod get -u ./...
# install dep with special version
jmod get github.com/grafana/jsonnet-libs@latest
- Dependency management based on go modules
- all dependency codes will download under
$(go env GOMODCACHE)
GOPROXY
supported to speed up downloadingJSONNET_PATH
compatibility
- all dependency codes will download under
- Compatible with
jsonnetfile.json
- not support local source, use
replace
to fix
- not support local source, use
- Includes all native functions of tanka
- Object YAML import supported
- with hidden fields
__dirname
and__filename
- with hidden fields
{
// module name
// for sub mod import, <module>/path/to/local/file.jsonnet
module: 'github.com/x/b',
// `JSONNET_PATH` compatibility,
// when this field defined, all dependencies will created symlinks under ./<jpath>
jpath: 'vendor',
// dependency version lock or replace
// only support dir
replace: {
// version lock
// if path equals, could short as '@v0.0.18'
'github.com/rancher/local-path-provisioner': 'github.com/rancher/local-path-provisioner@v0.0.18',
// local mod replace
'github.com/x/a': '../a',
// import stubs
'k.libsonnet': 'github.com/jsonnet-libs/k8s-alpha/1.19/main.libsonnet',
// mod short alias
'ksonnet-util': 'github.com/grafana/jsonnet-libs/ksonnet-util',
},
// automately resolve by the jsonnet code `import` or `importstr`
// rules follow go modules
// :: hidden fields means indirect require
require: {
'github.com/rancher/local-path-provisioner':: 'v0.0.19',
// ,<tag_version>, when upgrade, should use tag version for upgrade.
'github.com/grafana/jsonnet-libs':: 'v0.0.0-20210209092858-49e80898b183,master',
'github.com/x/a': 'v0.0.0',
},
}
For some go project like
$ go mod download -json github.com/grafana/loki@v2.1.0
{
"Path": "github.com/grafana/loki",
"Version": "v2.1.0",
"Error": "github.com/grafana/loki@v2.1.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2"
}
Could config mod.jsonnet
replace with commit hash of the tag to hack
{
replace: {
'github.com/grafana/loki': '@1b79df3',
}
}
Like Tanka but without struct limit.
Only one requirement, make sure the file return tanka.dev/Environment
object
cd ./examples
jmod k show ./clusters/demo/hello-world.jsonnet
jmod k apply ./clusters/demo/hello-world.jsonnet
jmod k delete ./clusters/demo/hello-world.jsonnet
jmod k prune ./clusters/demo/hello-world.jsonnet
jmod build -o ./environments/demo/main.jsonnet ./path/to/tanka-environment.jsonnet
tk show ./environments/demo
export not support pipe now, so need to create inline env object main.jsonnet first.