lock

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 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 NewDefaultIndex

func NewDefaultIndex() (Index, error)

NewDefaultIndex returns a new instance of default Index.

func NewIndex

func NewIndex(papi ProviderDownloaderAPI) Index

NewIndex returns a new instance of Index.

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 TFRegistryConfig) (*ProviderDownloaderClient, error)

ProviderDownloaderClient 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.

type TFRegistryAPI

type TFRegistryAPI interface {
	// ProviderPackageMetadata returns a package metadata of a provider.
	// https://developer.hashicorp.com/terraform/internals/provider-registry-protocol#find-a-provider-package
	ProviderPackageMetadata(ctx context.Context, req *tfregistry.ProviderPackageMetadataRequest) (*tfregistry.ProviderPackageMetadataResponse, error)
}

TFRegistryAPI is an interface which calls Terraform Registry API. This abstraction layer is needed for testing with mock.

type TFRegistryClient

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

TFRegistryClient is a real TFRegistryAPI implementation.

func NewTFRegistryClient

func NewTFRegistryClient(config TFRegistryConfig) (*TFRegistryClient, error)

NewTFRegistryClient returns a real TFRegistryClient instance.

type TFRegistryConfig

type TFRegistryConfig struct {

	// BaseURL is a URL for Terraform Registry API requests.
	// Defaults to the public Terraform Registry API.
	// This looks like the Terraform Cloud support, but currently for testing purposes only.
	// The Terraform Cloud is not supported yet.
	// BaseURL should always be specified with a trailing slash.
	BaseURL string
	// contains filtered or unexported fields
}

TFRegistryConfig is a set of configurations for ProviderDownloaderClient.

Jump to

Keyboard shortcuts

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