Skip to content

Commit

Permalink
Use godotenv to load .env for development
Browse files Browse the repository at this point in the history
  • Loading branch information
metalmatze committed Dec 15, 2016
1 parent fbaab3c commit 8712535
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .env.example
@@ -0,0 +1,5 @@
TRANSMISSION_ADDR=http://localhost:9091
TRANSMISSION_PASSWORD=
TRANSMISSION_USERNAME=
WEB_ADDR=:19091
WEB_PATH=/metrics
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/.env
/transmission-exporter

*.o
Expand Down
14 changes: 8 additions & 6 deletions README.md
Expand Up @@ -19,12 +19,6 @@ ENV Variable | Description
| TRANSMISSION_USERNAME | Transmission username, no default |
| TRANSMISSION_PASSWORD | Transmission password, no default |

### Build

make

For development we encourage you to use `make install` instead, it's faster.

### Docker

docker pull metalmatze/transmission-exporter
Expand All @@ -49,6 +43,14 @@ Example `docker-compose.yml` with Transmission also running in docker.
environment:
TRANSMISSION_ADDR: http://transmission:9091

### Development

make

For development we encourage you to use `make install` instead, it's faster.

Now simply copy the `.env.example` to `.env`, like `cp .env.example .env` and set your preferences.
Now you're good to go.

### Original authors of the Transmission package
Tobias Blom (https://github.com/tubbebubbe/transmission)
Expand Down
6 changes: 6 additions & 0 deletions cmd/transmission-exporter/main.go
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

arg "github.com/alexflint/go-arg"
"github.com/joho/godotenv"
transmission "github.com/metalmatze/transmission-exporter"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -21,6 +22,11 @@ type Config struct {
func main() {
log.Println("starting transmission-exporter")

err := godotenv.Load()
if err != nil {
log.Println("no .env present")
}

c := Config{
WebPath: "/metrics",
WebAddr: ":19091",
Expand Down

0 comments on commit 8712535

Please sign in to comment.