github.com/arvindram03/terraform@v0.3.7-0.20150212015210-408f838db36d/config/module/detect_file.go (about) 1 package module 2 3 import ( 4 "fmt" 5 "path/filepath" 6 ) 7 8 // FileDetector implements Detector to detect file paths. 9 type FileDetector struct{} 10 11 func (d *FileDetector) Detect(src, pwd string) (string, bool, error) { 12 if len(src) == 0 { 13 return "", false, nil 14 } 15 16 if !filepath.IsAbs(src) { 17 if pwd == "" { 18 return "", true, fmt.Errorf( 19 "relative paths require a module with a pwd") 20 } 21 22 src = filepath.Join(pwd, src) 23 } 24 return fmtFileURL(src), true, nil 25 }