cmd-1.7.0

KOSI Plugin cmd Version 1.7.0

Summary

The cmd plugin allows execution of Linux shell commands within a deployment configuration. It relies on either the bash or sh plugin to process commands, depending on availability. If the bash plugin is present, it will be used; otherwise, the sh plugin will handle execution.

Plugin dependencies

If you want to use the plugin cmd you need one of following plugins:

Why is the bash or sh Plugin Required?

The cmd plugin itself does not execute commands directly. Instead, it acts as a wrapper, passing the specified command to a shell environment. Since bash and sh are the most common shell interpreters in Linux, the plugin requires at least one of them to function properly.

Keys

Key Description
command Mandatory set this to a command for the bash or the sh terminal .

Note: The command has to be surrounded by double quotes, otherwise it will not be recognized.

Usage

Example 1 - Executing a single commands

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
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
{
    cmd(command = "echo Using the cmd-plugin");
    cmd(command = "echo Hello World");
}

Expected Output

This will be printed to the console:

2023-12-01 10:44:30 Info:      use plugin bash if available
Using the cmd-plugin
Hello World

Example 2 - Multiple commands

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
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
{
    cmd(command = "echo Using the cmd-plugin");
    cmd(command = "echo Hello World! '>' test.txt");
    cmd(command = "cat test.txt");
}

Expected Output

A file named test.txt is created and “Hello World!” is written to the file.
The second command outputs the contents of the file.

2023-12-01 11:06:17 Info:      run cmd plugin
Using the cmd-plugin
2023-12-01 11:06:17 Info:      run cmd plugin
Hello World!

Example 3 - Creating and listing a directory

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
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
{
    cmd(command = "mkdir -p /tmp/mydirectory");
    cmd(command = "ls -la /tmp/mydirectory");
}