Manage dependencies

Commodore components can declare dependencies to Jsonnet libraries. Those dependencies are resolved and downloaded using jsonnet-bundler.

Define dependencies in a jsonnetfile.json file. This file must be placed at the root of the component’s file structure.

Example jsonnetfile.json
{
  "version": 1,
  "dependencies": [
    {
      "source": {
        "git": {
          "remote": "https://github.com/coreos/kube-prometheus",
          "subdir": "jsonnet/kube-prometheus"
        }
      },
      "version": "release-0.3"
    }
  ],
  "legacyImports": true
}

If two components depend on the same Jsonnet library, they must require the same version. See jsonnet-bundler - Current Limitations

Jsonnet-bundler uses the file jsonnetfile.lock.json to freeze dependency versions for a project. Lock files of libraries aren’t taken into consideration and within this setup, components are libraries. If your component requires a specific version, you have to declare this in the version field within jsonnetfile.json.

When compiling components with commodore component compile, jsonnet-bundler will create the file jsonnetfile.lock.json and the folder vendor. Add them to your .gitignore.