1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-22 20:01:58 +01:00
terraform-inventory/input.go
Husayn Arrah 313d404eb3 Add support for remote state (#60)
* add support for remote state in version 0.9
* remove .terraform/terraform.tfstate as a source
2017-06-09 15:25:34 -04:00

30 lines
372 B
Go

package main
import (
"github.com/adammck/venv"
"github.com/blang/vfs"
)
func GetInputPath(fs vfs.Filesystem, env venv.Env) string {
var fn string
fn = env.Getenv("TF_STATE")
if fn != "" {
return fn
}
fn = env.Getenv("TI_TFSTATE")
if fn != "" {
return fn
}
fn = "terraform.tfstate"
_, err := fs.Stat(fn)
if err == nil {
return fn
}
return "."
}