A jsonnet package manager.
Find a file
Benoit Gagnon 671f860a19 Shallow fetch for Git packages
If the server supports it, fetch a specific
revision with --depth 1. Otherwise, fall back
to the normal fetch.

This replaces the previous "clone" operation. The bandwidth and time savings
can be significant depending on the history
of the repository (number of commits).
2019-07-24 23:02:14 -04:00
cmd/jb Fix install integration tests by using v0.1.0 of jb 2019-07-23 13:44:51 -07:00
pkg Shallow fetch for Git packages 2019-07-24 23:02:14 -04:00
scripts Initial commit 2018-04-24 16:01:37 +01:00
spec Add correct lockfile handling 2018-07-25 13:57:37 +02:00
vendor Update vendored deps 2019-07-23 13:36:26 -07:00
.drone.jsonnet Run unit tests and integration tests in CI 2019-07-23 13:42:38 -07:00
.drone.yml Run unit tests and integration tests in CI 2019-07-23 13:42:38 -07:00
.gitignore Initial commit 2018-04-24 16:01:37 +01:00
.header Initial commit 2018-04-24 16:01:37 +01:00
CHANGELOG.md Release v0.1.0 2019-04-23 17:03:40 +02:00
Dockerfile Initial commit 2018-04-24 16:01:37 +01:00
go.mod pkg: Write tests for TestInsertDependency, TestFileExists, TestLoadJsonnetfile 2019-07-23 13:36:18 -07:00
go.sum Use Drone as the CI with a working pipeline (#28) 2019-04-23 14:26:40 +02:00
LICENSE Initial commit 2018-04-24 16:01:37 +01:00
Makefile drone: Run tests including integration tests 2019-07-23 13:37:23 -07:00
README.md Release v0.1.0 2019-04-23 17:03:40 +02:00
VERSION Release v0.1.0 2019-04-23 17:03:40 +02:00

jsonnet-bundler

NOTE: This project is alpha stage. Flags, configuration, behavior and design may change significantly in following releases.

The jsonnet-bundler is a package manager for Jsonnet.

Install

go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb

Features

  • Fetches transitive dependencies
  • Can vendor subtrees, as opposed to whole repositories

Current Limitations

  • Always downloads entire dependent repositories, even when updating
  • If two dependencies depend on the same package (diamond problem), they must require the same version

Example Usage

Initialize your project:

mkdir myproject
cd myproject
jb init

The existence of the jsonnetfile.json file means your directory is now a jsonnet-bundler package that can define dependencies.

To depend on another package (another Github repository): Note that your dependency need not be initialized with a jsonnetfile.json. If it is not, it is assumed it has no transitive dependencies.

jb install https://github.com/anguslees/kustomize-libsonnet

Now write myconfig.jsonnet, which can import a file from that package. Remember to use -J vendor when running Jsonnet to include the vendor tree.

local kustomize = import 'kustomize-libsonnet/kustomize.libsonnet';

local my_resource = {
  metadata: {
    name: 'my-resource',
  },
};

kustomize.namePrefix('staging-')(my_resource)

To depend on a package that is in a subtree of a Github repo (this package also happens to bring in a transitive dependency):

jb install https://github.com/coreos/prometheus-operator/jsonnet/prometheus-operator

Note that if you are copy pasting from the Github website's address bar, remove the tree/master from the path.

If pushed to Github, your project can now be referenced from other packages in the same way, with its dependencies fetched automatically.

All command line flags

$ jb -h
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 [<packages>...]
    Install all dependencies or install specific ones

  update
    Update all dependencies.