github.com/opentofu/opentofu@v1.7.1/internal/initwd/module_install_hooks.go (about)

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