jsonnet-bundler/README.md

107 lines
2.4 KiB
Markdown
Raw Normal View History

2018-04-24 15:19:40 +01:00
# jsonnet-bundler
> NOTE: This project is *alpha* stage. Flags, configuration, behavior and design may change significantly in following releases.
2019-03-12 19:00:08 +00:00
The jsonnet-bundler is a package manager for [Jsonnet](http://jsonnet.org/).
2018-04-24 15:19:40 +01:00
## Install
```
go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
```
2019-03-12 19:00:08 +00:00
## Features
- Fetches transitive dependencies
- Can vendor subtrees, as opposed to whole repositories
## Current Limitations
2019-03-13 13:13:20 +00:00
- Always downloads entire dependent repositories, even when updating
2019-03-12 19:00:08 +00:00
- If two dependencies depend on the same package (diamond problem), they must require the same version
## Example Usage
Initialize your project:
```sh
mkdir myproject
cd myproject
jb init
```
The existence of the `jsonnetfile.json` file means your directory is now a
2019-03-13 13:13:20 +00:00
jsonnet-bundler package that can define dependencies.
2019-03-12 19:00:08 +00:00
To depend on another package (another Github repository):
2019-03-13 13:13:20 +00:00
*Note that your dependency need not be initialized with a `jsonnetfile.json`.
If it is not, it is assumed it has no transitive dependencies.*
2019-03-12 19:00:08 +00:00
```sh
jb install https://github.com/anguslees/kustomize-libsonnet
```
Now write `myconfig.jsonnet`, which can import a file from that package.
2019-03-13 11:02:13 +00:00
Remember to use `-J vendor` when running Jsonnet to include the vendor tree.
2019-03-12 19:00:08 +00:00
```jsonnet
2019-03-13 11:02:13 +00:00
local kustomize = import 'kustomize-libsonnet/kustomize.libsonnet';
2019-03-12 19:00:08 +00:00
local my_resource = {
metadata: {
name: 'my-resource',
},
};
kustomize.namePrefix('staging-')(my_resource)
```
2019-03-13 11:02:13 +00:00
To depend on a package that is in a subtree of a Github repo (this package also
2019-03-12 19:00:08 +00:00
happens to bring in a transitive dependency):
```sh
jb install https://github.com/coreos/prometheus-operator/jsonnet/prometheus-operator
```
2019-03-13 11:02:13 +00:00
*Note that if you are copy pasting from the Github website's address bar,
remove the `tree/master` from the path.*
2019-03-12 19:00:08 +00:00
If pushed to Github, your project can now be referenced from other packages in
2019-03-13 13:13:20 +00:00
the same way, with its dependencies fetched automatically.
2019-03-12 19:00:08 +00:00
## All command line flags
2018-04-24 15:19:40 +01:00
[embedmd]:# (_output/help.txt)
```txt
$ jb -h
2018-05-13 06:55:13 -07:00
usage: jb [<flags>] <command> [<args> ...]
A jsonnet package manager
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--jsonnetpkg-home="vendor"
The directory used to cache packages in.
Commands:
help [<command>...]
Show help.
init
Initialize a new empty jsonnetfile
install [<uris>...]
2018-05-13 06:55:13 -07:00
Install all dependencies or install specific ones
2018-06-29 14:29:48 +02:00
update
Update all dependencies.
2019-04-23 17:03:40 +02:00
2018-04-24 15:19:40 +01:00
```
2019-03-12 19:00:08 +00:00