hcl

package
v1.58.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package hcl provides an HCL → YAML converter for docker-agent configuration files. The HCL surface mirrors the YAML schema with a few conventions:

  • Top-level keyed maps (agents, models, providers, mcps, rag) are written as labeled blocks, e.g. `agent "root" { ... }` becomes `agents: { root: { ... } }`.
  • Inside an agent, `command "name" { ... }` becomes `commands: { name: { ... } }`.
  • Toolsets use the label as the `type` field: `toolset "mcp" { ... }` becomes `toolsets: [{ type: mcp, ... }]`.
  • Multi-line strings should use heredocs. Because HCL templates expand `${...}` interpolation, any literal `${...}` (such as `${shell({cmd: "..."})}`) must be escaped as `$${...}`.
  • The custom `file("path")` function reads a UTF-8 text file and returns its contents as a string. Relative paths are resolved from the HCL config file's directory.

The converter does not validate the resulting document against the configuration schema; that is left to the existing YAML/JSON loader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LabelKeyedMapOutKeys

func LabelKeyedMapOutKeys() map[string]bool

LabelKeyedMapOutKeys returns the set of YAML keys produced by HCL block rules that map a labeled block into a label-keyed map (e.g. agent "x" {} becomes agents.x). It is exported so tests can verify the HCL conventions stay in sync with top-level keyed maps in the JSON schema.

func LooksLikeHCL

func LooksLikeHCL(data []byte) bool

LooksLikeHCL reports whether the given bytes look like an HCL document rather than a YAML one. The detection is heuristic and is intended for callers that do not have a filename hint to rely on (for example, OCI artifacts). It looks for top-level labeled blocks of the docker-agent HCL schema, e.g. `agent "..." {`, which are not valid YAML.

func ToMap

func ToMap(data []byte, filename string) (map[string]any, error)

ToMap parses an HCL document and returns a generic map that mirrors the structure of the equivalent YAML document.

func ToYAML

func ToYAML(data []byte, filename string) ([]byte, error)

ToYAML parses an HCL document and returns an equivalent YAML document that can be fed to the existing docker-agent config loader.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL