Skip to content

Commit

Permalink
fix: fix logic to detect GCP in log
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Feb 6, 2024
1 parent 56c43c2 commit 13a660b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions log/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
)

var GCP = false
var GCPEnv = "GOOGLE_CLOUD_PROJECT"
var GCPEnv = []string{
"CLOUD_RUN_JOB",
"K_SERVICE",
"GOOGLE_CLOUD_PROJECT",
}

type severity string

Expand Down Expand Up @@ -55,6 +59,11 @@ func isGCP() bool {
return true
}

gcp, _ := os.LookupEnv(GCPEnv)
return gcp != ""
for _, key := range GCPEnv {
if v, ok := os.LookupEnv(key); ok && v != "" {
return true
}
}

return false
}

0 comments on commit 13a660b

Please sign in to comment.