Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

Port can now be suplied by env var #3

Merged
merged 1 commit into from
Jun 22, 2017
Merged

Port can now be suplied by env var #3

merged 1 commit into from
Jun 22, 2017

Conversation

dgromov
Copy link
Contributor

@dgromov dgromov commented Jun 21, 2017

Things running in docker like to pass in ports to listen on. Adding this option.

@dgromov dgromov requested review from prateek and cw9 June 21, 2017 21:10
@coveralls
Copy link

Coverage Status

Coverage remained the same at 55.556% when pulling 8e33bb9cf83d01f4014fa10a400c1d3f799c0990 on port_by_env into 33570d8 on master.


if envPort != "" {
if p, err := strconv.Atoi(envPort); err == nil {
cfg.HTTP.Port = p
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log a message indicating you're overriding the config value with an env var

} else {
logger.Fatalf("%s (%s) is not a valid port number", envPort, portEnvVar)
}
} else {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be outside the else, i.e.

if envPort != "" {
  ... 
}

if cfg.HTTP.Port == 0 {
   ...
}

@@ -47,7 +55,7 @@ type serverConfig struct {
}

// NewHTTPServerOptions create a new set of http server options.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/New/new

@coveralls
Copy link

Coverage Status

Coverage remained the same at 55.556% when pulling 7734433 on port_by_env into 33570d8 on master.

Copy link

@prateek prateek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dgromov dgromov merged commit 00f02b4 into master Jun 22, 2017
@dgromov dgromov deleted the port_by_env branch June 22, 2017 17:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants