Skip to content

Type System

Sam Hatfield edited this page Aug 30, 2016 · 1 revision

Converge Resource Type System: a functional specification

Owner: Sam Hatfield (@sehqlr)

Date/Version: 2016-08-29

Getting the "Dependently Typed" adjective into Converge

The direction I would like to go in is to have the type system as a core feature of converge generally, rather than just for param validation.

With this feature, nodes' values have types associated with them. This includes parameters as it did before, but it also includes values passed between modules.

Type Inferred? What it represents
decimal yes floating point numbers and percentages
url no URLs, including protocol, but not including GET args
ipv4 no IPv4 addresses
ipv6 no IPv6 addresses
CIDR no CIDR subnet notation
blocksize no storage capacity as number + unit (8MiB) or % of disk space

HCL Examples

These are valid:

param "dns_server" {
    default = 8.8.8.8
    type = ipv4
    # validation is implicit
}

param "vm_size" {
    default = 128MiB,
    type = blocksize,
    must = [
        "range 50MiB 512MiB",
    ]
}

The same invalidations apply from the Demo. The list of valid types and extensions for those types would be added to the list output.