-
Notifications
You must be signed in to change notification settings - Fork 41
/
branding.go
47 lines (39 loc) · 1.13 KB
/
branding.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package tools
import (
"fmt"
"github.com/spf13/viper"
)
var BrandingCfg Branding
type Branding struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
}
// getDefaultBranding returns the struct branding with default values
func getDefaultBranding() Branding {
return Branding{
Title: "TUM-Live",
Description: "TUM-Live, the livestreaming and VoD service of the " +
"Rechnerbetriebsgruppe at the department of informatics and " +
"mathematics at the Technical University of Munich",
}
}
// InitBranding initializes the global branding configuration variable `BrandingCfg`. If the config file doesn't exist
// it will be set to the result of `getDefaultBranding()`.
func InitBranding() {
v := viper.New()
v.SetConfigName("branding")
v.SetConfigType("yaml")
v.AddConfigPath("/etc/TUM-Live/")
v.AddConfigPath("$HOME/.TUM-Live")
v.AddConfigPath(".")
branding := getDefaultBranding()
err := v.ReadInConfig()
if err == nil {
err = v.Unmarshal(&branding)
logger.Info("Using branding.yaml.")
if err != nil {
panic(fmt.Errorf("fatal error branding file: %v", err))
}
}
BrandingCfg = branding
}