lockfile

package
v1.222.0 Latest Latest
Warning

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

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

Documentation

Overview

Package lockfile parses Terraform/OpenTofu dependency lock files (.terraform.lock.hcl) to extract the exact set of providers and versions a component depends on. The lock file is the authoritative source of resolved provider versions (including transitive providers pulled in by child modules), which makes it the right input for eagerly warming the provider cache across platforms.

Index

Constants

View Source
const Name = ".terraform.lock.hcl"

Name is the conventional filename of the Terraform/OpenTofu dependency lock file. Both tools write the same filename.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	// Source is the fully-qualified provider source address recorded as the
	// provider block label, e.g. "registry.terraform.io/hashicorp/aws".
	Source string
	// Version is the exact locked version, e.g. "5.95.0".
	Version string
}

Provider is a single provider dependency recorded in a lock file.

func Parse

func Parse(src []byte, filename string) ([]Provider, error)

Parse parses lock file content; filename is used only for diagnostics.

func ParseDir

func ParseDir(dir string) ([]Provider, error)

ParseDir parses the lock file (.terraform.lock.hcl) in dir. It is a convenience wrapper around ParseFile.

func ParseFile

func ParseFile(path string) ([]Provider, error)

ParseFile reads and parses the lock file at path, returning its providers. A missing file is reported via errUtils.ErrFileNotFound so callers can decide whether to generate one (e.g. by running `terraform init`) before warming.

Jump to

Keyboard shortcuts

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