internal/getproviders: Stub NetworkMirrorSource

This is a placeholder for later implementation of a mirror source that
talks to a particular remote HTTP server and expects it to implement the
provider mirror protocol.
This commit is contained in:
Martin Atkins 2020-04-21 16:26:43 -07:00
parent 2c535d829d
commit c5bd783eba
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package getproviders
import (
"fmt"
svchost "github.com/hashicorp/terraform-svchost"
"github.com/hashicorp/terraform/addrs"
)
// NetworkMirrorSource is a source that reads providers and their metadata
// from an HTTP server implementing the Terraform network mirror protocol.
type NetworkMirrorSource struct {
host svchost.Hostname
}
var _ Source = (*NetworkMirrorSource)(nil)
// NewNetworkMirrorSource constructs and returns a new network-based
// mirror source that will expect to find a mirror service on the given
// host.
func NewNetworkMirrorSource(host svchost.Hostname) *NetworkMirrorSource {
return &NetworkMirrorSource{
host: host,
}
}
// AvailableVersions retrieves the available versions for the given provider
// from the network mirror.
func (s *NetworkMirrorSource) AvailableVersions(provider addrs.Provider) (VersionList, error) {
return nil, fmt.Errorf("Network provider mirror is not supported in this version of Terraform")
}
// PackageMeta checks to see if the network mirror contains a copy of the
// distribution package for the given provider version on the given target,
// and returns the metadata about it if so.
func (s *NetworkMirrorSource) PackageMeta(provider addrs.Provider, version Version, target Platform) (PackageMeta, error) {
return PackageMeta{}, fmt.Errorf("Network provider mirror is not supported in this version of Terraform")
}