Skip to content

Commit

Permalink
Update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
t-persson committed Oct 23, 2024
1 parent f858232 commit 4f0128f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/configs/iut/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type Config interface {
ServiceHost() string
ServicePort() string
StripPrefix() string
LogLevel() string
LogFilePath() string
ETOSNamespace() string
Expand All @@ -35,6 +36,7 @@ type Config interface {
type cfg struct {
serviceHost string
servicePort string
stripPrefix string
logLevel string
logFilePath string
etosNamespace string
Expand All @@ -48,6 +50,7 @@ func Get() Config {

flag.StringVar(&conf.serviceHost, "address", EnvOrDefault("SERVICE_HOST", "127.0.0.1"), "Address to serve API on")
flag.StringVar(&conf.servicePort, "port", EnvOrDefault("SERVICE_PORT", "8080"), "Port to serve API on")
flag.StringVar(&conf.stripPrefix, "stripprefix", EnvOrDefault("STRIP_PREFIX", ""), "Strip a URL prefix. Useful when a reverse proxy sets a subpath. I.e. reverse proxy sets /stream as prefix, making the etos API available at /stream/v1/events. In that case we want to set stripprefix to /stream")
flag.StringVar(&conf.logLevel, "loglevel", EnvOrDefault("LOGLEVEL", "INFO"), "Log level (TRACE, DEBUG, INFO, WARNING, ERROR, FATAL, PANIC).")
flag.StringVar(&conf.logFilePath, "logfilepath", os.Getenv("LOG_FILE_PATH"), "Path, including filename, for the log files to create.")
flag.StringVar(&conf.databaseHost, "database_host", EnvOrDefault("ETOS_ETCD_HOST", "etcd-client"), "Host to ETOS database")
Expand All @@ -67,6 +70,11 @@ func (c *cfg) ServicePort() string {
return c.servicePort
}

// StripPrefix returns the prefix to strip. Empty string if no prefix.
func (c *cfg) StripPrefix() string {
return c.stripPrefix
}

// LogLevel returns the log level.
func (c *cfg) LogLevel() string {
return c.logLevel
Expand Down
8 changes: 8 additions & 0 deletions internal/configs/logarea/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type Config interface {
ServiceHost() string
ServicePort() string
StripPrefix() string
LogLevel() string
LogFilePath() string
ETOSNamespace() string
Expand All @@ -35,6 +36,7 @@ type Config interface {
type cfg struct {
serviceHost string
servicePort string
stripPrefix string
logLevel string
logFilePath string
etosNamespace string
Expand All @@ -48,6 +50,7 @@ func Get() Config {

flag.StringVar(&conf.serviceHost, "address", EnvOrDefault("SERVICE_HOST", "127.0.0.1"), "Address to serve API on")
flag.StringVar(&conf.servicePort, "port", EnvOrDefault("SERVICE_PORT", "8080"), "Port to serve API on")
flag.StringVar(&conf.stripPrefix, "stripprefix", EnvOrDefault("STRIP_PREFIX", ""), "Strip a URL prefix. Useful when a reverse proxy sets a subpath. I.e. reverse proxy sets /stream as prefix, making the etos API available at /stream/v1/events. In that case we want to set stripprefix to /stream")
flag.StringVar(&conf.logLevel, "loglevel", EnvOrDefault("LOGLEVEL", "INFO"), "Log level (TRACE, DEBUG, INFO, WARNING, ERROR, FATAL, PANIC).")
flag.StringVar(&conf.logFilePath, "logfilepath", os.Getenv("LOG_FILE_PATH"), "Path, including filename, for the log files to create.")
flag.StringVar(&conf.etosNamespace, "etosnamespace", ReadNamespaceOrEnv("ETOS_NAMESPACE"), "Path, including filename, for the log files to create.")
Expand All @@ -68,6 +71,11 @@ func (c *cfg) ServicePort() string {
return c.servicePort
}

// StripPrefix returns the prefix to strip. Empty string if no prefix.
func (c *cfg) StripPrefix() string {
return c.stripPrefix
}

// LogLevel returns the log level.
func (c *cfg) LogLevel() string {
return c.logLevel
Expand Down
8 changes: 8 additions & 0 deletions internal/configs/sse/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type Config interface {
ServiceHost() string
ServicePort() string
StripPrefix() string
LogLevel() string
LogFilePath() string
ETOSNamespace() string
Expand All @@ -35,6 +36,7 @@ type Config interface {
type cfg struct {
serviceHost string
servicePort string
stripPrefix string
logLevel string
logFilePath string
etosNamespace string
Expand All @@ -48,6 +50,7 @@ func Get() Config {

flag.StringVar(&conf.serviceHost, "address", EnvOrDefault("SERVICE_HOST", "127.0.0.1"), "Address to serve API on")
flag.StringVar(&conf.servicePort, "port", EnvOrDefault("SERVICE_PORT", "8080"), "Port to serve API on")
flag.StringVar(&conf.stripPrefix, "stripprefix", EnvOrDefault("STRIP_PREFIX", ""), "Strip a URL prefix. Useful when a reverse proxy sets a subpath. I.e. reverse proxy sets /stream as prefix, making the etos API available at /stream/v1/events. In that case we want to set stripprefix to /stream")
flag.StringVar(&conf.logLevel, "loglevel", EnvOrDefault("LOGLEVEL", "INFO"), "Log level (TRACE, DEBUG, INFO, WARNING, ERROR, FATAL, PANIC).")
flag.StringVar(&conf.logFilePath, "logfilepath", os.Getenv("LOG_FILE_PATH"), "Path, including filename, for the log files to create.")
flag.StringVar(&conf.etosNamespace, "etosnamespace", ReadNamespaceOrEnv("ETOS_NAMESPACE"), "Path, including filename, for the log files to create.")
Expand All @@ -68,6 +71,11 @@ func (c *cfg) ServicePort() string {
return c.servicePort
}

// StripPrefix returns the prefix to strip. Empty string if no prefix.
func (c *cfg) StripPrefix() string {
return c.stripPrefix
}

// LogLevel returns the log level.
func (c *cfg) LogLevel() string {
return c.logLevel
Expand Down

0 comments on commit 4f0128f

Please sign in to comment.