Skip to content

Commit e12b256

Browse files
committed
feat!: removed configuration file and moved to conf via env vars
1 parent 627d7df commit e12b256

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

main.go

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
6-
"flag"
75
"os"
86

97
"github.com/robbert229/jaeger-postgresql/internal/sql"
@@ -15,41 +13,25 @@ import (
1513
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
1614
)
1715

18-
// Configuration is the main configuration struct for the github.com/robbert229/jaeger-postgresql plugin.
19-
type Configuration struct {
20-
DatabaseURL string `json:"database_url"`
21-
}
22-
2316
func main() {
2417
logger := hclog.New(&hclog.LoggerOptions{
25-
Name: "github.com/robbert229/jaeger-postgresql",
18+
Name: "jaeger-postgresql",
2619
Level: hclog.Warn, // Jaeger only captures >= Warn, so don't bother logging below Warn
2720
})
2821

29-
var configPath string
30-
flag.StringVar(&configPath, "config", "", "A path to the plugin's configuration file")
31-
flag.Parse()
32-
33-
var config Configuration
34-
configBytes, err := os.ReadFile(configPath)
35-
if err != nil {
36-
logger.Error("failed to read configuration file", "error", err)
37-
os.Exit(1)
38-
}
39-
40-
err = json.Unmarshal(configBytes, &config)
41-
if err != nil {
42-
logger.Error("failed to parse configuration", "error", err)
22+
databaseURL := os.Getenv("DATABASE_URL")
23+
if databaseURL == "" {
24+
logger.Error("invalid database url")
4325
os.Exit(1)
4426
}
4527

46-
err = sql.Migrate(logger, config.DatabaseURL)
28+
err := sql.Migrate(logger, databaseURL)
4729
if err != nil {
4830
logger.Error("failed to migrate database", "error", err)
4931
os.Exit(1)
5032
}
5133

52-
pgxconfig, err := pgxpool.ParseConfig(config.DatabaseURL)
34+
pgxconfig, err := pgxpool.ParseConfig(databaseURL)
5335
if err != nil {
5436
logger.Error("failed to parse database url", "error", err)
5537
os.Exit(1)

0 commit comments

Comments
 (0)