From f94f6962f552eee6fb995e3600e4c4ba1d97917a Mon Sep 17 00:00:00 2001 From: Marvin Preuss Date: Mon, 9 Aug 2021 11:09:03 +0200 Subject: [PATCH] renames `Box` config key to `Web` --- cmd/root.go | 8 ++++---- internal/config/config.go | 6 +++--- pkg/timer/timer.go | 2 +- pkg/web/web.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 0748d28..72b169c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -78,8 +78,8 @@ func init() { } // Defaults. - viper.SetDefault("box.hostname", "localhost") - viper.SetDefault("box.port", 9999) + viper.SetDefault("web.hostname", "localhost") + viper.SetDefault("web.port", 9999) viper.SetDefault("mpd.hostname", "localhost") viper.SetDefault("mpd.port", 6600) viper.SetDefault("reader.dev", "/dev/hidraw0") @@ -97,8 +97,8 @@ func init() { "debug.pprof": rootCmd.PersistentFlags().Lookup("pprof"), "reader.dev": prepareCmd.Flags().Lookup("rfid-reader"), "reader.ignore": runCmd.Flags().Lookup("ignore-reader"), - "box.hostname": timerCmd.Flags().Lookup("hostname"), - "box.port": timerCmd.Flags().Lookup("port"), + "web.hostname": timerCmd.Flags().Lookup("hostname"), + "web.port": timerCmd.Flags().Lookup("port"), "timer.duration": timerCmd.Flags().Lookup("duration"), } { if err := viper.BindPFlag(k, v); err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index ef48b73..04bf971 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -20,11 +20,11 @@ type Config struct { Dev string `mapstructure:"Dev"` } `mapstructure:"Reader"` - // Box is used to configure a webinterface. - Box struct { + // Web is used to configure the webinterface. + Web struct { Hostname string `mapstructure:"Hostname"` Port int `mapstructure:"Port"` - } `mapstructure:"Box"` + } `mapstructure:"Web"` // MPD contains the connection details for the Music Player Daemon. MPD struct { diff --git a/pkg/timer/timer.go b/pkg/timer/timer.go index 75e293e..748f9b7 100644 --- a/pkg/timer/timer.go +++ b/pkg/timer/timer.go @@ -58,7 +58,7 @@ func (t *Timer) Handle() { // Run is the command line interface for triggering the timer. 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 { log.Fatal().Err(err).Msg("could not connect") } diff --git a/pkg/web/web.go b/pkg/web/web.go index 60c7959..c84b083 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -111,7 +111,7 @@ func gw(s *grpc.Server, conn string) *runtime.ServeMux { func Run(command *cobra.Command, args []string) { // 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. grpcServer := grpc.NewServer(