Skip to content

Commit dbe8886

Browse files
committed
Also check for terraform.tfstate in pwd
1 parent 47c0c9f commit dbe8886

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ func main() {
3030
file = os.Getenv("TI_TFSTATE")
3131
}
3232

33+
// check for a file named terraform.tfstate in the pwd
34+
if file == "" {
35+
fn := "terraform.tfstate"
36+
_, err := os.Stat(fn)
37+
if err == nil {
38+
file = fn
39+
}
40+
}
41+
3342
if file == "" {
3443
fmt.Printf("Usage: %s [options] path\n", os.Args[0])
3544
os.Exit(1)

parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var keyNames []string
1919
func init() {
2020
keyNames = []string{
2121
"ipv4_address", // DO
22-
"public_ip", // AWS
23-
"private_ip", // AWS
22+
"public_ip", // AWS
23+
"private_ip", // AWS
2424
}
2525
}
2626

@@ -76,7 +76,7 @@ func (s resourceState) isSupported() bool {
7676

7777
// Address returns the IP address of this resource.
7878
func (s resourceState) Address() string {
79-
for _, key := range(keyNames) {
79+
for _, key := range keyNames {
8080
if ip := s.Primary.Attributes[key]; ip != "" {
8181
return ip
8282
}

0 commit comments

Comments
 (0)