Fuzzball Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Creating New Templates

You can create your own templates in the workflow catalog that you or your colleagues can use to render fuzzfiles and run workflows.

Please select either the web UI or CLI tab to see the appropriate instructions for your environment.

Begin by navigating to the workflow catalog and selecting “Create Application” in the upper right corner.

Select the Create Application option

View the blank template fields

From here you can populate all of the fields. The Name, Category, and Description fields are self-explanatory. You will need to provide a Template. This is a normal Fuzzfile with variables inserted using double curly braces and a dot (i.e. {{.VariableName}}).

You might find it easy to create a fuzzfile using the Workflow Editor, and then replace specific values with variables.
The templating feature in the workflow catalog is implemented using Go text/template and slim-sprig. The latter allows you to do more complex operations like creating conditional logic!

Once you have your template specified, you can add inputs for all of your variables. Then you can scroll to the bottom and save your template with the Save Application button.

View the completed workflow catalog template

Now you are ready to test your new template! Find it in the workflow catalog and interact with it as described in the previous two sections.

Run the cowsay workflow

View the cowsay workflow

To create a template in the workflow catalog using the CLI, you’ll need to manually author both a template file and a values file.

Authoring the Template File

The template file is a YAML file with the syntax of a fuzzfile that also includes placeholders for values you want users to customize. These placeholders use the syntax {{.VariableName}}, where VariableName is a unique identifier for each parameterized value.

The templating feature in the workflow catalog is implemented using the Go text/template and slim-sprig. The latter allows you to do more complex operations like creating conditional logic!

Here’s an example template file for a simple “Hello World” workflow:

version: v1
jobs:
  helloworld:
    image:
      uri: {{.ContainerUri}}
    policy:
      retry:
        attempts: 1
      timeout:
        execute: {{.Timeout}}
    command:
      - /bin/sh
      - '-c'
      - {{.Script}}
    resource:
      cpu:
        cores: {{.Cores}}
        affinity: NUMA
      memory:
        size: {{.Memory}}

It is important to provide users with additional details about the possible values for these variables and their purposes. This ensures clarity and helps prevent errors when rendering the fuzzfile. The values file serves this purpose.

Authoring the Values File

The values file must define all variables used in your template. Here is an example corresponding to the “Hello World” template above:

values:
  - name: ContainerUri
    display_name: URI for the docker image to use for this workflow
    string_value: docker://alpine:latest
  - name: Timeout
    display_name: How long to wait for the workflow job to complete
    string_value: 5m0s
  - name: Cores
    display_name: How many CPU cores to allocate for the workflow job
    uint_value: 1
  - name: Memory
    display_name: How much memory to allocate for the workflow job
    string_value: 1GiB
  - name: Script
    display_name: Script to run for the 'hello world' job
    string_value: echo "Hello, world! Hostname ${HOSTNAME}"

Each entry for a variable has the following attributes:

  1. name: The variable name (without the dot prefix used in the template)
  2. display_name: A user-friendly explanation of what the variable does
  3. Value type: One of the following, depending on the data type:
    • string_value: For text values, durations, sizes, etc.
    • uint_value: For unsigned integers (whole numbers)
    • float_value: For decimal numbers
    • bool_value: For true/false values
The value type is indicated by the key name. The value of the key is the default value for the variable.

Adding the Template to the Catalog

Once you’ve created both files, add the template to the workflow catalog using the create command:

# fuzzball application create <TEMPLATE_FILE> <VALUES_FILE> [flags]

For example:

# fuzzball application create hello-world-template.yaml hello-world-values.yaml \
  --name "Hello World" \
  --description "A simple Hello World example" \
  --category "EXAMPLES"

Application created with ID: 00000000-0000-0000-0000-000000000000

Find your template listed amongst the other templates in the workflow catalog by using the fuzzball application list command.