From 22f353a7b4ff501262ce11aacad4b429fa13364a Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Tue, 12 Mar 2019 19:00:08 +0000 Subject: [PATCH 1/3] Add usage examples to README.md --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 971ce75..d83740e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ > 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](http://jsonnet.org/). +The jsonnet-bundler is a package manager for [Jsonnet](http://jsonnet.org/). + ## Install @@ -10,9 +11,67 @@ The jsonnet-bundler is a package manager for [jsonnet](http://jsonnet.org/). go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb ``` -## Usage -All command line flags: +## Features + +- Fetches transitive dependencies +- Can vendor subtrees, as opposed to whole repositories + + +## Current Limitations + +- Always clones 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: + +```sh +mkdir myproject +cd myproject +jb init +``` + +The existence of the `jsonnetfile.json` file means your directory is now a +jsonnet-bundler package. + +To depend on another package (another Github repository): + +```sh +jb install https://github.com/anguslees/kustomize-libsonnet +``` + +Now write `myconfig.jsonnet`, which can import a file from that package. + +```jsonnet +local kustomize = import 'vendor/kustomize-libsonnet/kustomize.libsonnet'; + +local my_resource = { + metadata: { + name: 'my-resource', + }, +}; + +kustomize.namePrefix('staging-')(my_resource) +``` + +Depend on a package that is in a subtree of a Github repo (this package also +happens to bring in a transitive dependency): + +```sh +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. + + +## All command line flags [embedmd]:# (_output/help.txt) ```txt @@ -39,5 +98,5 @@ Commands: update Update all dependencies. - ``` + From eceba3ee458805610e6b17bd64634fc7dd702731 Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Wed, 13 Mar 2019 11:02:13 +0000 Subject: [PATCH 2/3] -J vendor and italics --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d83740e..6977231 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,10 @@ 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. ```jsonnet -local kustomize = import 'vendor/kustomize-libsonnet/kustomize.libsonnet'; +local kustomize = import 'kustomize-libsonnet/kustomize.libsonnet'; local my_resource = { metadata: { @@ -57,15 +58,15 @@ local my_resource = { kustomize.namePrefix('staging-')(my_resource) ``` -Depend on a package that is in a subtree of a Github repo (this package also +To depend on a package that is in a subtree of a Github repo (this package also happens to bring in a transitive dependency): ```sh 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. +*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. From 15a95d4bb4d83c40f0238baef496a0813aa8fc4f Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Wed, 13 Mar 2019 13:13:20 +0000 Subject: [PATCH 3/3] few more tweaks --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6977231..97ae163 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb ## Current Limitations -- Always clones entire dependent repositories, even when updating +- Always downloads entire dependent repositories, even when updating - If two dependencies depend on the same package (diamond problem), they must require the same version @@ -35,9 +35,11 @@ jb init ``` The existence of the `jsonnetfile.json` file means your directory is now a -jsonnet-bundler package. +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.* ```sh jb install https://github.com/anguslees/kustomize-libsonnet @@ -69,7 +71,7 @@ jb install https://github.com/coreos/prometheus-operator/jsonnet/prometheus-oper remove the `tree/master` from the path.* If pushed to Github, your project can now be referenced from other packages in -the same way. +the same way, with its dependencies fetched automatically. ## All command line flags