regfile

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package regfile renders a dotvault configuration as a Windows Registry (.reg) file targeting HKLM\SOFTWARE\Policies\goodtune\dotvault.

The output is the canonical "Windows Registry Editor Version 5.00" format encoded as UTF-16LE with a BOM, matching what regedit.exe produces and what Group Policy tooling expects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(cfg *config.Config) ([]byte, error)

Generate produces .reg file content for cfg encoded as UTF-16LE with BOM.

func GenerateText

func GenerateText(cfg *config.Config) (string, error)

GenerateText produces .reg file content for cfg as plain text using the same Windows Registry Editor Version 5.00 format as Generate, but without UTF-16LE encoding. Useful for tests and for callers that want to inspect or post-process the output.

func MarshalYAML

func MarshalYAML(cfg *config.Config) ([]byte, error)

MarshalYAML renders cfg as the canonical YAML form accepted by config.Load. Output uses 2-space indentation, matching the project's existing config.dev.yaml style, and includes a trailing newline.

In current yaml.v3 versions map keys are emitted in sorted order, which keeps Enrolments and per-engine Settings stable across runs. That behaviour is not formally guaranteed by the YAML spec, so the test suite includes a regression test that pins it; if a future yaml.v3 release drops the implicit sort the test will fail loudly and prompt us to switch to an explicit yaml.Node walk.

Empty optional fields are emitted explicitly (e.g. `auth_method: ""`) rather than omitted, because the source of this call is typically a .reg file or registry-loaded config where the empty-string distinction matters: re-importing a YAML config that omits a field would leave any previously-set value in place, whereas an explicit empty string clears it. This matches the clearing semantics already used by reg-import.

func Parse

func Parse(data []byte) (*config.Config, error)

Parse reads a Windows Registry Editor Version 5.00 .reg file and reconstructs a *config.Config from values under HKLM\SOFTWARE\Policies\goodtune\dotvault.

The input may be UTF-16LE with BOM (the canonical regedit.exe format produced by Generate) or plain text/UTF-8 (the variant produced by GenerateText / --ascii). Other hives are ignored: only values rooted at the dotvault policy key are considered.

Parse does NOT validate the produced config; callers that need validation should pass the result through (*Config).validate via config.Load or the equivalent path. This keeps the parser focused on faithful round-trip and lets callers decide how strict to be.

Types

This section is empty.

Jump to

Keyboard shortcuts

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