Skip to content

Commit

Permalink
fix: required API details for snapshot-dump (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenorgate authored Jun 5, 2024
1 parent 2724112 commit ddb14ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cmd/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import (

func run(ctx context.Context) error {
cfg := config.Get()
if cfg.API.Key == "" {
return errors.New("env variable \"API_KEY\" is required")
}
if cfg.API.URL == "" {
return errors.New("env variable \"API_URL\" is required")
}

remoteLogger := logrus.New()
remoteLogger.SetLevel(logrus.Level(cfg.Log.Level))
Expand Down
7 changes: 7 additions & 0 deletions cmd/monitor/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package monitor

import (
"context"
"errors"
"fmt"

"github.com/sirupsen/logrus"
Expand All @@ -15,6 +16,12 @@ import (

func run(ctx context.Context) error {
cfg := config.Get()
if cfg.API.Key == "" {
return errors.New("env variable \"API_KEY\" is required")
}
if cfg.API.URL == "" {
return errors.New("env variable \"API_URL\" is required")
}

remoteLogger := logrus.New()
remoteLogger.SetLevel(logrus.Level(cfg.Log.Level))
Expand Down
7 changes: 0 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,6 @@ func Get() Config {
cfg.Log.ExporterSenderTimeout = LogExporterSendTimeout
}

if cfg.API.Key == "" {
required("API_KEY")
}
if cfg.API.URL == "" {
required("API_URL")
}

if !strings.HasPrefix(cfg.API.URL, "https://") && !strings.HasPrefix(cfg.API.URL, "http://") {
cfg.API.URL = fmt.Sprintf("https://%s", cfg.API.URL)
}
Expand Down

0 comments on commit ddb14ad

Please sign in to comment.