lock

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index interface {
	// GetOrCreateProviderVersion returns a cached provider version if available,
	// otherwise creates it.
	// address is a provider address such as hashicorp/null.
	// version is a version number such as 3.2.1.
	// platforms is a list of target platforms to generate hash values.
	// Target platform names consist of an operating system and a CPU architecture such as darwin_arm64.
	GetOrCreateProviderVersion(ctx context.Context, address string, version string, platforms []string) (*ProviderVersion, error)
}

Index is an in-memory data store for caching provider hash values.

func NewIndex

func NewIndex(papi ProviderDownloaderAPI) Index

NewIndex returns a new instance of Index with the given provider downloader API.

func NewIndexFromConfig added in v0.9.0

func NewIndexFromConfig(config tfregistry.Config) (Index, error)

NewIndexFromConfig returns a new instance of Index with the given registry config.

func NewMockIndex

func NewMockIndex(pvs []*ProviderVersion) Index

NewMockIndex does not call the real API but returns preset mock provider version metadata.

type ProviderDownloadRequest

type ProviderDownloadRequest struct {
	// (required): the namespace portion of the address of the requested provider.
	Namespace string `json:"namespace"`
	// (required): the type portion of the address of the requested provider.
	Type string `json:"type"`
	// (required): the version selected to download.
	Version string `json:"version"`
	// (required): a keyword identifying the operating system that the returned package should be compatible with, like "linux" or "darwin".
	OS string `json:"os"`
	// (required): a keyword identifying the CPU architecture that the returned package should be compatible with, like "amd64" or "arm".
	Arch string `json:"arch"`
}

ProviderDownloadRequest is a request type for ProviderDownload.

type ProviderDownloadResponse

type ProviderDownloadResponse struct {
	// contains filtered or unexported fields
}

ProviderDownloadResponse is a response type for ProviderDownload.

type ProviderDownloaderAPI

type ProviderDownloaderAPI interface {
	// ProviderDownload downloads a provider package.
	ProviderDownload(ctx context.Context, req *ProviderDownloadRequest) (*ProviderDownloadResponse, error)
}

PackageDownloaderAPI is an interface for downloading provider package. Provider packages are downloaded from the HashiCorp release server, GitHub release page or somewhere else. Therefore we distinct this API from the Terraform Registry API. The API specification is not documented.

type ProviderDownloaderClient

type ProviderDownloaderClient struct {
	// contains filtered or unexported fields
}

ProviderDownloaderClient implements the ProviderDownloaderAPI interface

func NewProviderDownloaderClient

func NewProviderDownloaderClient(config tfregistry.Config) (*ProviderDownloaderClient, error)

NewProviderDownloaderClient is a factory method which returns a ProviderDownloaderClient instance.

func (*ProviderDownloaderClient) ProviderDownload

ProviderDownload downloads a provider package.

type ProviderVersion

type ProviderVersion struct {
	// contains filtered or unexported fields
}

ProviderVersion is a data structure that holds hash values of a specific version of a particular provider. It corresponds to one provider block in the dependency lock file (.terraform.lock.hcl). https://developer.hashicorp.com/terraform/language/files/dependency-lock

func NewMockProviderVersion

func NewMockProviderVersion(address string, version string, platforms []string, h1Hashes map[string]string, zhHashes map[string]string) *ProviderVersion

NewMockProviderVersion returns a mocked ProviderVersion for testing. This is actually a setter to all private fields, but should not be used except for generating test data from outside the package.

func (*ProviderVersion) AllHashes

func (pv *ProviderVersion) AllHashes() []string

AllHashes returns an array of strings containing all hash values. It is intended to be used as the value of hashes in a dependency lock file. The result is sorted alphabetically.

func (*ProviderVersion) Merge

func (pv *ProviderVersion) Merge(rhs *ProviderVersion) error

Merge takes another ProviderVersion and merges it. It returns an error if the argument is incompatible the current object.

Jump to

Keyboard shortcuts

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