Package dependencies
This page provides an overview of package dependencies in the CLI.
The dependencies section of the manifest.yaml
file outlines any external dependencies the package is explicitly dependent on. For example, the user defined function that is required from another package.
When a package is installed, where dependencies are specified in the manifest, the package resolves each dependency and installs them on the host system, which is the system where the command is run.
Dependency format
The expected structure for defining dependencies is as follows:
dependencies:
- name: package
location: loc
repo: repo
version: ver
For completeness, each location
option is outlined below separately and the underlying structure of the request completed when retrieving the requested dependency is shown.
The keys within this dependency structure relate to the following:
key | description |
---|---|
name |
The name of the package to be retrieved as a dependency. |
version |
The version of the package which is to be retrieved as a dependency. |
location |
The storage location from which a package is to be retrieved, one of local (default), github , gitlab or kx-nexus . |
repo |
The repository URL from which the dependency is to be retrieved. |
path |
The local path from which the dependency is to be retrieved. |
kxi |
A special field pointing to the .kxi package location that is used when nested dependencies are used. |
Required environment variables:
GITHUB_TOKEN
this token is required to allow you to download.kxi
packages from Github and can be generated by following the instructions outlined here
kxi package -q init pkg-with-dep --force
kxi package -q add --to pkg-with-dep dep --location github --repo test_user/test_repo --name test-package --version 1.0.0
cat pkg-with-dep/manifest.yaml | grep "dependencies" -A 5
dependencies:
- name: test-package
version: 1.0.0
repo: test_user/test_repo
location: github
metadata: {}
The underlying URL against which this request is executed is as follows (this can be seen in the config: $HOME/.insights/pakx.sources
):
https://github.com/{package.repo}/release/download/{package.version}/{package.name}-{package.version}.kxi
Required environment variables:
GITLAB_TOKEN
this token is required to allow you to download.kxi
packages from Gitlab and can be generated by following the instructions outline here
kxi package -q init pkg-with-dep --force
kxi package -q add --to pkg-with-dep dep --location gitlab --repo test_user/test_repo --name test-package --version 1.0.0
cat pkg-with-dep/manifest.yaml | grep "dependencies" -A 5
dependencies:
- name: test-package
version: 1.0.0
repo: test_user/test_repo
location: gitlab
metadata: {}
The underlying URL against which this request is executed is as follows (this can be seen in the config file: $HOME/.insights/pakx.sources
):
https://gitlab.com/api/v4/projects/{package.repo}/packages/generic/{package.name}/{package.version}/{package.name}-{package.version}.kxi
Required environment variables:
KX_NEXUS_USER
/KX_NEXUS_PASS
The username/password associated with your access to the KX External Nexus.
kxi package -q init pkg-with-dep --force
kxi package -q add --to pkg-with-dep dep --location kx-nexus --repo test_user/test_repo --name test-package --version 1.0.0
cat pkg-with-dep/manifest.yaml | grep "dependencies" -A 5
dependencies:
- name: test-package
version: 1.0.0
repo: test_user/test_repo
location: kx-nexus
metadata: {}
The underlying URL against which this request is executed is as follows (this can be seen in the config file: $HOME/.insights/pakx.sources
):
https://nexus.kxi-dev.kx.com/repository/{package.repo}/{package.name}/{package.version}/{package.name}-{package.version}.kxi"
Configuration of additional dependency options can be done within the ~/.insights/pakx-pakx.sources
config which allows for modifications to the retrieval locations or added sources.
Next steps
- Learn about overlays and patches