Skip to content
Permalink
Browse files

standardize on env var name

  • Loading branch information...
sqs committed Jul 26, 2015
1 parent c12f36f commit 175a8be170fffcc1046d95bbd20fc2ef28eab01c
Showing with 5 additions and 5 deletions.
  1. +1 −1 cmd/papertrail-go/papertrail-go.go
  2. +1 −1 papertrail/example_test.go
  3. +3 −3 papertrail/token.go
@@ -37,7 +37,7 @@ func main() {

token, err := papertrail.ReadToken()
if err == papertrail.ErrNoTokenFound {
log.Fatal("No Papertrail API token found; exiting.\n\npapertrail-go requires a valid Papertrail API token (which you can obtain from https://papertrailapp.com/user/edit) to be set in the PAPERTRAIL_TOKEN environment variable or in ~/.papertrail.yml (in the format `token: MYTOKEN`).")
log.Fatal("No Papertrail API token found; exiting.\n\npapertrail-go requires a valid Papertrail API token (which you can obtain from https://papertrailapp.com/user/edit) to be set in the PAPERTRAIL_API_TOKEN environment variable or in ~/.papertrail.yml (in the format `token: MYTOKEN`).")
} else if err != nil {
log.Fatal(err)
}
@@ -8,7 +8,7 @@ import (
func ExampleSearch() {
token, err := ReadToken()
if err == ErrNoTokenFound {
fmt.Println("ExampleSearch requires a valid Papertrail API token (which you can obtain from https://papertrailapp.com/user/edit) to be set in the PAPERTRAIL_TOKEN environment variable or in ~/.papertrail.yml (in the format `token: MYTOKEN`). None found; skipping.")
fmt.Println("ExampleSearch requires a valid Papertrail API token (which you can obtain from https://papertrailapp.com/user/edit) to be set in the PAPERTRAIL_API_TOKEN environment variable or in ~/.papertrail.yml (in the format `token: MYTOKEN`). None found; skipping.")
return
} else if err != nil {
log.Fatal(err)
@@ -8,15 +8,15 @@ import (
"path/filepath"
)

var ErrNoTokenFound = errors.New("no Papertrail API token found in PAPERTRAIL_TOKEN or ~/.papertrail.yml")
var ErrNoTokenFound = errors.New("no Papertrail API token found in PAPERTRAIL_API_TOKEN or ~/.papertrail.yml")

// ReadToken attempts to read the Papertrail API token from 2 sources, the
// PAPERTRAIL_TOKEN environment variable and the ~/.papertrail.yml file, in that
// PAPERTRAIL_API_TOKEN environment variable and the ~/.papertrail.yml file, in that
// order. It returns the token if found in either source, and otherwise returns
// ErrNoTokenFound. If an unexpected error occurs (e.g., while reading the
// config file), it returns that error.
func ReadToken() (string, error) {
t := os.Getenv("PAPERTRAIL_TOKEN")
t := os.Getenv("PAPERTRAIL_API_TOKEN")
if t != "" {
return t, nil
}

0 comments on commit 175a8be

Please sign in to comment.
You can’t perform that action at this time.