From 4f0128f8ad2f95056a60348fd674353e1964fe33 Mon Sep 17 00:00:00 2001 From: Tobias Persson Date: Wed, 23 Oct 2024 09:46:35 +0200 Subject: [PATCH] Update configs --- internal/configs/iut/config.go | 8 ++++++++ internal/configs/logarea/config.go | 8 ++++++++ internal/configs/sse/config.go | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/internal/configs/iut/config.go b/internal/configs/iut/config.go index 4b8fb0b..b945115 100644 --- a/internal/configs/iut/config.go +++ b/internal/configs/iut/config.go @@ -25,6 +25,7 @@ import ( type Config interface { ServiceHost() string ServicePort() string + StripPrefix() string LogLevel() string LogFilePath() string ETOSNamespace() string @@ -35,6 +36,7 @@ type Config interface { type cfg struct { serviceHost string servicePort string + stripPrefix string logLevel string logFilePath string etosNamespace string @@ -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") @@ -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 diff --git a/internal/configs/logarea/config.go b/internal/configs/logarea/config.go index 36c5f67..316f5da 100644 --- a/internal/configs/logarea/config.go +++ b/internal/configs/logarea/config.go @@ -25,6 +25,7 @@ import ( type Config interface { ServiceHost() string ServicePort() string + StripPrefix() string LogLevel() string LogFilePath() string ETOSNamespace() string @@ -35,6 +36,7 @@ type Config interface { type cfg struct { serviceHost string servicePort string + stripPrefix string logLevel string logFilePath string etosNamespace string @@ -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.") @@ -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 diff --git a/internal/configs/sse/config.go b/internal/configs/sse/config.go index 36c5f67..316f5da 100644 --- a/internal/configs/sse/config.go +++ b/internal/configs/sse/config.go @@ -25,6 +25,7 @@ import ( type Config interface { ServiceHost() string ServicePort() string + StripPrefix() string LogLevel() string LogFilePath() string ETOSNamespace() string @@ -35,6 +36,7 @@ type Config interface { type cfg struct { serviceHost string servicePort string + stripPrefix string logLevel string logFilePath string etosNamespace string @@ -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.") @@ -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