blob: 3fd5fb774c57f0325e72471a6d636e2f58379c12 [file] [edit]
// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1
package initwd
import (
"context"
version "github.com/hashicorp/go-version"
"github.com/hashicorp/terraform/internal/configs"
"github.com/hashicorp/terraform/internal/tfdiags"
)
// ModuleInstallHook is an interface used to provide notifications about the
// installation process being orchestrated by InstallModules.
//
// This interface may have new methods added in future, so implementers should
// embed InstallHooksImpl to get no-op implementations of any unimplemented
// methods.
type ModuleInstallHook interface {
// ModuleSourceResolved is called after the installer has resolved the
// source and, if applicable, version for a module, before installation
// proceeds.
ModuleSourceResolved(ctx context.Context, req *configs.ModuleRequest, version string) tfdiags.Diagnostics
// Download is called for modules that are retrieved from a remote source
// before that download begins, to allow a caller to give feedback
// on progress through a possibly-long sequence of downloads.
Download(moduleAddr, packageAddr string, version *version.Version)
// Install is called for each module that is installed, even if it did
// not need to be downloaded from a remote source.
Install(moduleAddr string, version *version.Version, localPath string)
}
// ModuleInstallHookImpl is a do-nothing implementation of InstallHooks that
// can be embedded in another implementation struct to allow only partial
// implementation of the interface.
type ModuleInstallHookImpl struct {
}
func (h ModuleInstallHookImpl) Download(moduleAddr, packageAddr string, version *version.Version) {
}
func (h ModuleInstallHookImpl) Install(moduleAddr string, version *version.Version, localPath string) {
}
func (h ModuleInstallHookImpl) ModuleSourceResolved(ctx context.Context, req *configs.ModuleRequest, version string) tfdiags.Diagnostics {
return nil
}
var _ ModuleInstallHook = ModuleInstallHookImpl{}