Package dependencies
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 by 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
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. |
For completeness each location
option is outlined below separately and the underlying structure of the request completed when retrieving the requested dependency is shown.
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.
Local dependencies
When adding local package dependencies:
path
should be the absolute file path.- Specifying
name
andversion
andlocation: local
is allowed. - Searching path ordering is generally
.
followed byKXI_PACKAGE_PATH
and finallyKXI_ARTIFACT_PATH
. - Only
kxi
packages can be added as local dependencies.
location: local
is the default value.
The following is an example dependency which would find test-package.1.0.0.kxi
based on a tagged release 1.0.0
stored at the location path/to/
on the local host.
dependencies:
- name: test-package
path: path/to/test-package-1.0.0.kxi
location: loc
repo: repo
version: 0.0.1
The version in the manifest.yaml
will take precedence over the version in the file path
For example: If you had a package mypackage/2.0.0
but the maanifest includes 1.1.0
then the version of the package is 1.1.0
.
Adding Local dependencies
When adding local dependencies there are a few constraints:
- Only
.kxi
packages can be added as local dependencies. - These can be referenced using
path
with should be the absolute filepath.
The following is an example request which would find test-package.1.0.0.kxi
based on a tagged release 1.0.0
stored at the location path/to/
on the local host.
dependencies:
- name: test-package:
path: path/to/test-package-1.0.0.kxi
The version in the manifest.yaml
will take precedence over the version in the filepath