github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/initwd/module_install_hooks.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package initwd 5 6 import ( 7 version "github.com/hashicorp/go-version" 8 ) 9 10 // ModuleInstallHooks is an interface used to provide notifications about the 11 // installation process being orchestrated by InstallModules. 12 // 13 // This interface may have new methods added in future, so implementers should 14 // embed InstallHooksImpl to get no-op implementations of any unimplemented 15 // methods. 16 type ModuleInstallHooks interface { 17 // Download is called for modules that are retrieved from a remote source 18 // before that download begins, to allow a caller to give feedback 19 // on progress through a possibly-long sequence of downloads. 20 Download(moduleAddr, packageAddr string, version *version.Version) 21 22 // Install is called for each module that is installed, even if it did 23 // not need to be downloaded from a remote source. 24 Install(moduleAddr string, version *version.Version, localPath string) 25 } 26 27 // ModuleInstallHooksImpl is a do-nothing implementation of InstallHooks that 28 // can be embedded in another implementation struct to allow only partial 29 // implementation of the interface. 30 type ModuleInstallHooksImpl struct { 31 } 32 33 func (h ModuleInstallHooksImpl) Download(moduleAddr, packageAddr string, version *version.Version) { 34 } 35 36 func (h ModuleInstallHooksImpl) Install(moduleAddr string, version *version.Version, localPath string) { 37 } 38 39 var _ ModuleInstallHooks = ModuleInstallHooksImpl{}