Documentation
¶
Overview ¶
Package tfpath holds path predicates for Terraform/OpenTofu config files.
Index ¶
- Constants
- func AllowSet(paths []string) map[string]struct{}
- func Extension(path string) string
- func FilterShadowed(paths []string) []string
- func IsConfig(path string) bool
- func IsHCLConfig(path string) bool
- func IsJSONConfig(path string) bool
- func Matching(paths []string, pred func(string) bool) []string
- func Partition[T any](items []T, path func(T) string) (kept, shadowed []T)
- func PartitionWithTofuPrecedence[T any](items []T, path func(T) string, preferTofu func(string) bool) (kept, shadowed []T)
- func Select(paths []string, pred func(string) bool) []string
- func SelectKeeping(paths []string, pred func(string) bool, keep string) []string
- func SelectKeepingWithTofuPrecedence(paths []string, pred func(string) bool, keep string, ...) []string
- func SelectWithTofuPrecedence(paths []string, pred, preferTofu func(string) bool) []string
- func ShadowedByTofu(paths []string) map[string]struct{}
Constants ¶
const ( ExtTF = ".tf" ExtTofu = ".tofu" ExtTFJSON = ".tf.json" ExtTofuJSON = ".tofu.json" ExtTFVars = ".tfvars" )
Variables ¶
This section is empty.
Functions ¶
func Extension ¶
Extension returns the Terraform/OpenTofu config suffix, including compound JSON suffixes that filepath.Ext would truncate to ".json".
func FilterShadowed ¶
FilterShadowed drops paths ShadowedByTofu reports. The input is returned unchanged when nothing is shadowed.
func IsHCLConfig ¶
IsHCLConfig reports whether path is a native Terraform/OpenTofu HCL configuration file.
func IsJSONConfig ¶
IsJSONConfig reports whether path uses Terraform/OpenTofu JSON configuration syntax.
func Partition ¶
Partition splits items into those OpenTofu would load and those it ignores. shadowed is nil when nothing is dropped; kept is the input slice in that case.
func PartitionWithTofuPrecedence ¶
func PartitionWithTofuPrecedence[T any]( items []T, path func(T) string, preferTofu func(string) bool, ) (kept, shadowed []T)
PartitionWithTofuPrecedence splits twin configs according to preferTofu. A nil callback gives every .tofu path precedence.
func Select ¶
Select is Matching then FilterShadowed. Use it when merging a directory into one module, not when deciding which files enter inventory.
func SelectKeeping ¶
SelectKeeping is Select, except keep stays in the result when it matched pred. If keep is a .tf twin of a selected .tofu file, that .tofu twin is dropped so a scanned Terraform file is not evaluated with its OpenTofu replacement.
func SelectKeepingWithTofuPrecedence ¶
func SelectKeepingWithTofuPrecedence( paths []string, pred func(string) bool, keep string, preferTofu func(string) bool, ) []string
SelectKeepingWithTofuPrecedence is SelectWithTofuPrecedence, except keep stays in the result and its twin is dropped.
func SelectWithTofuPrecedence ¶
SelectWithTofuPrecedence applies OpenTofu precedence only when preferTofu accepts the .tofu path. If a twin exists and preferTofu rejects it, the .tf path is kept instead.
func ShadowedByTofu ¶
ShadowedByTofu reports paths OpenTofu ignores: foo.tf next to foo.tofu, foo.tf.json next to foo.tofu.json. Returns nil when nothing is shadowed.
Types ¶
This section is empty.