Skip to content

Commit

Permalink
update env checks to work nicely in a service runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispatrick committed Mar 6, 2024
1 parent eff94f6 commit b31caad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions policy/storage/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package storage
import (
"context"
"net/http"
"os"

"github.com/atomist-skills/go-skill/policy/goals"
"github.com/atomist-skills/go-skill/util"
Expand All @@ -14,6 +15,11 @@ import (
)

func getBucketName() string {
bucket := os.Getenv("POLICY_STORAGE_BUCKET")
if bucket != "" {
return bucket
}

if util.IsStaging() {
return "atm-policy-evaluation-results-staging"
}
Expand Down
5 changes: 5 additions & 0 deletions util/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
// Return whether the skill runs on staging or not, using the same logic as the TypeScript code.
// ref: https://github.com/atomist-skills/skill/blob/21696f154efded41f4cb98eb0e6951ab81839b8c/lib/util.ts#L235-L240
func IsStaging() bool {
environment, found := os.LookupEnv("SKILL_ENVIRONMENT")
if found {
return environment == "staging"
}

url, found := os.LookupEnv("ATOMIST_GRAPHQL_ENDPOINT")
if !found {
url = "https://automation.atomist.com/graphql"
Expand Down

0 comments on commit b31caad

Please sign in to comment.