mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-24 00:28:18 +00:00
25ef3da9d5
chore(fmt): run gci on complete project Fix global import formatting in go code by running the `gci` command. This allows us to just use the command directly, instead of fixing the import order manually for the linter, on each PR. Co-authored-by: Elio Bischof <elio@zitadel.com>
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package senders
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/notification/channels"
|
|
"github.com/zitadel/zitadel/internal/notification/channels/fs"
|
|
"github.com/zitadel/zitadel/internal/notification/channels/instrumenting"
|
|
"github.com/zitadel/zitadel/internal/notification/channels/log"
|
|
"github.com/zitadel/zitadel/internal/notification/channels/webhook"
|
|
)
|
|
|
|
const webhookSpanName = "webhook.NotificationChannel"
|
|
|
|
func WebhookChannels(
|
|
ctx context.Context,
|
|
webhookConfig webhook.Config,
|
|
getFileSystemProvider func(ctx context.Context) (*fs.Config, error),
|
|
getLogProvider func(ctx context.Context) (*log.Config, error),
|
|
successMetricName,
|
|
failureMetricName string,
|
|
) (*Chain, error) {
|
|
if err := webhookConfig.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
channels := make([]channels.NotificationChannel, 0, 3)
|
|
webhookChannel, err := webhook.InitChannel(ctx, webhookConfig)
|
|
logging.WithFields(
|
|
"instance", authz.GetInstance(ctx).InstanceID(),
|
|
"callurl", webhookConfig.CallURL,
|
|
).OnError(err).Debug("initializing JSON channel failed")
|
|
if err == nil {
|
|
channels = append(
|
|
channels,
|
|
instrumenting.Wrap(
|
|
ctx,
|
|
webhookChannel,
|
|
webhookSpanName,
|
|
successMetricName,
|
|
failureMetricName,
|
|
),
|
|
)
|
|
}
|
|
channels = append(channels, debugChannels(ctx, getFileSystemProvider, getLogProvider)...)
|
|
return ChainChannels(channels...), nil
|
|
}
|