loop-1.4.0

KOSI Plugin loop Version 1.4.0

Changelog Plugin loop 1.4.0

Updates

  • update dependencies

Summary

The loop plugin allows you to repeatedly execute parts of your KOSI package yaml while iterating over a list. A iterator variable is used to access the current element in the list. Loop behaves similar to ‘for each’ in other languages.

Keys

Key Description
iterator Mandatory Allows a string representing any valid variable name.
The iterator allows you to specify the name of the variable containing the list item for the current repetition.
list Mandatory when listVar is not set set a list that you want to loop over in yaml format.
listVar Mandatory when list is not set set a valid variable which stored a list that was previously set by another plugin. Expects a string representing a valid variable that was previously set.
ListVar is an alternative to list allowing you to loop over a variable that contains a list and was set by another plugin.
tasks Mandatory set a list of plugins and their parameters.
Tasks acts the exact same way as the global list of tasks in your Package. All tasks will be repeated for every element of the list given to loop.

Example

languageversion = "0.1.0";
apiversion = "kubernative/kubeops/sina/user/v3";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";

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

containers = 
{
    example=["docker.io", "nginx", "latest"];
}


install 
{  
    loop(iterator='"number"';list='["1","2","3"]')
    {
       fprint(message= '"Hello {0}"';variables='"number"');
    }
}
[ 06/18/2021 13:04:29 Info    default ] Hello 1
[ 06/18/2021 13:04:29 Info    default ] Hello 2
[ 06/18/2021 13:04:29 Info    default ] Hello 3