lock

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 20 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 ProviderLockAPI) Index

NewIndex returns a new instance of Index with the given ProviderLockAPI.

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 ProviderLockAPI added in v0.10.0

type ProviderLockAPI interface {
	// ProviderPackageMetadata returns a package metadata of a provider.
	ProviderPackageMetadata(ctx context.Context, req *ProviderPackageMetadataRequest) (*ProviderPackageMetadataResponse, error)

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

ProviderLockAPI is an interface for locking 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 ProviderLockClient added in v0.10.0

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

ProviderLockClient implements the ProviderLockAPI interface

func NewProviderLockClient added in v0.10.0

func NewProviderLockClient(config tfregistry.Config) (*ProviderLockClient, error)

NewProviderLockClient is a factory method which returns a ProviderLockClient instance.

func (*ProviderLockClient) ProviderDownload added in v0.10.0

ProviderDownload downloads a provider package.

func (*ProviderLockClient) ProviderPackageMetadata added in v0.10.0

ProviderPackageMetadata returns a package metadata of a provider.

type ProviderPackageMetadataRequest added in v0.10.0

type ProviderPackageMetadataRequest tfregistry.ProviderPackageMetadataRequest

type ProviderPackageMetadataResponse added in v0.10.0

type ProviderPackageMetadataResponse tfregistry.ProviderPackageMetadataResponse

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
⌂ 换网址