feat: improve milestone format (#6150)

* feat: milestone format

* feat: push external domain

* cleanup

* Revert "remove prerelease"

This reverts commit 7417fdbeb3.

* fix branch

* remove prerelease
This commit is contained in:
Elio Bischof
2023-07-06 19:31:08 +02:00
committed by GitHub
parent a36818c222
commit 9b768003b7
5 changed files with 23 additions and 5 deletions

View File

@@ -214,7 +214,7 @@ func startZitadel(config *Config, masterKey string, server chan<- *Server) error
} }
actions.SetLogstoreService(actionsLogstoreSvc) actions.SetLogstoreService(actionsLogstoreSvc)
notification.Start(ctx, config.Projections.Customizations["notifications"], config.Projections.Customizations["notificationsquotas"], config.Projections.Customizations["telemetry"], *config.Telemetry, config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPIFromDomain(config.ExternalSecure, config.ExternalPort), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS) notification.Start(ctx, config.Projections.Customizations["notifications"], config.Projections.Customizations["notificationsquotas"], config.Projections.Customizations["telemetry"], *config.Telemetry, config.ExternalDomain, config.ExternalPort, config.ExternalSecure, commands, queries, eventstoreClient, assets.AssetAPIFromDomain(config.ExternalSecure, config.ExternalPort), config.SystemDefaults.Notifications.FileSystemPath, keys.User, keys.SMTP, keys.SMS)
router := mux.NewRouter() router := mux.NewRouter()
tlsConfig, err := config.TLS.Config() tlsConfig, err := config.TLS.Config()

View File

@@ -12,6 +12,7 @@ import (
type NotificationQueries struct { type NotificationQueries struct {
*query.Queries *query.Queries
es *eventstore.Eventstore es *eventstore.Eventstore
externalDomain string
externalPort uint16 externalPort uint16
externalSecure bool externalSecure bool
fileSystemPath string fileSystemPath string
@@ -24,6 +25,7 @@ type NotificationQueries struct {
func NewNotificationQueries( func NewNotificationQueries(
baseQueries *query.Queries, baseQueries *query.Queries,
es *eventstore.Eventstore, es *eventstore.Eventstore,
externalDomain string,
externalPort uint16, externalPort uint16,
externalSecure bool, externalSecure bool,
fileSystemPath string, fileSystemPath string,
@@ -35,6 +37,7 @@ func NewNotificationQueries(
return &NotificationQueries{ return &NotificationQueries{
Queries: baseQueries, Queries: baseQueries,
es: es, es: es,
externalDomain: externalDomain,
externalPort: externalPort, externalPort: externalPort,
externalSecure: externalSecure, externalSecure: externalSecure,
fileSystemPath: fileSystemPath, fileSystemPath: fileSystemPath,

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"net/http" "net/http"
"time"
"github.com/zitadel/logging" "github.com/zitadel/logging"
@@ -128,6 +129,7 @@ func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.Sched
if alreadyHandled { if alreadyHandled {
return nil return nil
} }
for _, endpoint := range t.cfg.Endpoints { for _, endpoint := range t.cfg.Endpoints {
if err := types.SendJSON( if err := types.SendJSON(
ctx, ctx,
@@ -138,7 +140,19 @@ func (t *telemetryPusher) pushMilestone(ctx context.Context, event *pseudo.Sched
}, },
t.queries.GetFileSystemProvider, t.queries.GetFileSystemProvider,
t.queries.GetLogProvider, t.queries.GetLogProvider,
ms, &struct {
InstanceID string `json:"instanceId"`
ExternalDomain string `json:"externalDomain"`
PrimaryDomain string `json:"primaryDomain"`
Type milestone.Type `json:"type"`
ReachedDate time.Time `json:"reached"`
}{
InstanceID: ms.InstanceID,
ExternalDomain: t.queries.externalDomain,
PrimaryDomain: ms.PrimaryDomain,
Type: ms.Type,
ReachedDate: ms.ReachedDate,
},
event, event,
t.metricSuccessfulDeliveriesJSON, t.metricSuccessfulDeliveriesJSON,
t.metricFailedDeliveriesJSON, t.metricFailedDeliveriesJSON,

View File

@@ -73,8 +73,8 @@ func awaitMilestone(t *testing.T, bodies chan []byte, primaryDomain, expectMiles
} }
t.Log("received milestone", plain.String()) t.Log("received milestone", plain.String())
milestone := struct { milestone := struct {
Type string Type string `json:"type"`
PrimaryDomain string PrimaryDomain string `json:"primaryDomain"`
}{} }{}
if err := json.Unmarshal(body, &milestone); err != nil { if err := json.Unmarshal(body, &milestone); err != nil {
t.Error(err) t.Error(err)

View File

@@ -31,6 +31,7 @@ func Start(
quotaHandlerCustomConfig projection.CustomConfig, quotaHandlerCustomConfig projection.CustomConfig,
telemetryHandlerCustomConfig projection.CustomConfig, telemetryHandlerCustomConfig projection.CustomConfig,
telemetryCfg handlers.TelemetryPusherConfig, telemetryCfg handlers.TelemetryPusherConfig,
externalDomain string,
externalPort uint16, externalPort uint16,
externalSecure bool, externalSecure bool,
commands *command.Commands, commands *command.Commands,
@@ -56,7 +57,7 @@ func Start(
logging.WithFields("metric", metricSuccessfulDeliveriesJSON).OnError(err).Panic("unable to register counter") logging.WithFields("metric", metricSuccessfulDeliveriesJSON).OnError(err).Panic("unable to register counter")
err = metrics.RegisterCounter(metricFailedDeliveriesJSON, "Failed JSON message deliveries") err = metrics.RegisterCounter(metricFailedDeliveriesJSON, "Failed JSON message deliveries")
logging.WithFields("metric", metricFailedDeliveriesJSON).OnError(err).Panic("unable to register counter") logging.WithFields("metric", metricFailedDeliveriesJSON).OnError(err).Panic("unable to register counter")
q := handlers.NewNotificationQueries(queries, es, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption, statikFS) q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption, statikFS)
handlers.NewUserNotifier( handlers.NewUserNotifier(
ctx, ctx,
projection.ApplyCustomConfig(userHandlerCustomConfig), projection.ApplyCustomConfig(userHandlerCustomConfig),