resolver

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

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

View Source
const (
	DefaultFetchTimeout   = 30 * time.Second
	DefaultMaxModuleBytes = 0                 // no per-module cap; use MaxTotalBytes only
	DefaultMaxTotalBytes  = 200 * 1024 * 1024 // 200 MiB

)

Variables

View Source
var FetchConcurrency = fetchConcurrencyFromEnv()

FetchConcurrency bounds simultaneous go-getter downloads (IAC_MODULE_FETCH_CONCURRENCY).

View Source
var HostFetchConcurrency = hostFetchConcurrencyFromEnv()

Functions

func GitModuleResolveKey added in v1.8.0

func GitModuleResolveKey(source, version string) (string, bool)

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

func NewRegistryCache(timeout time.Duration) *registryCache

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

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

type DotTerraformResolver

type DotTerraformResolver struct {
	RootDirs []string
	// contains filtered or unexported fields
}

DotTerraformResolver reads terraform init output: .terraform/modules/modules.json.

func (*DotTerraformResolver) Resolve

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

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

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

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

func LoadManifest(path string) (*Manifest, error)

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

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.

Jump to

Keyboard shortcuts

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