mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-23 00:12:13 +01:00
Also check for terraform.tfstate in pwd
This commit is contained in:
parent
47c0c9f64c
commit
dbe88863eb
9
main.go
9
main.go
@ -30,6 +30,15 @@ func main() {
|
||||
file = os.Getenv("TI_TFSTATE")
|
||||
}
|
||||
|
||||
// check for a file named terraform.tfstate in the pwd
|
||||
if file == "" {
|
||||
fn := "terraform.tfstate"
|
||||
_, err := os.Stat(fn)
|
||||
if err == nil {
|
||||
file = fn
|
||||
}
|
||||
}
|
||||
|
||||
if file == "" {
|
||||
fmt.Printf("Usage: %s [options] path\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
|
@ -76,7 +76,7 @@ func (s resourceState) isSupported() bool {
|
||||
|
||||
// Address returns the IP address of this resource.
|
||||
func (s resourceState) Address() string {
|
||||
for _, key := range(keyNames) {
|
||||
for _, key := range keyNames {
|
||||
if ip := s.Primary.Attributes[key]; ip != "" {
|
||||
return ip
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user