HCL Format + Examples

Information on using the HCL format to define Scale Signatures

The Hashicorp Configuration Language (HCL) is used to define signatures in human readable way.

HCL Basics

In the context of Scale Signatures, the Signature File is concerned with HCL's attributes and blocks.

Attributes

In HCL, an attribute is a fundamental element that assigns a value to a name. Attributes are key-value pairs, and their values can be simple literals (like strings or numbers), or they can be more complex expressions.

For example:

field1 = "a field"
field2 = 2

Blocks

blocks, in HCL, are structures representing a higher-order configuration container that can hold attributes and, in some cases, nested blocks. Blocks form the core structure of HCL-based configurations, especially in tools like Terraform, and in Scale Signatures and Extensions.

A block in HCL has a type, zero or more labels, and a body. The type defines the kind of configuration the block will hold (like a resource, or in the case below, a model). Labels are additional identifiers to distinguish or parameterize the block further. The body of the block contains attributes and possibly nested blocks.

model Thing {
  string "name" {
    default  = ""
    accessor = true
  }
}

Example Signatures

When you run scale fn new helloworld:latest, this is the default signature that is created for, and generated for you:

version = "v1alpha"
context = "context"
model Context {
  string MyString {
    default = "DefaultValue"
  }
}
Edit on GitHub

Last updated on

On this page