Feature: default broadcast endpoint config option (#123)

* feat: add broadcast_default_endpoint config

* chore: add documentation for new env variable

* rename to broadcast URL.

* update changelog.

Co-authored-by: Miroslav Šedivý <sedivy.miro@gmail.com>
This commit is contained in:
Konstantin Krauss
2022-01-02 22:19:36 +01:00
committed by GitHub
parent f37a2347e1
commit 50a85c6b39
4 changed files with 20 additions and 2 deletions

View File

@ -25,8 +25,8 @@ func New(remote *config.Remote, config *config.Broadcast) *BroadcastManager {
logger: log.With().Str("module", "remote").Logger(),
remote: remote,
config: config,
enabled: false,
url: "",
enabled: config.Enabled,
url: config.URL,
}
}

View File

@ -7,6 +7,8 @@ import (
type Broadcast struct {
Pipeline string
URL string
Enabled bool
}
func (Broadcast) Init(cmd *cobra.Command) error {
@ -15,9 +17,16 @@ func (Broadcast) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().String("broadcast_url", "", "URL for broadcasting, setting this value will automatically enable broadcasting")
if err := viper.BindPFlag("broadcast_url", cmd.PersistentFlags().Lookup("broadcast_url")); err != nil {
return err
}
return nil
}
func (s *Broadcast) Set() {
s.Pipeline = viper.GetString("broadcast_pipeline")
s.URL = viper.GetString("broadcast_url")
s.Enabled = s.URL != ""
}