Documentation
¶
Overview ¶
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
Index ¶
- func ConfigEntries(entries []fs.DirEntry, pred func(string) bool) []fs.DirEntry
- func ConfinedFilePath(ctx context.Context, entry fs.DirEntry, dir, packageRoot string) (string, bool)
- func DetectModuleSourceType(source string) (sourceType, registryScope string)
- func GetProviderFromResourceType(resourceType string) (string, error)
- func IsUnresolved(err error) bool
- func LoadTFFilesFromDir(ctx context.Context, dir, packageRoot string) (model.FileMetadatas, error)
- func LooksLikeLocalModuleSource(source string) bool
- func ParseTerraformModules(ctx context.Context, fsys vfs.FS, files model.FileMetadatas, numWorkers int) (map[string]ParsedModule, error)
- func ParseTerraformModulesFromFiles(ctx context.Context, fsys vfs.FS, files model.FileMetadatas, ...) (map[string]ParsedModule, error)
- func SelectConfigNames(entries []fs.DirEntry, dir string, allow map[string]struct{}, keep string) []string
- func SelectHCLConfigNames(entries []fs.DirEntry, dir string, allow map[string]struct{}, keep string) []string
- type ListModuleEntry
- type ModuleAttributesInfo
- type ModuleParseResult
- type ParsedModule
- type RegistryModuleSource
- type RemoteResolver
- type UnresolvedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigEntries ¶ added in v1.15.0
ConfigEntries returns non-directory entries matching pred. pred is typically tfpath.IsHCLConfig or tfpath.IsConfig.
func ConfinedFilePath ¶ added in v1.15.0
func ConfinedFilePath(ctx context.Context, entry fs.DirEntry, dir, packageRoot string) (string, bool)
ConfinedFilePath reports whether a directory entry is a regular file the Terraform parser can scan. Regular files are accepted. Symlinks are accepted only when their target is a regular file confined within packageRoot (or dir when packageRoot is empty).
func DetectModuleSourceType ¶
func GetProviderFromResourceType ¶
GetProviderFromResourceType extracts the provider name from a Terraform resource type. For example: "aws_s3_bucket" → "aws", "azurerm_network_interface" → "azurerm"
func IsUnresolved ¶ added in v1.7.2
func LoadTFFilesFromDir ¶ added in v1.9.0
LoadTFFilesFromDir returns FileMetadata for top-level Terraform/OpenTofu configuration files (.tf, .tofu, .tf.json, .tofu.json) in dir (no recursion — a Terraform module is a single directory). When packageRoot is non-empty, symlinked config files are included only when their targets stay within the package root.
func LooksLikeLocalModuleSource ¶
LooksLikeLocalModuleSource uses heuristics to determine if the resolved source string is likely local
func ParseTerraformModules ¶
func ParseTerraformModules( ctx context.Context, fsys vfs.FS, files model.FileMetadatas, numWorkers int, ) (map[string]ParsedModule, error)
ParseTerraformModules parses HCL content and extracts module source/version. numWorkers: 0 means auto-detect (GOMAXPROCS).
func ParseTerraformModulesFromFiles ¶ added in v1.9.0
func ParseTerraformModulesFromFiles( ctx context.Context, fsys vfs.FS, files model.FileMetadatas, allowedFiles map[string]bool, ) (map[string]ParsedModule, error)
ParseTerraformModulesFromFiles is a variant of ParseTerraformModules that accepts an optional allowedFiles set to restrict which files contribute module blocks (all files still contribute locals/vars for correct resolution). fsys is used for local-source path validation; a nil fsys falls back to vfs.DiskFS{}.
func SelectConfigNames ¶ added in v1.15.0
func SelectConfigNames(entries []fs.DirEntry, dir string, allow map[string]struct{}, keep string) []string
SelectConfigNames is SelectHCLConfigNames plus JSON config files.
func SelectHCLConfigNames ¶ added in v1.15.0
func SelectHCLConfigNames(entries []fs.DirEntry, dir string, allow map[string]struct{}, keep string) []string
SelectHCLConfigNames returns HCL config basenames from entries, optionally limited to allow and then OpenTofu-shadowed within that set. keep, when set, is never dropped from a scan-set merge.
Types ¶
type ListModuleEntry ¶ added in v1.7.2
type ListModuleEntry struct {
Name string `json:"name"`
Source string `json:"source"`
Version string `json:"version,omitempty"`
SourceType string `json:"source_type"`
RegistryScope string `json:"registry_scope,omitempty"`
FileName string `json:"file_name"`
DefLine int `json:"def_line"`
DefEndLine int `json:"def_end_line"`
}
ListModuleEntry is the JSON shape emitted by `datadog-iac-scanner list-modules`. Field names are stable integration contracts for hosted scan orchestration.
func ListModuleEntries ¶ added in v1.7.2
func ListModuleEntries(modules map[string]ParsedModule, includeLocal bool) []ListModuleEntry
ListModuleEntries converts parsed modules to list-modules JSON rows.
type ModuleAttributesInfo ¶
type ModuleParseResult ¶
type ModuleParseResult struct {
Index int
Module ParsedModule
Error error
}
type ParsedModule ¶
type ParsedModule struct {
Name string
AbsSource string
Source string
Version string
IsLocal bool
SourceType string // local, git, registry, etc.
RegistryScope string // public, private, or "" (non-registry)
AttributesData map[string]ModuleAttributesInfo
FileName string
DefLine int
DefEndLine int
}
func ParseAllModuleVariables ¶
func ParseAllModuleVariables( ctx context.Context, fsys vfs.FS, modules map[string]ParsedModule, rootDir string, resolver RemoteResolver, mergeAllow map[string]struct{}, ) ([]ParsedModule, error)
ParseAllModuleVariables resolves modules to disk and fills AttributesData. Resolution failures for individual modules are non-fatal and logged; only a context cancellation returns an error.
type RegistryModuleSource ¶ added in v1.12.0
type RegistryModuleSource struct {
Host string
Namespace string
Name string
Provider string
Subdir string
}
RegistryModuleSource is a Terraform registry module address.
func ParseRegistryModuleSource ¶ added in v1.12.0
func ParseRegistryModuleSource(source string) (RegistryModuleSource, error)
ParseRegistryModuleSource parses a registry module source, including hosts with ports and //subdir selections. Implicit three-part addresses use registry.terraform.io rather than the OpenTofu default host; explicit registry.opentofu.org sources keep their declared host.
func (*RegistryModuleSource) Public ¶ added in v1.12.0
func (s *RegistryModuleSource) Public() bool
func (*RegistryModuleSource) String ¶ added in v1.12.0
func (s *RegistryModuleSource) String() string
type RemoteResolver ¶ added in v1.8.0
type RemoteResolver interface {
Resolve(ctx context.Context, mod *ParsedModule) (localPath string, err error)
}
type UnresolvedError ¶ added in v1.7.2
type UnresolvedError struct {
Reason string
}
func (*UnresolvedError) Error ¶ added in v1.7.2
func (e *UnresolvedError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
|
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |