github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/meta_new.go (about) 1 package command 2 3 import ( 4 "os" 5 "strconv" 6 7 "github.com/hashicorp/terraform/internal/plans/planfile" 8 ) 9 10 // NOTE: Temporary file until this branch is cleaned up. 11 12 // Input returns whether or not input asking is enabled. 13 func (m *Meta) Input() bool { 14 if test || !m.input { 15 return false 16 } 17 18 if envVar := os.Getenv(InputModeEnvVar); envVar != "" { 19 if v, err := strconv.ParseBool(envVar); err == nil && !v { 20 return false 21 } 22 } 23 24 return true 25 } 26 27 // PlanFile returns a reader for the plan file at the given path. 28 // 29 // If the return value and error are both nil, the given path exists but seems 30 // to be a configuration directory instead. 31 // 32 // Error will be non-nil if path refers to something which looks like a plan 33 // file and loading the file fails. 34 func (m *Meta) PlanFile(path string) (*planfile.Reader, error) { 35 fi, err := os.Stat(path) 36 if err != nil { 37 return nil, err 38 } 39 40 if fi.IsDir() { 41 // Looks like a configuration directory. 42 return nil, nil 43 } 44 45 return planfile.Open(path) 46 }