Skip to content

Commit

Permalink
reuse context
Browse files Browse the repository at this point in the history
  • Loading branch information
huseyinbabal committed Jul 31, 2023
1 parent 9b6d5ce commit 7619652
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/botkube-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func run(ctx context.Context) (err error) {
}

if commGroupCfg.Mattermost.Enabled {
mb, err := bot.NewMattermost(commGroupLogger.WithField(botLogFieldKey, "Mattermost"), commGroupName, commGroupCfg.Mattermost, executorFactory, reporter)
mb, err := bot.NewMattermost(ctx, commGroupLogger.WithField(botLogFieldKey, "Mattermost"), commGroupName, commGroupCfg.Mattermost, executorFactory, reporter)
if err != nil {
return reportFatalError("while creating Mattermost bot", err)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/bot/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type mattermostMessage struct {
}

// NewMattermost creates a new Mattermost instance.
func NewMattermost(log logrus.FieldLogger, commGroupName string, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error) {
func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName string, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error) {
botMentionRegex, err := mattermostBotMentionRegex(cfg.BotName)
if err != nil {
return nil, err
Expand All @@ -90,7 +90,6 @@ func NewMattermost(log logrus.FieldLogger, commGroupName string, cfg config.Matt

client := model.NewAPIv4Client(cfg.URL)
client.SetOAuthToken(cfg.Token)
ctx := context.Background()
botTeams, _, err := client.SearchTeams(ctx, &model.TeamSearch{
Term: cfg.Team,
})
Expand Down

0 comments on commit 7619652

Please sign in to comment.