-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from oleg-balunenko/envvarconfig
Env var config
- Loading branch information
Showing
11 changed files
with
39 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SCRUM_REPORT_PORT=8080 | ||
SCRUM_REPORT_LOG_LEVEL=INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
) | ||
|
||
// Config stores configuration for service. | ||
type Config struct { | ||
LogLevel string | ||
Port string | ||
Host string | ||
Debug bool | ||
OpenBrowser bool | ||
LogLevel string | ||
Port string | ||
} | ||
|
||
// Load configuration from flags. | ||
func Load() *Config { | ||
func Load() Config { | ||
var c Config | ||
|
||
flag.StringVar(&c.Host, "host_address", "127.0.0.1", "address of host") | ||
flag.StringVar(&c.Port, "listen_port", "8080", "listen port") | ||
flag.StringVar(&c.LogLevel, "log_level", "INFO", "log level") | ||
flag.BoolVar(&c.Debug, "debug", false, `Run debug mode - use real ip machine instead localhost | ||
to possible to debug with Charles`) | ||
flag.BoolVar(&c.OpenBrowser, "open_browser", false, "open browser after start on index page") | ||
c.Port = getStringOrDefault("SCRUM_REPORT_PORT", "8080") | ||
c.LogLevel = getStringOrDefault("SCRUM_REPORT_LOG_LEVEL", "INFO") | ||
|
||
flag.Parse() | ||
return c | ||
} | ||
|
||
func getStringOrDefault(key string, defVal string) string { | ||
val, ok := os.LookupEnv(key) | ||
if !ok || val == "" { | ||
return defVal | ||
} | ||
|
||
return &c | ||
return val | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Package web handles generated static. | ||
// To update views - add changes to template htmls and run go generate. | ||
package web | ||
|
||
//go:generate go-bindata -pkg=web templates/ |