Documentation
¶
Index ¶
- func ProviderIsLockable(addr addrs.Provider) bool
- type Locks
- func (l *Locks) AllProviders() map[addrs.Provider]*ProviderLock
- func (l *Locks) DeepCopy() *Locks
- func (l *Locks) Empty() bool
- func (l *Locks) Equal(other *Locks) bool
- func (l *Locks) EqualProviderAddress(other *Locks) bool
- func (l *Locks) Provider(addr addrs.Provider) *ProviderLock
- func (l *Locks) SetProvider(addr addrs.Provider, version getproviders.Version, ...) *ProviderLock
- func (l *Locks) Sources() map[string][]byte
- type ProviderLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProviderIsLockable ¶
ProviderIsLockable returns true if the given provider is eligible for version locking.
Currently, all providers except builtin and legacy providers are eligible for locking.
Types ¶
type Locks ¶
type Locks struct {
// contains filtered or unexported fields
}
Locks is the top-level type representing the information retained in a dependency lock file.
Locks and the other types used within it are mutable via various setter methods, but they are not safe for concurrent modifications, so it's the caller's responsibility to prevent concurrent writes and writes concurrent with reads.
func NewLocks ¶
func NewLocks() *Locks
NewLocks constructs and returns a new Locks object that initially contains no locks at all.
func (*Locks) AllProviders ¶
func (l *Locks) AllProviders() map[addrs.Provider]*ProviderLock
AllProviders returns a map describing all of the provider locks in the receiver.
func (*Locks) DeepCopy ¶
DeepCopy creates a new Locks that represents the same information as the receiver but does not share memory for any parts of the structure that. are mutable through methods on Locks.
Note that this does _not_ create deep copies of parts of the structure that are technically mutable but are immutable by convention, such as the array underlying the slice of version constraints. Callers may mutate the resulting data structure only via the direct methods of Locks.
func (*Locks) Empty ¶
Empty returns true if the given Locks object contains no actual locks.
UI code might wish to use this to distinguish a lock file being written for the first time from subsequent updates to that lock file.
func (*Locks) Equal ¶
Equal returns true if the given Locks represents the same information as the receiver.
Equal explicitly _does not_ consider the equality of version constraints in the saved locks, because those are saved only as hints to help the UI explain what's changed between runs, and are never used as part of dependency installation decisions.
func (*Locks) EqualProviderAddress ¶
EqualProviderAddress returns true if the given Locks have the same provider address as the receiver. This doesn't check version and hashes.
func (*Locks) Provider ¶
func (l *Locks) Provider(addr addrs.Provider) *ProviderLock
Provider returns the stored lock for the given provider, or nil if that provider currently has no lock.
func (*Locks) SetProvider ¶
func (l *Locks) SetProvider(addr addrs.Provider, version getproviders.Version, constraints getproviders.VersionConstraints, hashes []getproviders.Hash) *ProviderLock
SetProvider creates a new lock or replaces the existing lock for the given provider.
SetProvider returns the newly-created provider lock object, which invalidates any ProviderLock object previously returned from Provider or SetProvider for the given provider address.
The ownership of the backing array for the slice of hashes passes to this function, and so the caller must not read or write that backing array after calling SetProvider.
Only lockable providers can be passed to this method. If you pass a non-lockable provider address then this function will panic. Use function ProviderIsLockable to determine whether a particular provider should participate in the version locking mechanism.
func (*Locks) Sources ¶
Sources returns the source code of the file the receiver was generated from, or an empty map if the receiver wasn't generated from a file.
This return type matches the one expected by HCL diagnostics printers to produce source code snapshots, which is the only intended use for this method.
type ProviderLock ¶
type ProviderLock struct {
// contains filtered or unexported fields
}
ProviderLock represents lock information for a specific provider.
func NewProviderLock ¶
func NewProviderLock(addr addrs.Provider, version getproviders.Version, constraints getproviders.VersionConstraints, hashes []getproviders.Hash) *ProviderLock
NewProviderLock creates a new ProviderLock object that isn't associated with any Locks object.
This is here primarily for testing. Most callers should use Locks.SetProvider to construct a new provider lock and insert it into a Locks object at the same time.
The ownership of the backing array for the slice of hashes passes to this function, and so the caller must not read or write that backing array after calling NewProviderLock.
Only lockable providers can be passed to this method. If you pass a non-lockable provider address then this function will panic. Use function ProviderIsLockable to determine whether a particular provider should participate in the version locking mechanism.
func (*ProviderLock) AllHashes ¶
func (l *ProviderLock) AllHashes() []getproviders.Hash
AllHashes returns all of the package hashes that were recorded when this lock was created. If no hashes were recorded for that platform, the result is a zero-length slice.
If your intent is to verify a package against the recorded hashes, use PreferredHashes to get only the hashes which the current version of Terraform considers the strongest of the available hashing schemes, one of which must match in order for verification to be considered successful.
Do not modify the backing array of the returned slice.
func (*ProviderLock) PreferredHashes ¶
func (l *ProviderLock) PreferredHashes() []getproviders.Hash
PreferredHashes returns a filtered version of the AllHashes return value which includes only the strongest of the availabile hash schemes, in case legacy hash schemes are deprecated over time but still supported for upgrade purposes.
At least one of the given hashes must match for a package to be considered valud.
func (*ProviderLock) Provider ¶
func (l *ProviderLock) Provider() addrs.Provider
Provider returns the address of the provider this lock applies to.
func (*ProviderLock) Version ¶
func (l *ProviderLock) Version() getproviders.Version
Version returns the currently-selected version for the corresponding provider.
func (*ProviderLock) VersionConstraints ¶
func (l *ProviderLock) VersionConstraints() getproviders.VersionConstraints
VersionConstraints returns the version constraints that were recorded as being used to choose the version returned by Version.
These version constraints are not authoritative for future selections and are included only so Terraform can detect if the constraints in configuration have changed since a selection was made, and thus hint to the user that they may need to run terraform init -upgrade to apply the new constraints.