Documentation
¶
Overview ¶
Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package fsutil provides filesystem utilities for parsing HCL input (files or directories), listing files by extension, and writing output files with automatic directory creation.
Index ¶
- Variables
- func HasGeneratedMarker(path, provider string) (bool, error)
- func ListFilesWithExtensions(path string, recursive bool, exts ...string) ([]string, error)
- func ParseHCLInput(path string, recursive bool) (hcl.Body, error)
- func PrependGeneratedMarker(content []byte, provider string) []byte
- func PruneStaleGeneratedYAML(outputDir string, currentOutputs map[string]struct{}, provider string) error
- func UniqueOutputName(taken map[string]struct{}, base string) string
- func WriteFile(path string, content []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrNoHCLFiles = errors.New("no HCL files found in input")
ErrNoHCLFiles is returned when no HCL files are found in the given path.
Functions ¶
func HasGeneratedMarker ¶
HasGeneratedMarker reports whether path has cinzel markers for provider.
func ListFilesWithExtensions ¶
ListFilesWithExtensions returns files under path matching the given extensions.
func ParseHCLInput ¶
ParseHCLInput parses one or more HCL files from path and returns a merged body.
func PrependGeneratedMarker ¶
PrependGeneratedMarker prepends standardized cinzel generation markers.
func PruneStaleGeneratedYAML ¶
func PruneStaleGeneratedYAML(outputDir string, currentOutputs map[string]struct{}, provider string) error
PruneStaleGeneratedYAML removes stale YAML files owned by provider.
The whole tree under outputDir is walked, not only its top level. An output can sit in a subdirectory, either because a filename names one or because an action is written to its own folder, and a file left there was never reached: renaming an action kept the old one beside the new one for good.
Only files carrying the provider's marker are removed, so anything the caller wrote by hand is left where it is. currentOutputs has to name every file this run produced, actions included, or a live file is read as stale and deleted.
func UniqueOutputName ¶ added in v0.6.0
UniqueOutputName returns base, or a suffixed variant when base is already taken, and records whichever it returns. Output paths are built from the input's basename alone, so two files a directory apart wrote to one path and the first result was gone with nothing said.
Case is folded because a name differing only in case is the same file on macOS and Windows, and the same input would otherwise produce different output depending on where it ran.
Types ¶
This section is empty.