opentofu/command/hook_module_install.go
Martin Atkins fd5b7b42b8 command: new Meta methods for accessing the new config loader
We need to share a single config loader across all callers because that
allows us to maintain the source code cache we'll use for snippets in
error messages.

Nothing calls this yet. Callers will be gradually updated away from Module
and Config in subsequent commits.
2018-10-16 18:20:32 -07:00

34 lines
854 B
Go

package command
import (
"fmt"
version "github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/configs/configload"
"github.com/mitchellh/cli"
)
type uiModuleInstallHooks struct {
configload.InstallHooksImpl
Ui cli.Ui
ShowLocalPaths bool
}
var _ configload.InstallHooks = uiModuleInstallHooks{}
func (h uiModuleInstallHooks) Download(modulePath, packageAddr string, v *version.Version) {
if v != nil {
h.Ui.Info(fmt.Sprintf("Downloading %s %s for %s...", packageAddr, v, modulePath))
} else {
h.Ui.Info(fmt.Sprintf("Downloading %s for %s...", packageAddr, modulePath))
}
}
func (h uiModuleInstallHooks) Install(modulePath string, v *version.Version, localDir string) {
if h.ShowLocalPaths {
h.Ui.Info(fmt.Sprintf("- %s in %s", modulePath, localDir))
} else {
h.Ui.Info(fmt.Sprintf("- %s", modulePath))
}
}