github.com/arvindram03/terraform@v0.3.7-0.20150212015210-408f838db36d/config/module/storage.go (about)

     1  package module
     2  
     3  // Storage is an interface that knows how to lookup downloaded modules
     4  // as well as download and update modules from their sources into the
     5  // proper location.
     6  type Storage interface {
     7  	// Dir returns the directory on local disk where the modulue source
     8  	// can be loaded from.
     9  	Dir(string) (string, bool, error)
    10  
    11  	// Get will download and optionally update the given module.
    12  	Get(string, bool) error
    13  }
    14  
    15  func getStorage(s Storage, src string, mode GetMode) (string, bool, error) {
    16  	// Get the module with the level specified if we were told to.
    17  	if mode > GetModeNone {
    18  		if err := s.Get(src, mode == GetModeUpdate); err != nil {
    19  			return "", false, err
    20  		}
    21  	}
    22  
    23  	// Get the directory where the module is.
    24  	return s.Dir(src)
    25  }