Skip to content

Commit

Permalink
Merge pull request #125 from launchdarkly/eb/ch81724/refactor-config
Browse files Browse the repository at this point in the history
(v6 - #3) move config types into new package, refactor, better separation from internal types
  • Loading branch information
eli-darkly authored Jul 9, 2020
2 parents d99047e + 684b4ac commit 6688274
Show file tree
Hide file tree
Showing 18 changed files with 667 additions and 633 deletions.
9 changes: 5 additions & 4 deletions cmd/ld-relay/ld-relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
_ "github.com/kardianos/minwinsvc"

relay "github.com/launchdarkly/ld-relay/v6"
"github.com/launchdarkly/ld-relay/v6/config"
"github.com/launchdarkly/ld-relay/v6/internal/version"
"github.com/launchdarkly/ld-relay/v6/logging"
)
Expand All @@ -33,7 +34,7 @@ func main() {
flag.BoolVar(&useEnvironment, "from-env", false, "read configuration from environment variables")
flag.Parse()

c := relay.DefaultConfig
c := config.DefaultConfig

if configFile == "" && !useEnvironment {
configFile = defaultConfigPath
Expand All @@ -58,12 +59,12 @@ func main() {
logging.GlobalLoggers.Infof("Starting LaunchDarkly relay version %s with %s\n", formatVersion(version.Version), configDesc)

if configFile != "" {
if err := relay.LoadConfigFile(&c, configFile); err != nil {
if err := config.LoadConfigFile(&c, configFile); err != nil {
log.Fatalf("Error loading config file: %s", err)
}
}
if useEnvironment {
if err := relay.LoadConfigFromEnvironment(&c); err != nil {
if err := config.LoadConfigFromEnvironment(&c); err != nil {
log.Fatalf("Configuration error: %s", err)
}
}
Expand Down Expand Up @@ -94,7 +95,7 @@ func main() {

}

func startHTTPServer(c *relay.Config, r *relay.Relay, errs chan<- error) {
func startHTTPServer(c *config.Config, r *relay.Relay, errs chan<- error) {
srv := &http.Server{
Addr: fmt.Sprintf(":%d", c.Main.Port),
Handler: r,
Expand Down
Loading

0 comments on commit 6688274

Please sign in to comment.