fsutil

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func HasGeneratedMarker(path, provider string) (bool, error)

HasGeneratedMarker reports whether path has cinzel markers for provider.

func ListFilesWithExtensions

func ListFilesWithExtensions(path string, recursive bool, exts ...string) ([]string, error)

ListFilesWithExtensions returns files under path matching the given extensions.

func ParseHCLInput

func ParseHCLInput(path string, recursive bool) (hcl.Body, error)

ParseHCLInput parses one or more HCL files from path and returns a merged body.

func PrependGeneratedMarker

func PrependGeneratedMarker(content []byte, provider string) []byte

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

func UniqueOutputName(taken map[string]struct{}, base string) string

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.

func WriteFile

func WriteFile(path string, content []byte) error

WriteFile writes content to path, creating parent directories as needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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