KOSI Language Reference
3 minute read
“This Guide explains the basic Structure of the package.kosi File using the if and cmd Plugins”
package.kosi File
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-package";
description = "kosi-example-package description";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
#Included files inside the kosi-package
files =
{
input="template.yaml";
}
#Included images inside the kosi-package. Default has to be changed
containers =
{
nginx = ["docker.io", "nginx", "latest"];
}
#Installation-section of the kosi-package
install
{
cmd(command = "echo using if plugin");
if (condition = "{{values.firstparam}}<2") then
{
cmd(command = "echo using templated values.")
cmd(command = "echo {{values.firstparam}} is smaller than 2");
}
else
{
cmd(command = "echo {{values.firstparam}} is bigger than 2");
}
}
Metadata
There are a few metadata and they are mandatory.
| Parameter | Description |
|---|---|
| languageversion | KOSI language version specification. |
| apiversion | KOSI package version specification. |
| name | Set the name of the package, which will be displayed on the hub. |
| description | Set the description of the package, which will be displayed on the hub. |
| version | Set the version of the package, which will be displayed on the hub. The Versioning is semantic (“major.minor.patch” example: 1.0.1) |
| docs | A Tgz with the documentation of the package, which contains Markdown files. |
| logo | A PNG for a logo of the package. |
IMPORTANT: Only use a fully lowercase name for your package. Note: Do not change the names
logo.pnganddocs.tgz. Note: Please name your Markdown files insidedocs.tgzwithout versions, for exampledocs/documentation.md.
files
files =
{
input = "template.yaml";
}
The
fileselement describes the files which are included in the KOSI package.
When you build the package, the
fileselement is written intopackage.yamlasincludes.files.
containers
containers =
{
example = ["docker.io", "nginx", "latest"];
}
- The
containerselement is used for docker images. The three element array clearly encodes exactly what KOSI needs to pull an image: the registrydocker.io, the repositorynginxand the taglatest.
- When you build the package, that shorthand is rewritten into YAML form inside
package.yamlasincludes.containers.
- The template exposes everything under the root object package. After the build, you can reference any part of the container definition with dot notation. Registry for
examplewould be:{{package.includes.containers.example.registry}}
install
install
{
cmd(command = "echo using if plugin");
if (condition = "{{values.firstparam}}<2") then
{
cmd(command = "echo using templated values.");
cmd(command = "echo {{values.firstparam}} is smaller than 2");
}
else
{
cmd(command = "echo {{values.firstparam}} is greater or equal to 2");
}
}
In this section the logic of the used Plugins is described.
The
cmdPlugin is for executing commands in the command line and theifPlugin is for creating conditions, under which other plugins are executed.
The main used trees are
installfor installing a new package,updatefor updating packages anddeletefor deleting packages.