Skip to main content

Starlark Introduction

This section details the Kurtosis Starlark DSL used to manipulate the contents of enclaves. Feel free to use the official Kurtosis Starlark VS Code extension when writing Starlark with VSCode for features like syntax highlighting, method signature suggestions, hover preview for functions, and auto-completion for Kurtosis custom types.

Useful tips for using and writing Starlark

If you're using Visual Studio Code, you may find our Kurtosis VS Code Extension helpful when writing Starlark.

If you're using Vim, you can add the following to your .vimrc to get Starlark syntax highlighting:

" Add syntax highlighting for Starlark files
autocmd FileType *.star setlocal filetype=python

or if you use Neovim:

autocmd BufNewFile,BufRead *.star set filetype=python

Parameter Naming Convention

In Python, it is very common to name function parameters that are optional. E.g.:

def do_something(required_arg, optional_arg="default_value")

In Kurtosis Starlark, all parameters can be referenced by name regardless of whether they are required or not. We do this to allow for ease-of-reading clarity. Mandatory and optional parameters will be indicated in the comment above the field. Example:

def make_pizza(
# If true, the crust will be thin; if false, the crust will be regular
thin_crust = True,

Similarly, all function arguments can be provided either positionally or by name.

For example, this function...

def make_pizza(size, topping = "pepperoni")

...can be called in any of the following ways:

# 1. Only the required argument filled, positionally

# 2. Only the required argument filled, by name
make_pizza(size = "16cm")

# 3. Both arguments filled, positionally
make_pizza("16cm", "mushroom")

# 4. Both arguments filled, mixing position and name
make_pizza("16cm", topping = "mushroom")

# 5. Both arguments filled, by name
make_pizza(size = "16cm", topping = "mushroom")

We recommend the last style (naming both positional and optional args), for reading clarity.