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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Package resolver implements Terraform module resolution for tfmodules.RemoteResolver.
Index ¶
- Constants
- Variables
- func GitModuleResolveKey(source, version string) (string, bool)
- func NewModuleCache() (*moduleCache, error)
- func NewRegistryCache(timeout time.Duration) *registryCache
- type BareGitResolver
- type ChainResolver
- type DotTerraformResolver
- type GoGetterConfig
- type GoGetterResolver
- type LocalGitRefResolver
- type LocalResolver
- type Manifest
- type ManifestEntry
- type PrefetchedResolver
- type Resolution
- type Resolver
Constants ¶
const ( DefaultFetchTimeout = 30 * time.Second DefaultMaxModuleBytes = 0 // no per-module cap; use MaxTotalBytes only DefaultMaxTotalBytes = 200 * 1024 * 1024 // 200 MiB )
Variables ¶
var FetchConcurrency = fetchConcurrencyFromEnv()
FetchConcurrency bounds simultaneous go-getter downloads (IAC_MODULE_FETCH_CONCURRENCY).
var HostFetchConcurrency = hostFetchConcurrencyFromEnv()
Functions ¶
func GitModuleResolveKey ¶ added in v1.8.0
GitModuleResolveKey returns a canonical cache key for pinned git module sources. Identical content folds transport spellings (https vs ssh, .git suffix) into one key. Returns false when the source is not a git:: module with ref= (not BareGit-owned).
func NewModuleCache ¶
func NewModuleCache() (*moduleCache, error)
NewModuleCache creates ~/.cache/.../modules (or XDG_CACHE_HOME) and returns it.
func NewRegistryCache ¶ added in v1.8.0
Types ¶
type BareGitResolver ¶ added in v1.8.0
type BareGitResolver struct {
// Defaults to <user-cache-dir>/datadog-iac-scanner/git-bare.
CacheDir string
// contains filtered or unexported fields
}
BareGitResolver keeps one bare clone per repo and extracts refs via git archive.
func NewBareGitResolver ¶ added in v1.8.0
func NewBareGitResolver(cacheDir string) *BareGitResolver
func (*BareGitResolver) Resolve ¶ added in v1.8.0
func (r *BareGitResolver) Resolve(ctx context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
Resolve implements Resolver for any git:: source that carries a ref= parameter.
type ChainResolver ¶
type ChainResolver struct {
// contains filtered or unexported fields
}
ChainResolver tries each Resolver in order.
func NewChainResolver ¶
func NewChainResolver(resolvers ...Resolver) *ChainResolver
func (*ChainResolver) Resolve ¶
func (c *ChainResolver) Resolve(ctx context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
type DotTerraformResolver ¶
type DotTerraformResolver struct {
RootDirs []string
// contains filtered or unexported fields
}
DotTerraformResolver reads terraform init output: .terraform/modules/modules.json.
func (*DotTerraformResolver) Resolve ¶
func (r *DotTerraformResolver) Resolve(_ context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
type GoGetterConfig ¶ added in v1.8.0
type GoGetterConfig struct {
Disabled bool
FetchTimeout time.Duration
// MaxModuleBytes caps each individual module fetch (programmatic knob; not exposed via CLI).
// Defaults to 0 (no per-module cap); the scan-level cap MaxTotalBytes applies instead.
MaxModuleBytes int64
MaxTotalBytes int64
HostAllowlist []string
Cache *moduleCache
RegistryCache *registryCache
TmpDir string
// contains filtered or unexported fields
}
GoGetterConfig holds caps and options for GoGetterResolver. It must not be copied after first use (contains atomic.Int64 and a channel); always use a pointer.
func NewGoGetterConfig ¶ added in v1.8.0
func NewGoGetterConfig() *GoGetterConfig
NewGoGetterConfig returns defaults with a fetch semaphore and a fresh registry cache.
type GoGetterResolver ¶ added in v1.8.0
type GoGetterResolver struct {
// contains filtered or unexported fields
}
GoGetterResolver downloads modules via hashicorp/go-getter (registry translation, caps, cache).
func NewGoGetterResolver ¶ added in v1.8.0
func NewGoGetterResolver(cfg *GoGetterConfig) *GoGetterResolver
func (*GoGetterResolver) Resolve ¶ added in v1.8.0
func (r *GoGetterResolver) Resolve(ctx context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
type LocalGitRefResolver ¶ added in v1.8.0
type LocalGitRefResolver struct {
ScanRoots []string
// Defaults to <user-cache-dir>/datadog-iac-scanner/git-local.
CacheDir string
// contains filtered or unexported fields
}
LocalGitRefResolver extracts self-referential git modules from the local checkout.
func NewLocalGitRefResolver ¶ added in v1.8.0
func NewLocalGitRefResolver(scanRoots []string, cacheDir string) *LocalGitRefResolver
func (*LocalGitRefResolver) Resolve ¶ added in v1.8.0
func (r *LocalGitRefResolver) Resolve(ctx context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
Resolve implements Resolver for git:: sources that reference the local checkout.
type LocalResolver ¶
type LocalResolver struct{}
LocalResolver resolves local filesystem module sources.
func (LocalResolver) Resolve ¶
func (LocalResolver) Resolve(_ context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
type Manifest ¶
type Manifest struct {
Dir string `json:"dir"`
Modules map[string]ManifestEntry `json:"modules"`
}
Manifest is validated JSON: optional root Dir plus source or source@version → ManifestEntry.
func LoadManifest ¶
LoadManifest parses and validates manifest JSON from path.
type ManifestEntry ¶
type ManifestEntry struct {
LocalPath string `json:"local_path"`
Version string `json:"version,omitempty"`
Origin string `json:"origin,omitempty"`
}
ManifestEntry is one row in a --modules-manifest JSON file.
type PrefetchedResolver ¶
type PrefetchedResolver struct {
// contains filtered or unexported fields
}
PrefetchedResolver resolves modules from a --modules-manifest.
func NewPrefetchedResolver ¶
func NewPrefetchedResolver(m *Manifest) *PrefetchedResolver
func (*PrefetchedResolver) Resolve ¶
func (r *PrefetchedResolver) Resolve(_ context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
type Resolution ¶
type Resolution struct {
LocalPath string
Cleanup func() // optional post-scan cleanup
}
Resolution holds a resolved module directory and optional cleanup.
type Resolver ¶
type Resolver interface {
Resolve(ctx context.Context, mod *tfmodules.ParsedModule) (Resolution, error)
}
Resolver maps one module call to disk; errors should wrap *tfmodules.UnresolvedError when appropriate.