copy-1.7.0

KOSI Plugin copy Version 1.7.0

Summary

The copy plugin allows you to copy either a single file or an entire directory, including all its contents, recursively. It provides options to control overwriting behavior when files already exist in the destination.

Keys

Key Description
src Mandatory Specifies the absolute path of the source file or directory to be copied.
dest Mandatory Specifies the absolute path of the destination file or directory where the source will be copied.
overwrite true/false Controls whether existing files in the destination should be replaced.
  • If set to true, any file in the destination with the same name will be replaced.
  • If set to false, an error will be thrown if the file already exists in the destination.
  • If no file with the same name exists, the file will be copied normally, regardless of the overwrite setting.

⚠️ Warning: Overwritten data will be permanently lost and cannot be recovered! Proceed with caution. ⚠️

Usage

Example 1 - Copy file

The following example demonstrates how to copy a single file from a source location to a destination.

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/kosi/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
{
    copy
    (
        src = "/absolute/path/to/file"; 
        dest = "/absolute/path/to/the/dest/file";
        overwrite = "true/false";
    );
}

Note: Copying a file will not change its name. The destination file will retain the same name as the source file unless explicitly changed in the dest parameter.

Example 2 - Copy folder

The following example demonstrates how to copy a folder from a source location to a destination.

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/kosi/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
{
    copy
    (
        src = "/absolute/path/to/folder"; 
        dest = "/absolute/path/to/the/dest/folder";
        overwrite = "true/false";
    );
}

Example 3 - Copying multiple files with a specific extension

The following example copies all .txt files from the source directory to the destination directory.

languageversion = "1.0.0";
apiversion = "kubernative/kubeops/kosi/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 Copying all .txt files from source to destination");
    copy
    (
        src = "/absolute/path/to/source/*.txt"; 
        dest = "/absolute/path/to/destination/"; 
        overwrite = "true/false";
    );
}