renames `Box` config key to `Web`

main
Marvin Preuss 3 years ago
parent 63a16a3253
commit f94f6962f5

@ -78,8 +78,8 @@ func init() {
} }
// Defaults. // Defaults.
viper.SetDefault("box.hostname", "localhost") viper.SetDefault("web.hostname", "localhost")
viper.SetDefault("box.port", 9999) viper.SetDefault("web.port", 9999)
viper.SetDefault("mpd.hostname", "localhost") viper.SetDefault("mpd.hostname", "localhost")
viper.SetDefault("mpd.port", 6600) viper.SetDefault("mpd.port", 6600)
viper.SetDefault("reader.dev", "/dev/hidraw0") viper.SetDefault("reader.dev", "/dev/hidraw0")
@ -97,8 +97,8 @@ func init() {
"debug.pprof": rootCmd.PersistentFlags().Lookup("pprof"), "debug.pprof": rootCmd.PersistentFlags().Lookup("pprof"),
"reader.dev": prepareCmd.Flags().Lookup("rfid-reader"), "reader.dev": prepareCmd.Flags().Lookup("rfid-reader"),
"reader.ignore": runCmd.Flags().Lookup("ignore-reader"), "reader.ignore": runCmd.Flags().Lookup("ignore-reader"),
"box.hostname": timerCmd.Flags().Lookup("hostname"), "web.hostname": timerCmd.Flags().Lookup("hostname"),
"box.port": timerCmd.Flags().Lookup("port"), "web.port": timerCmd.Flags().Lookup("port"),
"timer.duration": timerCmd.Flags().Lookup("duration"), "timer.duration": timerCmd.Flags().Lookup("duration"),
} { } {
if err := viper.BindPFlag(k, v); err != nil { if err := viper.BindPFlag(k, v); err != nil {

@ -20,11 +20,11 @@ type Config struct {
Dev string `mapstructure:"Dev"` Dev string `mapstructure:"Dev"`
} `mapstructure:"Reader"` } `mapstructure:"Reader"`
// Box is used to configure a webinterface. // Web is used to configure the webinterface.
Box struct { Web struct {
Hostname string `mapstructure:"Hostname"` Hostname string `mapstructure:"Hostname"`
Port int `mapstructure:"Port"` Port int `mapstructure:"Port"`
} `mapstructure:"Box"` } `mapstructure:"Web"`
// MPD contains the connection details for the Music Player Daemon. // MPD contains the connection details for the Music Player Daemon.
MPD struct { MPD struct {

@ -58,7 +58,7 @@ func (t *Timer) Handle() {
// Run is the command line interface for triggering the timer. // Run is the command line interface for triggering the timer.
func Run(cmd *cobra.Command, args []string) { func Run(cmd *cobra.Command, args []string) {
conn, err := grpcclient.Conn(config.Cfg.Box.Hostname, config.Cfg.Box.Port) conn, err := grpcclient.Conn(config.Cfg.Web.Hostname, config.Web.Box.Port)
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("could not connect") log.Fatal().Err(err).Msg("could not connect")
} }

@ -111,7 +111,7 @@ func gw(s *grpc.Server, conn string) *runtime.ServeMux {
func Run(command *cobra.Command, args []string) { func Run(command *cobra.Command, args []string) {
// Create host string for serving web. // Create host string for serving web.
lh := fmt.Sprintf("%s:%d", config.Cfg.Box.Hostname, config.Cfg.Box.Port) lh := fmt.Sprintf("%s:%d", config.Cfg.Web.Hostname, config.Cfg.Web.Port)
// Create grpc server. // Create grpc server.
grpcServer := grpc.NewServer( grpcServer := grpc.NewServer(

Loading…
Cancel
Save