Files
nomad/website/content/partials/plugins/hcl-specifications.mdx
Aimee Ukasick d305f32017 Docs: Plugin authoring guide (#26395)
* create plugin author guide; remove concepts/plugins

* style guide; update links

* update cni redirect

* move host-volume plugin to /plugins/. Add arch host volume content.

* Apply Jeff's style guide updates

Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>

* Create Base plugin API section, link to BasePlugin interface

---------

Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>
2025-08-08 14:55:58 -05:00

33 lines
944 B
Plaintext

## HCL specifications
`*hclspec.Spec` is a struct that defines the schema to validate an HCL entity
against. Find the full documentation of the different HCL attribute types in the [hclspec godoc][hclspec].
For a basic example, review the driver configuration for the raw_exec
driver.
```hcl
job "example" {
...
driver = "raw_exec"
config {
command = "/bin/sleep"
args = ["100"]
}
}
```
The `config` block is what is validated against the `hclspec.Spec`. The
`command` key takes a string attribute, and the `args` key takes an array
attribute. The corresponding `*hclspec.Spec` would be:
```go
spec := hclspec.NewObject(map[string]*hclspec.Spec{
"command": hclspec.NewAttr("command", "string", true),
"args": hclspec.NewAttr("args", "list(string)", false),
})
```
[hclspec]: https://godoc.org/github.com/hashicorp/nomad/plugins/shared/hclspec
[pluginblock]: /nomad/docs/configuration/plugin