set-1.7.0

KOSI Plugin Set Version 1.7.0

Changelog Plugin set 1.7.0

New

  • set variables inside a KOSI process

Summary

The ‘set’ Plugin allows you to set variables inside a KOSI process to get access for other plugin calls.

Keys

Key Description
variable Mandatory The variable name for accessing the variable.
value Mandatory The value of the variable.

Syntax to access plugin variables inside KOSI:

{{ vars.myvariable }}

values.yaml

usecase: "user" #or "kubeops"

Example Package

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-set-demo-package";
description = "kosi-set-demo-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";

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

install
{
    set
    (
        variable = "kubeopsvariable";
        value = "Hello KubeOps";
    );

    set
    (
        variable = "uservariable";
        value = "Hello User, you use the set-plugin";
    );

    set
    (
        variable = "ifcondition";
        value = "{{ values.usecase }}";
    );

    if(condition = "$vars.ifcondition$ = 'user'";) then
    {
        print(message = "Your ifcondition-variable: {{ vars.ifcondition }}");
        print(message = "Your usecase-values: {{ values.usecase }}");
        print(message = "Your user-variable: {{ vars.uservariable}}");
    } else
    {
        print(message = "Your ifcondition-variable: {{ vars.ifcondition }}");
        print(message = "Your usecase-values: {{ values.usecase }}");
        print(message = "Your kubeops-variable:{{ vars.kubeopsvariable }}");
    }
    print(message = "This will always print.");
}

Result

[root@localhost]# kosi install -p package.tgz -f values.yaml
2025-03-10 11:30:56 Info:      KOSI version: 2.14.0.0_XXXXXXXXXX
2025-03-10 11:30:57 Info:      Your ifcondition-variable: user
2025-03-10 11:30:57 Info:      Your usecase-values: user
2025-03-10 11:30:57 Info:      Your user-variable: Hello User, you use the set-plugin
2025-03-10 11:30:57 Info:      This will always print.
2025-03-10 11:30:57 Info:      Installation successful.

or with usecase => kubeops

[root@localhost]# kosi install -p package.tgz -f values.yaml
2025-03-10 11:22:04 Info:      KOSI version: 2.14.0.0_XXXXXXXXXX
2025-03-10 11:22:05 Info:      Your ifcondition-variable: kubeops
2025-03-10 11:22:05 Info:      Your usecase-values: kubeops
2025-03-10 11:22:05 Info:      Your kubeops-variable:Hello KubeOps
2025-03-10 11:22:05 Info:      This will always print.
2025-03-10 11:22:05 Info:      Installation successful.