Skip to main content
The vmparser package provides a suite of functions for reading VM configuration from vms/<vmname>.json. Every function accepts a VM name string, resolves the file path automatically, and returns a typed Go value. You can read the entire VM struct in one call, or use the targeted getter functions to retrieve a specific resource section or even a single field.

Import

Error handling

Every read function returns an error as its second return value. Always check it — the error wraps the underlying os or encoding/json failure with context about which file was being read.
Every read function opens and parses the full JSON file on each call. There is no in-memory cache. If you need multiple fields from the same VM in a tight loop, call VMParser or GetVM once and read from the returned struct directly.

Reading by resource

Use VMParser or its alias GetVM to load the entire VM configuration into a *VM struct.
Both functions return (*VM, error). GetVM is a thin wrapper that calls VMParser internally.