From 3078d21c5f2e12d38ff0b36189f2c142e10cf100 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 20 Feb 2020 17:53:11 -0800 Subject: [PATCH] internal/getproviders: Include Provider and Version in PackageMeta Although we tend to return these in contexts where at least one of these values is implied, being explicit means that PackageMeta values are self-contained and less reliant on such external context. --- internal/getproviders/registry_client.go | 2 ++ internal/getproviders/registry_source_test.go | 4 ++++ internal/getproviders/types.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/internal/getproviders/registry_client.go b/internal/getproviders/registry_client.go index 6b5be18c02..a1d1532d71 100644 --- a/internal/getproviders/registry_client.go +++ b/internal/getproviders/registry_client.go @@ -211,6 +211,8 @@ func (c *registryClient) PackageMeta(provider addrs.Provider, version Version, t } ret := PackageMeta{ + Provider: provider, + Version: version, ProtocolVersions: protoVersions, TargetPlatform: Platform{ OS: body.OS, diff --git a/internal/getproviders/registry_source_test.go b/internal/getproviders/registry_source_test.go index 0d5efab488..5de161e7b1 100644 --- a/internal/getproviders/registry_source_test.go +++ b/internal/getproviders/registry_source_test.go @@ -117,6 +117,10 @@ func TestSourcePackageMeta(t *testing.T) { "1.2.0", "linux", "amd64", PackageMeta{ + Provider: addrs.NewProvider( + svchost.Hostname("example.com"), "awesomesauce", "happycloud", + ), + Version: versions.MustParseVersion("1.2.0"), ProtocolVersions: VersionList{versions.MustParseVersion("5.0.0")}, TargetPlatform: Platform{"linux", "amd64"}, Filename: "happycloud_1.2.0.zip", diff --git a/internal/getproviders/types.go b/internal/getproviders/types.go index 3cfce0c125..83515173b1 100644 --- a/internal/getproviders/types.go +++ b/internal/getproviders/types.go @@ -48,6 +48,9 @@ var CurrentPlatform = Platform{ // accepted by the current version of Terraform before trying to use the // described package. type PackageMeta struct { + Provider addrs.Provider + Version Version + ProtocolVersions VersionList TargetPlatform Platform