Documentation
¶
Index ¶
- Constants
- Variables
- func PackageMatchesAnyHash(loc PackageLocation, allowed []Hash) (bool, error)
- func PackageMatchesHash(loc PackageLocation, want Hash) (bool, error)
- func PackedFilePathForPackage(baseDir string, provider addrs.Provider, version Version, platform Platform) string
- func SearchLocalDirectory(baseDir string) (map[addrs.Provider]PackageMetaList, error)
- func UnpackedDirectoryPathForPackage(baseDir string, provider addrs.Provider, version Version, platform Platform) string
- func VersionConstraintsString(spec VersionConstraints) string
- type Hash
- func HashLegacyZipSHAFromSHA(sum [sha256.Size]byte) Hash
- func MustParseHash(s string) Hash
- func PackageHash(loc PackageLocation) (Hash, error)
- func PackageHashLegacyZipSHA(loc PackageLocalArchive) (Hash, error)
- func PackageHashV1(loc PackageLocation) (Hash, error)
- func ParseHash(s string) (Hash, error)
- func PreferredHashes(given []Hash) []Hash
- type HashScheme
- type PackageAuthentication
- func NewArchiveChecksumAuthentication(platform Platform, wantSHA256Sum [sha256.Size]byte) PackageAuthentication
- func NewMatchingChecksumAuthentication(document []byte, filename string, wantSHA256Sum [sha256.Size]byte) PackageAuthentication
- func NewPackageHashAuthentication(platform Platform, validHashes []Hash) PackageAuthentication
- func NewSignatureAuthentication(document, signature []byte, keys []SigningKey) PackageAuthentication
- func PackageAuthenticationAll(checks ...PackageAuthentication) PackageAuthentication
- type PackageAuthenticationHashes
- type PackageAuthenticationResult
- type PackageHTTPURL
- type PackageLocalArchive
- type PackageLocalDir
- type PackageLocation
- type PackageMeta
- func (m PackageMeta) AcceptableHashes() []Hash
- func (m PackageMeta) Hash() (Hash, error)
- func (m PackageMeta) HashV1() (Hash, error)
- func (m PackageMeta) LessThan(other PackageMeta) bool
- func (m PackageMeta) MatchesAnyHash(acceptable []Hash) (bool, error)
- func (m PackageMeta) MatchesHash(want Hash) (bool, error)
- func (m PackageMeta) PackedFilePath(baseDir string) string
- func (m PackageMeta) UnpackedDirectoryPath(baseDir string) string
- type PackageMetaList
- func (l PackageMetaList) FilterPlatform(target Platform) PackageMetaList
- func (l PackageMetaList) FilterProviderExactVersion(provider addrs.Provider, version Version) PackageMetaList
- func (l PackageMetaList) FilterProviderPlatformExactVersion(provider addrs.Provider, platform Platform, version Version) PackageMetaList
- func (l PackageMetaList) Len() int
- func (l PackageMetaList) Less(i, j int) bool
- func (l PackageMetaList) Sort()
- func (l PackageMetaList) Swap(i, j int)
- type Platform
- type Requirements
- type Selections
- type SigningKey
- type Version
- type VersionConstraints
- type VersionList
- type VersionSet
- type Warnings
Constants ¶
const HashicorpPartnersKey = `` /* 3193-byte string literal not displayed */
HashicorpPartnersKey is a key created by HashiCorp, used to generate and verify trust signatures for Partner tier providers.
const HashicorpPublicKey = `` /* 7715-byte string literal not displayed */
HashicorpPublicKey is the HashiCorp public key, also available at https://www.hashicorp.com/security
const NilHash = Hash("")
NilHash is the zero value of Hash. It isn't a valid hash, so all of its methods will panic.
Variables ¶
CurrentPlatform is the platform where the current program is running.
If attempting to install providers for use on the same system where the installation process is running, this is the right platform to use.
Functions ¶
func PackageMatchesAnyHash ¶
func PackageMatchesAnyHash(loc PackageLocation, allowed []Hash) (bool, error)
PackageMatchesAnyHash returns true if the package at the given location matches at least one of the given hashes, or false otherwise.
If it cannot read from the given location, PackageMatchesAnyHash returns an error. Unlike the singular PackageMatchesHash, PackageMatchesAnyHash considers unsupported hash formats as successfully non-matching, rather than returning an error.
PackageMatchesAnyHash can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func PackageMatchesHash ¶
func PackageMatchesHash(loc PackageLocation, want Hash) (bool, error)
PackageMatchesHash returns true if the package at the given location matches the given hash, or false otherwise.
If it cannot read from the given location, or if the given hash is in an unsupported format, PackageMatchesHash returns an error.
There is currently only one hash format, as implemented by HashV1. However, if others are introduced in future PackageMatchesHash may accept multiple formats, and may generate errors for any formats that become obsolete.
PackageMatchesHash can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func PackedFilePathForPackage ¶
func PackedFilePathForPackage(baseDir string, provider addrs.Provider, version Version, platform Platform) string
PackedFilePathForPackage is similar to PackageMeta.PackedFilePath but makes its decision based on individually-passed provider address, version, and target platform so that it can be used by callers outside this package that may have other types that represent package identifiers.
func SearchLocalDirectory ¶
func SearchLocalDirectory(baseDir string) (map[addrs.Provider]PackageMetaList, error)
SearchLocalDirectory performs an immediate, one-off scan of the given base directory for provider plugins using the directory structure defined for FilesystemMirrorSource.
This is separated to allow other callers, such as the provider plugin cache management in the "internal/providercache" package, to use the same directory structure conventions.
func UnpackedDirectoryPathForPackage ¶
func UnpackedDirectoryPathForPackage(baseDir string, provider addrs.Provider, version Version, platform Platform) string
UnpackedDirectoryPathForPackage is similar to PackageMeta.UnpackedDirectoryPath but makes its decision based on individually-passed provider address, version, and target platform so that it can be used by callers outside this package that may have other types that represent package identifiers.
func VersionConstraintsString ¶
func VersionConstraintsString(spec VersionConstraints) string
VersionConstraintsString returns a canonical string representation of a VersionConstraints value.
Types ¶
type Hash ¶
type Hash string
Hash is a specially-formatted string representing a checksum of a package or the contents of the package.
A Hash string is always starts with a scheme, which is a short series of alphanumeric characters followed by a colon, and then the remainder of the string has a different meaning depending on the scheme prefix.
The currently-valid schemes are defined as the constants of type HashScheme in this package.
Callers outside of this package must not create Hash values via direct conversion. Instead, use either the HashScheme.New method on one of the HashScheme contents (for a hash of a particular scheme) or the ParseHash function (if hashes of any scheme are acceptable).
func HashLegacyZipSHAFromSHA ¶
HashLegacyZipSHAFromSHA is a convenience method to produce the schemed-string hash format from an already-calculated hash of a provider .zip archive.
This just adds the "zh:" prefix and encodes the string in hex, so that the result is in the same format as PackageHashLegacyZipSHA.
func MustParseHash ¶
MustParseHash is a wrapper around ParseHash that panics if it returns an error.
func PackageHash ¶
func PackageHash(loc PackageLocation) (Hash, error)
PackageHash computes a hash of the contents of the package at the given location, using whichever hash algorithm is the current default.
Currently, this method returns version 1 hashes as produced by the function PackageHashV1, but this function may switch to other versions in later releases. Call PackageHashV1 directly if you specifically need a V1 hash.
PackageHash can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func PackageHashLegacyZipSHA ¶
func PackageHashLegacyZipSHA(loc PackageLocalArchive) (Hash, error)
PackageHashLegacyZipSHA implements the old provider package hashing scheme of taking a SHA256 hash of the containing .zip archive itself, rather than of the contents of the archive.
The result is a hash string with the "zh:" prefix, which is intended to represent "zip hash". After the prefix is a lowercase-hex encoded SHA256 checksum, intended to exactly match the formatting used in the registry API (apart from the prefix) so that checksums can be more conveniently compared by humans.
Because this hashing scheme uses the official provider .zip file as its input, it accepts only PackageLocalArchive locations.
func PackageHashV1 ¶
func PackageHashV1(loc PackageLocation) (Hash, error)
PackageHashV1 computes a hash of the contents of the package at the given location using hash algorithm 1. The resulting Hash is guaranteed to have the scheme HashScheme1.
The hash covers the paths to files in the directory and the contents of those files. It does not cover other metadata about the files, such as permissions.
This function is named "PackageHashV1" in anticipation of other hashing algorithms being added in a backward-compatible way in future. The result from PackageHashV1 always begins with the prefix "h1:" so that callers can distinguish the results of potentially multiple different hash algorithms in future.
PackageHashV1 can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func ParseHash ¶
ParseHash parses the string representation of a Hash into a Hash value.
A particular version of Terraform only supports a fixed set of hash schemes, but this function intentionally allows unrecognized schemes so that we can silently ignore other schemes that may be introduced in the future. For that reason, the Scheme method of the returned Hash may return a value that isn't in one of the HashScheme constants in this package.
This function doesn't verify that the value portion of the given hash makes sense for the given scheme. Invalid values are just considered to not match any packages.
If this function returns an error then the returned Hash is invalid and must not be used.
func PreferredHashes ¶
PreferredHashes examines all of the given hash strings and returns the one that the current version of Terraform considers to provide the strongest verification.
Returns an empty string if none of the given hashes are of a supported format. If PreferredHash returns a non-empty string then it will be one of the hash strings in "given", and that hash is the one that must pass verification in order for a package to be considered valid.
func (Hash) GoString ¶
GoString returns a Go syntax representation of the receiving hash.
This is here primarily to help with producing descriptive test failure output; these results are not particularly useful at runtime.
func (Hash) HasScheme ¶
func (h Hash) HasScheme(want HashScheme) bool
HasScheme returns true if the given scheme matches the receiver's scheme, or false otherwise.
If the receiver is not using valid syntax then this method will panic.
func (Hash) Scheme ¶
func (h Hash) Scheme() HashScheme
Scheme returns the scheme of the recieving hash. If the receiver is not using valid syntax then this method will panic.
type HashScheme ¶
type HashScheme string
HashScheme is an enumeration of schemes that are allowed for values of type Hash.
const ( // HashScheme1 is the scheme identifier for the first hash scheme. // // Use HashV1 (or one of its wrapper functions) to calculate hashes with // this scheme. HashScheme1 HashScheme = HashScheme("h1:") // HashSchemeZip is the scheme identifier for the legacy hash scheme that // applies to distribution archives (.zip files) rather than package // contents, and can therefore only be verified against the original // distribution .zip file, not an extracted directory. // // Use PackageHashLegacyZipSHA to calculate hashes with this scheme. HashSchemeZip HashScheme = HashScheme("zh:") )
func (HashScheme) New ¶
func (hs HashScheme) New(value string) Hash
New creates a new Hash value with the receiver as its scheme and the given raw string as its value.
It's the caller's responsibility to make sure that the given value makes sense for the selected scheme.
type PackageAuthentication ¶
type PackageAuthentication interface {
// AuthenticatePackage takes the local location of a package (which may or
// may not be the same as the original source location), and returns a
// PackageAuthenticationResult, or an error if the authentication checks
// fail.
//
// The local location is guaranteed not to be a PackageHTTPURL: a remote
// package will always be staged locally for inspection first.
AuthenticatePackage(localLocation PackageLocation) (*PackageAuthenticationResult, error)
}
PackageAuthentication is an interface implemented by the optional package authentication implementations a source may include on its PackageMeta objects.
A PackageAuthentication implementation is responsible for authenticating that a package is what its distributor intended to distribute and that it has not been tampered with.
func NewArchiveChecksumAuthentication ¶
func NewArchiveChecksumAuthentication(platform Platform, wantSHA256Sum [sha256.Size]byte) PackageAuthentication
NewArchiveChecksumAuthentication returns a PackageAuthentication implementation that checks that the original distribution archive matches the given hash.
This authentication is suitable only for PackageHTTPURL and PackageLocalArchive source locations, because the unpacked layout (represented by PackageLocalDir) does not retain access to the original source archive. Therefore this authenticator will return an error if its given localLocation is not PackageLocalArchive.
NewPackageHashAuthentication is preferable to use when possible because it uses the newer hashing scheme (implemented by function PackageHash) that can work with both packed and unpacked provider packages.
func NewMatchingChecksumAuthentication ¶
func NewMatchingChecksumAuthentication(document []byte, filename string, wantSHA256Sum [sha256.Size]byte) PackageAuthentication
NewMatchingChecksumAuthentication returns a PackageAuthentication implementation that scans a registry-provided SHA256SUMS document for a specified filename, and compares the SHA256 hash against the expected hash. This is necessary to ensure that the signed SHA256SUMS document matches the declared SHA256 hash for the package, and therefore that a valid signature of this document authenticates the package.
This authentication always returns a nil result, since it alone cannot offer any assertions about package integrity. It should be combined with other authentications to be useful.
func NewPackageHashAuthentication ¶
func NewPackageHashAuthentication(platform Platform, validHashes []Hash) PackageAuthentication
NewPackageHashAuthentication returns a PackageAuthentication implementation that checks whether the contents of the package match whatever subset of the given hashes are considered acceptable by the current version of Terraform.
This uses the hash algorithms implemented by functions PackageHash and MatchesHash. The PreferredHashes function will select which of the given hashes are considered by Terraform to be the strongest verification, and authentication succeeds as long as one of those matches.
func NewSignatureAuthentication ¶
func NewSignatureAuthentication(document, signature []byte, keys []SigningKey) PackageAuthentication
NewSignatureAuthentication returns a PackageAuthentication implementation that verifies the cryptographic signature for a package against any of the provided keys.
The signing key for a package will be auto detected by attempting each key in turn until one is successful. If such a key is found, there are three possible successful authentication results:
- If the signing key is the HashiCorp official key, it is an official provider;
- Otherwise, if the signing key has a trust signature from the HashiCorp Partners key, it is a partner provider;
- If neither of the above is true, it is a community provider.
Any failure in the process of validating the signature will result in an unauthenticated result.
func PackageAuthenticationAll ¶
func PackageAuthenticationAll(checks ...PackageAuthentication) PackageAuthentication
PackageAuthenticationAll combines several authentications together into a single check value, which passes only if all of the given ones pass.
The checks are processed in the order given, so a failure of an earlier check will prevent execution of a later one.
The returned result is from the last authentication, so callers should take care to order the authentications such that the strongest is last.
The returned object also implements the AcceptableHashes method from interface PackageAuthenticationHashes, returning the hashes from the last of the given checks that indicates at least one acceptable hash, or no hashes at all if none of the constituents indicate any. The result may therefore be incomplete if there is more than one check that can provide hashes and they disagree about which hashes are acceptable.
type PackageAuthenticationHashes ¶
type PackageAuthenticationHashes interface {
PackageAuthentication
// AcceptableHashes returns a set of hashes that this authenticator
// considers to be valid for the current package or, where possible,
// equivalent packages on other platforms. The order of the items in
// the result is not significant, and it may contain duplicates
// that are also not significant.
//
// This method's result should only be used to create a "lock" for a
// particular provider if an earlier call to AuthenticatePackage for
// the corresponding package succeeded. A caller might choose to apply
// differing levels of trust for the acceptable hashes depending on
// the authentication result: a "verified checksum" result only checked
// that the downloaded package matched what the source claimed, which
// could be considered to be less trustworthy than a check that includes
// verifying a signature from the origin registry, depending on what the
// hashes are going to be used for.
//
// Implementations of PackageAuthenticationHashes may return multiple
// hashes with different schemes, which means that all of them are equally
// acceptable. Implementors may also return hashes that use schemes the
// current version of the authenticator would not allow but that could be
// accepted by other versions of Terraform, e.g. if a particular hash
// scheme has been deprecated.
//
// Authenticators that don't use hashes as their authentication procedure
// will either not implement this interface or will have an implementation
// that returns an empty result.
AcceptableHashes() []Hash
}
PackageAuthenticationHashes is an optional interface implemented by PackageAuthentication implementations that are able to return a set of hashes they would consider valid if a given PackageLocation referred to a package that matched that hash string.
This can be used to record a set of acceptable hashes for a particular package in a lock file so that future install operations can determine whether the package has changed since its initial installation.
type PackageAuthenticationResult ¶
type PackageAuthenticationResult struct {
KeyID string
// contains filtered or unexported fields
}
PackageAuthenticationResult is returned from a PackageAuthentication implementation. It is a mostly-opaque type intended for use in UI, which implements Stringer.
A failed PackageAuthentication attempt will return an "unauthenticated" result, which is represented by nil.
func (*PackageAuthenticationResult) SignedByAnyParty ¶
func (t *PackageAuthenticationResult) SignedByAnyParty() bool
SignedByAnyParty returns whether the package was authenticated as signed by either HashiCorp or by a third-party.
func (*PackageAuthenticationResult) SignedByHashiCorp ¶
func (t *PackageAuthenticationResult) SignedByHashiCorp() bool
SignedByHashiCorp returns whether the package was authenticated as signed by HashiCorp.
func (*PackageAuthenticationResult) String ¶
func (t *PackageAuthenticationResult) String() string
func (*PackageAuthenticationResult) ThirdPartySigned ¶
func (t *PackageAuthenticationResult) ThirdPartySigned() bool
ThirdPartySigned returns whether the package was authenticated as signed by a party other than HashiCorp.
type PackageHTTPURL ¶
type PackageHTTPURL string
PackageHTTPURL is a provider package location accessible via HTTP. Its value is a URL string using either the http: scheme or the https: scheme.
func (PackageHTTPURL) String ¶
func (p PackageHTTPURL) String() string
type PackageLocalArchive ¶
type PackageLocalArchive string
PackageLocalArchive is the location of a provider distribution archive file in the local filesystem. Its value is a local filesystem path using the syntax understood by Go's standard path/filepath package on the operating system where Terraform is running.
func (PackageLocalArchive) String ¶
func (p PackageLocalArchive) String() string
type PackageLocalDir ¶
type PackageLocalDir string
PackageLocalDir is the location of a directory containing an unpacked provider distribution archive in the local filesystem. Its value is a local filesystem path using the syntax understood by Go's standard path/filepath package on the operating system where Terraform is running.
func (PackageLocalDir) String ¶
func (p PackageLocalDir) String() string
type PackageLocation ¶
type PackageLocation interface {
String() string
// contains filtered or unexported methods
}
PackageLocation represents a location where a provider distribution package can be obtained. A value of this type contains one of the following concrete types: PackageLocalArchive, PackageLocalDir, or PackageHTTPURL.
type PackageMeta ¶
type PackageMeta struct {
Provider addrs.Provider
Version Version
ProtocolVersions VersionList
TargetPlatform Platform
Filename string
Location PackageLocation
// Authentication, if non-nil, is a request from the source that produced
// this meta for verification of the target package after it has been
// retrieved from the indicated Location.
//
// Different sources will support different authentication strategies --
// or possibly no strategies at all -- depending on what metadata they
// have available to them, such as checksums provided out-of-band by the
// original package author, expected signing keys, etc.
//
// If Authentication is non-nil then no authentication is requested.
// This is likely appropriate only for packages that are already available
// on the local system.
Authentication PackageAuthentication
}
PackageMeta represents the metadata related to a particular downloadable provider package targeting a single platform.
Package findproviders does no signature verification or protocol version compatibility checking of its own. A caller receving a PackageMeta must verify that it has a correct signature and supports a protocol version accepted by the current version of Terraform before trying to use the described package.
func (PackageMeta) AcceptableHashes ¶
func (m PackageMeta) AcceptableHashes() []Hash
AcceptableHashes returns a set of hashes that could be recorded for comparison to future results for the same provider version, to implement a "trust on first use" scheme.
The AcceptableHashes result is a platform-agnostic set of hashes, with the intent that in most cases it will be used as an additional cross-check in addition to a platform-specific hash check made during installation. However, there are some situations (such as verifying an already-installed package that's on local disk) where Terraform would check only against the results of this function, meaning that it would in principle accept another platform's package as a substitute for the correct platform. That's a pragmatic compromise to allow lock files derived from the result of this method to be portable across platforms.
Callers of this method should typically also verify the package using the object in the Authentication field, and consider how much trust to give the result of this method depending on the authentication result: an unauthenticated result or one that only verified a checksum could be considered less trustworthy than one that checked the package against a signature provided by the origin registry.
The AcceptableHashes result is actually provided by the object in the Authentication field. AcceptableHashes therefore returns an empty result for a PackageMeta that has no authentication object, or has one that does not make use of hashes.
func (PackageMeta) Hash ¶
func (m PackageMeta) Hash() (Hash, error)
Hash computes a hash of the contents of the package at the location associated with the reciever, using whichever hash algorithm is the current default.
This method will change to use new hash versions as they are introduced in future. If you need a specific hash version, call the method for that version directly instead, such as HashV1.
Hash can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func (PackageMeta) HashV1 ¶
func (m PackageMeta) HashV1() (Hash, error)
HashV1 computes a hash of the contents of the package at the location associated with the receiver using hash algorithm 1.
The hash covers the paths to files in the directory and the contents of those files. It does not cover other metadata about the files, such as permissions.
HashV1 can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func (PackageMeta) LessThan ¶
func (m PackageMeta) LessThan(other PackageMeta) bool
LessThan returns true if the receiver should sort before the given other PackageMeta in a sorted list of PackageMeta.
Sorting preference is given first to the provider address, then to the taget platform, and the to the version number (using semver precedence). Packages that differ only in semver build metadata have no defined precedence and so will always return false.
This ordering is primarily just to maximize the chance that results of functions in this package will be deterministic. The ordering is not intended to have any semantic meaning and is subject to change in future.
func (PackageMeta) MatchesAnyHash ¶
func (m PackageMeta) MatchesAnyHash(acceptable []Hash) (bool, error)
MatchesAnyHash returns true if the package at the location associated with the receiver matches at least one of the given hashes, or false otherwise.
If it cannot read from the given location, MatchesHash returns an error. Unlike the signular MatchesHash, MatchesAnyHash considers an unsupported hash format to be a successful non-match.
func (PackageMeta) MatchesHash ¶
func (m PackageMeta) MatchesHash(want Hash) (bool, error)
MatchesHash returns true if the package at the location associated with the receiver matches the given hash, or false otherwise.
If it cannot read from the given location, or if the given hash is in an unsupported format, MatchesHash returns an error.
MatchesHash can be used only with the two local package location types PackageLocalDir and PackageLocalArchive, because it needs to access the contents of the indicated package in order to compute the hash. If given a non-local location this function will always return an error.
func (PackageMeta) PackedFilePath ¶
func (m PackageMeta) PackedFilePath(baseDir string) string
PackedFilePath determines the path under the given base directory where SearchLocalDirectory or the FilesystemMirrorSource would expect to find packed copy (a .zip archive) of the receiving PackageMeta.
The result always uses forward slashes as path separator, even on Windows, to produce a consistent result on all platforms. Windows accepts both direction of slash as long as each individual path string is self-consistent.
func (PackageMeta) UnpackedDirectoryPath ¶
func (m PackageMeta) UnpackedDirectoryPath(baseDir string) string
UnpackedDirectoryPath determines the path under the given base directory where SearchLocalDirectory or the FilesystemMirrorSource would expect to find an unpacked copy of the receiving PackageMeta.
The result always uses forward slashes as path separator, even on Windows, to produce a consistent result on all platforms. Windows accepts both direction of slash as long as each individual path string is self-consistent.
type PackageMetaList ¶
type PackageMetaList []PackageMeta
PackageMetaList is a list of PackageMeta. It's just []PackageMeta with some methods for convenient sorting and filtering.
func (PackageMetaList) FilterPlatform ¶
func (l PackageMetaList) FilterPlatform(target Platform) PackageMetaList
FilterPlatform constructs a new PackageMetaList that contains only the elements of the receiver that are for the given target platform.
Pass CurrentPlatform to filter only for packages targeting the platform where this code is running.
func (PackageMetaList) FilterProviderExactVersion ¶
func (l PackageMetaList) FilterProviderExactVersion(provider addrs.Provider, version Version) PackageMetaList
FilterProviderExactVersion constructs a new PackageMetaList that contains only the elements of the receiver that relate to the given provider address and exact version.
The version matching for this function is exact, including matching on semver build metadata, because it's intended for handling a single exact version selected by the caller from a set of available versions.
func (PackageMetaList) FilterProviderPlatformExactVersion ¶
func (l PackageMetaList) FilterProviderPlatformExactVersion(provider addrs.Provider, platform Platform, version Version) PackageMetaList
FilterProviderPlatformExactVersion is a combination of both FilterPlatform and FilterProviderExactVersion that filters by all three criteria at once.
func (PackageMetaList) Len ¶
func (l PackageMetaList) Len() int
func (PackageMetaList) Less ¶
func (l PackageMetaList) Less(i, j int) bool
func (PackageMetaList) Sort ¶
func (l PackageMetaList) Sort()
Sort performs an in-place, stable sort on the contents of the list, using the ordering given by method Less. This ordering is primarily to help encourage deterministic results from functions and does not have any semantic meaning.
func (PackageMetaList) Swap ¶
func (l PackageMetaList) Swap(i, j int)
type Platform ¶
type Platform struct {
OS, Arch string
}
Platform represents a target platform that a provider is or might be available for.
func ParsePlatform ¶
ParsePlatform parses a string representation of a platform, like "linux_amd64", or returns an error if the string is not valid.
func (Platform) LessThan ¶
LessThan returns true if the receiver should sort before the other given Platform in an ordered list of platforms.
The ordering is lexical first by OS and then by Architecture. This ordering is primarily just to ensure that results of functions in this package will be deterministic. The ordering is not intended to have any semantic meaning and is subject to change in future.
type Requirements ¶
type Requirements map[addrs.Provider]VersionConstraints
Requirements gathers together requirements for many different providers into a single data structure, as a convenient way to represent the full set of requirements for a particular configuration or state or both.
If an entry in a Requirements has a zero-length VersionConstraints then that indicates that the provider is required but that any version is acceptable. That's different than a provider being absent from the map altogether, which means that it is not required at all.
func (Requirements) Merge ¶
func (r Requirements) Merge(other Requirements) Requirements
Merge takes the requirements in the receiever and the requirements in the other given value and produces a new set of requirements that combines all of the requirements of both.
The resulting requirements will permit only selections that both of the source requirements would've allowed.
type Selections ¶
Selections gathers together version selections for many different providers.
This is the result of provider installation: a specific version selected for each provider given in the requested Requirements, selected based on the given version constraints.
type SigningKey ¶
type SigningKey struct {
ASCIIArmor string `json:"ascii_armor"`
TrustSignature string `json:"trust_signature"`
}
SigningKey represents a key used to sign packages from a registry, along with an optional trust signature from the registry operator. These are both in ASCII armored OpenPGP format.
The JSON struct tags represent the field names used by the Registry API.
type Version ¶
Version represents a particular single version of a provider.
var UnspecifiedVersion Version = versions.Unspecified
UnspecifiedVersion is the zero value of Version, representing the absense of a version number.
func MustParseVersion ¶
MustParseVersion is a variant of ParseVersion that panics if it encounters an error while parsing.
func ParseVersion ¶
ParseVersion parses a "semver"-style version string into a Version value, which is the version syntax we use for provider versions.
type VersionConstraints ¶
type VersionConstraints = constraints.IntersectionSpec
VersionConstraints represents a set of version constraints, which can define the membership of a VersionSet by exclusion.
func MustParseVersionConstraints ¶
func MustParseVersionConstraints(str string) VersionConstraints
MustParseVersionConstraints is a variant of ParseVersionConstraints that panics if it encounters an error while parsing.
func ParseVersionConstraints ¶
func ParseVersionConstraints(str string) (VersionConstraints, error)
ParseVersionConstraints parses a "Ruby-like" version constraint string into a VersionConstraints value.
type VersionList ¶
VersionList represents a list of versions. It is a []Version with some extra methods for convenient filtering.
type VersionSet ¶
VersionSet represents a set of versions, usually describing the acceptable versions that can be selected under a particular version constraint provided by the end-user.
func MeetingConstraints ¶
func MeetingConstraints(vc VersionConstraints) VersionSet
MeetingConstraints returns a version set that contains all of the versions that meet the given constraints, specified using the Spec type from the constraints package.