KOSI Language Reference

“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");
    }
}

More information about each KOSI Plugin and their use can be found here Plugins.

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.png and docs.tgz. Note: Please name your Markdown files inside docs.tgz without versions, for example docs/documentation.md.

files

files = 
{
    input = "template.yaml";
}

The files element describes the files which are included in the KOSI package.

When you build the package, the files element is written into package.yaml as includes.files.

containers

containers = 
{
    example = ["docker.io", "nginx", "latest"];
}
  • The containers element is used for docker images. The three element array clearly encodes exactly what KOSI needs to pull an image: the registry docker.io, the repository nginx and the tag latest.
  • When you build the package, that shorthand is rewritten into YAML form inside package.yaml as includes.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 example would 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 cmd Plugin is for executing commands in the command line and the if Plugin is for creating conditions, under which other plugins are executed.

The main used trees are install for installing a new package, update for updating packages and delete for deleting packages.