mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
plugin: Display version + source when initializing plugins
This commit is contained in:
parent
b1e925e9d2
commit
28b33c9299
@ -75,6 +75,7 @@ func (c *InitCommand) Run(args []string) int {
|
||||
Dir: c.pluginDir(),
|
||||
PluginProtocolVersion: plugin.Handshake.ProtocolVersion,
|
||||
SkipVerify: !flagVerifyPlugins,
|
||||
Ui: c.Ui,
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,8 +311,12 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
|
||||
|
||||
var errs error
|
||||
if c.getPlugins {
|
||||
if len(missing) > 0 {
|
||||
c.Ui.Output(fmt.Sprintf(" - Checking for available provider plugins on %s...",
|
||||
discovery.GetReleaseHost()))
|
||||
}
|
||||
|
||||
for provider, reqd := range missing {
|
||||
c.Ui.Output(fmt.Sprintf("- Downloading plugin for provider %q...", provider))
|
||||
_, err := c.providerInstaller.Get(provider, reqd.Versions)
|
||||
|
||||
if err != nil {
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||
getter "github.com/hashicorp/go-getter"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// Releases are located by parsing the html listing from releases.hashicorp.com.
|
||||
@ -58,6 +59,8 @@ type ProviderInstaller struct {
|
||||
|
||||
// Skip checksum and signature verification
|
||||
SkipVerify bool
|
||||
|
||||
Ui cli.Ui // Ui for output
|
||||
}
|
||||
|
||||
// Get is part of an implementation of type Installer, and attempts to download
|
||||
@ -116,6 +119,7 @@ func (i *ProviderInstaller) Get(provider string, req Constraints) (PluginMeta, e
|
||||
|
||||
log.Printf("[DEBUG] fetching provider info for %s version %s", provider, v)
|
||||
if checkPlugin(url, i.PluginProtocolVersion) {
|
||||
i.Ui.Info(fmt.Sprintf("- Downloading plugin for provider %q (%s)...", provider, v.String()))
|
||||
log.Printf("[DEBUG] getting provider %q version %q at %s", provider, v, url)
|
||||
err := getter.Get(i.Dir, url)
|
||||
if err != nil {
|
||||
@ -422,3 +426,7 @@ func getFile(url string) ([]byte, error) {
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func GetReleaseHost() string {
|
||||
return releaseHost
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
const testProviderFile = "test provider binary"
|
||||
@ -149,6 +151,7 @@ func TestProviderInstallerGet(t *testing.T) {
|
||||
Dir: tmpDir,
|
||||
PluginProtocolVersion: 5,
|
||||
SkipVerify: true,
|
||||
Ui: cli.NewMockUi(),
|
||||
}
|
||||
_, err = i.Get("test", AllVersions)
|
||||
if err != ErrorNoVersionCompatible {
|
||||
@ -159,6 +162,7 @@ func TestProviderInstallerGet(t *testing.T) {
|
||||
Dir: tmpDir,
|
||||
PluginProtocolVersion: 3,
|
||||
SkipVerify: true,
|
||||
Ui: cli.NewMockUi(),
|
||||
}
|
||||
|
||||
{
|
||||
@ -230,6 +234,7 @@ func TestProviderInstallerPurgeUnused(t *testing.T) {
|
||||
Dir: tmpDir,
|
||||
PluginProtocolVersion: 3,
|
||||
SkipVerify: true,
|
||||
Ui: cli.NewMockUi(),
|
||||
}
|
||||
purged, err := i.PurgeUnused(map[string]PluginMeta{
|
||||
"test": PluginMeta{
|
||||
|
Loading…
Reference in New Issue
Block a user