1 Standard Library Reference

Kumori DSL’s standard library provides foundational types, utility functions, and reusable built-in artifacts. The standard library is organized into several logical packages, each serving a specific purpose.

Package Purpose/Contents
io File I/O utilities
strconv String operations
kumori Core artifact/resource types, interfaces, helpers
kumori/builtin Built-in artifacts: HTTPInbound, TCPInbound

The standard library is always available can be imported via the package name in Kumori projects.

[!NOTE] The standard library will be expanded over time to include more utilities and built-in artifacts. Check back frequently for updates!

1.1 io

The io package provides utilities for file input and output operations.

Currently, the only defined function is Open, which reads the contents of a file, returning it as a string, for later use in artifacts.

It is defined as follows:

func Open(path string, args? struct open[]) string

In plain words, io.Open takes a file path as a string and returns the file’s contents as a string. An optional second argument allows for additional options to be specified when opening the file. As mentioned in the Type System, Open Structs guide, the special keyword open, when used within a struct type definition, can be used to pass any values without any type restrictions.

Some example usage:

import "io"

component MyComponent {
    config {
        cnf io.Open("config.txt")
    }

    code {
        MyContainer {
            [...]
            fs {
                "/bin/entrypoint" {
                    data io.Open("entrypoint.sh")
                    mode 0o755
                }
            }
        }
    }
}

For a deeper explanation on how to pass configuration values that will later populate files within artifacts, please refer to the Variable Injection guide.

1.2 strconv

The strconv package provides functions for interacting with strings. This library is defined as follows:

func Format(i number, base number) string

func JSON(v any) string

func Concat(v []string) string

func Join(v []string, sep string) string

The strconv.Format function converts a number to its string representation in the specified base (e.g., binary, decimal, hexadecimal). The strconv.JSON function serializes a value into its JSON string representation. The strconv.Concat function concatenates a list of strings into a single string. The strconv.Join function joins a list of strings into a single string, using the specified separator.

1.3 kumori

The kumori package defines core types and aliases used throughout Kumori DSL, including artifact interfaces, resources, and connectivity constructs. Take a look at previous sections to know all about Kumori DSL types and usage.

1.4 kumori/builtin

The kumori/builtin package provides built-in artifacts that can be used to implement common infrastructure patterns, such as HTTP and TCP inbound services. These built-in artifacts simplify the process of exposing services to external clients.

Please, refer to the Built-in Artifacts documentation for a comprehensive list of available built-in artifacts and their usage.