Skip to content
Snippets Groups Projects
Commit b3ecabcc authored by gjahn's avatar gjahn
Browse files

Allow setting font color of landing page via environment variable

parent 09fd2dfb
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"unicode"
fp "path/filepath" fp "path/filepath"
configParser "github.com/caarlos0/env/v9" configParser "github.com/caarlos0/env/v9"
...@@ -18,6 +19,8 @@ var version string = "n/a" ...@@ -18,6 +19,8 @@ var version string = "n/a"
type Config struct { type Config struct {
Version string Version string
FontColor string `env:"FONT_COLOR" envDefault:""`
LogLevel string `env:"LOG_LEVE" envDefault:"error"` LogLevel string `env:"LOG_LEVE" envDefault:"error"`
Environment string `env:"ENV_NAME" envDefault:"development"` Environment string `env:"ENV_NAME" envDefault:"development"`
...@@ -65,7 +68,6 @@ func New() ( *Config, error ){ ...@@ -65,7 +68,6 @@ func New() ( *Config, error ){
) )
} }
if len( cfg.DatabaseHost ) >= 1 && len( cfg.DatabasePassword ) >= 2 { if len( cfg.DatabaseHost ) >= 1 && len( cfg.DatabasePassword ) >= 2 {
if ! fp.IsLocal( cfg.DatabasePassword ) && ! fp.IsAbs( cfg.DatabasePassword ) { if ! fp.IsLocal( cfg.DatabasePassword ) && ! fp.IsAbs( cfg.DatabasePassword ) {
return nil, errors.New( return nil, errors.New(
...@@ -85,6 +87,22 @@ func New() ( *Config, error ){ ...@@ -85,6 +87,22 @@ func New() ( *Config, error ){
} }
} }
if len( cfg.FontColor ) >= 1 {
if len( cfg.FontColor ) >= 21 {
return nil, errors.New(
fmt.Sprintln( "Font color too long" ),
)
}
for _, r := range cfg.FontColor {
if ! unicode.IsLetter( r ) {
return nil, errors.New(
fmt.Sprintln( "Invalid character in font color" ),
)
}
}
}
return &cfg, nil return &cfg, nil
} }
...@@ -48,7 +48,7 @@ func SetRoutes( router *f.App, config *configuration.Config, store state.Store, ...@@ -48,7 +48,7 @@ func SetRoutes( router *f.App, config *configuration.Config, store state.Store,
data := indexHtmlData{ data := indexHtmlData{
Version: config.Version, Version: config.Version,
Color: "", Color: config.FontColor,
} }
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment