internal/getproviders: Exit early if MultiSource has no sources

The MultiSource isn't actually properly implemented yet, but this is a
minimal implementation just for the case where there are no underlying
sources at all, because we use an empty MultiSource as a placeholder
when a test in the "command" package fails to explicitly populate a
ProviderSource.
This commit is contained in:
Martin Atkins 2020-03-13 16:14:41 -07:00
parent 18dd0a396d
commit e4d7a71d91
1 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,10 @@ var _ Source = MultiSource(nil)
// that are available across all of the underlying selectors, while respecting
// each selector's matching patterns.
func (s MultiSource) AvailableVersions(provider addrs.Provider) (VersionList, error) {
if len(s) == 0 { // Easy case: there can be no available versions
return nil, nil
}
// TODO: Implement
panic("MultiSource.AvailableVersions not yet implemented")
}
@ -37,6 +41,10 @@ func (s MultiSource) AvailableVersions(provider addrs.Provider) (VersionList, er
// PackageMeta retrieves the package metadata for the given provider from the
// first selector that indicates support for it.
func (s MultiSource) PackageMeta(provider addrs.Provider, version Version, target Platform) (PackageMeta, error) {
if len(s) == 0 { // Easy case: no providers exist at all
return PackageMeta{}, ErrProviderNotKnown{provider}
}
// TODO: Implement
panic("MultiSource.PackageMeta not yet implemented")
}