fix(setup): init projections (#7194)

Even though this is a feature it's released as fix so that we can back port to earlier revisions.

As reported by multiple users startup of ZITADEL after leaded to downtime and worst case rollbacks to the previously deployed version.

The problem starts rising when there are too many events to process after the start of ZITADEL. The root cause are changes on projections (database tables) which must be recomputed. This PR solves this problem by adding a new step to the setup phase which prefills the projections. The step can be enabled by adding the `--init-projections`-flag to `setup`, `start-from-init` and `start-from-setup`. Setting this flag results in potentially longer duration of the setup phase but reduces the risk of the problems mentioned in the paragraph above.

(cherry picked from commit 17953e9040)
This commit is contained in:
Silvan 2024-01-25 17:28:20 +01:00 committed by Livio Spring
parent 50faf37921
commit d3bb9c9b3b
No known key found for this signature in database
GPG Key ID: 26BB1C2FA5952CF0
80 changed files with 1296 additions and 962 deletions

View File

@ -103,7 +103,7 @@ core_unit_test:
core_integration_setup: core_integration_setup:
go build -o zitadel main.go go build -o zitadel main.go
./zitadel init --config internal/integration/config/zitadel.yaml --config internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml ./zitadel init --config internal/integration/config/zitadel.yaml --config internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml
./zitadel setup --masterkeyFromEnv --config internal/integration/config/zitadel.yaml --config internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml --steps internal/integration/config/zitadel.yaml --steps internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml ./zitadel setup --masterkeyFromEnv --init-projections --config internal/integration/config/zitadel.yaml --config internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml --steps internal/integration/config/zitadel.yaml --steps internal/integration/config/${INTEGRATION_DB_FLAVOR}.yaml
$(RM) zitadel $(RM) zitadel
.PHONY: core_integration_test .PHONY: core_integration_test

View File

@ -1327,3 +1327,12 @@ InternalAuthZ:
- "user.global.read" - "user.global.read"
- "user.grant.read" - "user.grant.read"
- "user.membership.read" - "user.membership.read"
# If a new projection is introduced it will be prefilled during the setup process (if enabled)
# This can prevent serving outdated data after a version upgrade, but might require a longer setup / upgrade process:
# https://zitadel.com/docs/self-hosting/manage/updating_scaling
InitProjections:
Enabled: false # ZITADEL_INITPROJECTIONS_ENABLED
RetryFailedAfter: 100ms # ZITADEL_INITPROJECTIONS_RETRYFAILEDAFTER
MaxFailureCount: 2 # ZITADEL_INITPROJECTIONS_MAXFAILURECOUNT
BulkLimit: 1000 # ZITADEL_INITPROJECTIONS_BULKLIMIT

View File

@ -1,4 +1,4 @@
package start package encryption
import ( import (
"context" "context"
@ -22,7 +22,20 @@ var (
} }
) )
type encryptionKeys struct { type EncryptionKeyConfig struct {
DomainVerification *crypto.KeyConfig
IDPConfig *crypto.KeyConfig
OIDC *crypto.KeyConfig
SAML *crypto.KeyConfig
OTP *crypto.KeyConfig
SMS *crypto.KeyConfig
SMTP *crypto.KeyConfig
User *crypto.KeyConfig
CSRFCookieKeyID string
UserAgentCookieKeyID string
}
type EncryptionKeys struct {
DomainVerification crypto.EncryptionAlgorithm DomainVerification crypto.EncryptionAlgorithm
IDPConfig crypto.EncryptionAlgorithm IDPConfig crypto.EncryptionAlgorithm
OIDC crypto.EncryptionAlgorithm OIDC crypto.EncryptionAlgorithm
@ -36,11 +49,11 @@ type encryptionKeys struct {
OIDCKey []byte OIDCKey []byte
} }
func ensureEncryptionKeys(ctx context.Context, keyConfig *encryptionKeyConfig, keyStorage crypto.KeyStorage) (keys *encryptionKeys, err error) { func EnsureEncryptionKeys(ctx context.Context, keyConfig *EncryptionKeyConfig, keyStorage crypto.KeyStorage) (keys *EncryptionKeys, err error) {
if err := verifyDefaultKeys(ctx, keyStorage); err != nil { if err := VerifyDefaultKeys(ctx, keyStorage); err != nil {
return nil, err return nil, err
} }
keys = new(encryptionKeys) keys = new(EncryptionKeys)
keys.DomainVerification, err = crypto.NewAESCrypto(keyConfig.DomainVerification, keyStorage) keys.DomainVerification, err = crypto.NewAESCrypto(keyConfig.DomainVerification, keyStorage)
if err != nil { if err != nil {
return nil, err return nil, err
@ -91,7 +104,7 @@ func ensureEncryptionKeys(ctx context.Context, keyConfig *encryptionKeyConfig, k
return keys, nil return keys, nil
} }
func verifyDefaultKeys(ctx context.Context, keyStorage crypto.KeyStorage) (err error) { func VerifyDefaultKeys(ctx context.Context, keyStorage crypto.KeyStorage) (err error) {
keys := make([]*crypto.Key, 0, len(defaultKeyIDs)) keys := make([]*crypto.Key, 0, len(defaultKeyIDs))
for _, keyID := range defaultKeyIDs { for _, keyID := range defaultKeyIDs {
_, err := crypto.LoadKey(keyID, keyStorage) _, err := crypto.LoadKey(keyID, keyStorage)

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"database/sql" "database/sql"
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -19,7 +21,7 @@ type ProjectionTable struct {
dbClient *sql.DB dbClient *sql.DB
} }
func (mig *ProjectionTable) Execute(ctx context.Context) error { func (mig *ProjectionTable) Execute(ctx context.Context, _ eventstore.Event) error {
stmt := createAdminViews + createAuthViews + createProjections stmt := createAdminViews + createAuthViews + createProjections
_, err := mig.dbClient.ExecContext(ctx, stmt) _, err := mig.dbClient.ExecContext(ctx, stmt)
return err return err

View File

@ -3,6 +3,8 @@ package setup
import ( import (
"context" "context"
"database/sql" "database/sql"
"github.com/zitadel/zitadel/internal/eventstore"
) )
const ( const (
@ -26,7 +28,7 @@ type AssetTable struct {
dbClient *sql.DB dbClient *sql.DB
} }
func (mig *AssetTable) Execute(ctx context.Context) error { func (mig *AssetTable) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, createAssets) _, err := mig.dbClient.ExecContext(ctx, createAssets)
return err return err
} }

View File

@ -41,30 +41,19 @@ type FirstInstance struct {
domain string domain string
} }
func (mig *FirstInstance) Execute(ctx context.Context) error { func (mig *FirstInstance) Execute(ctx context.Context, _ eventstore.Event) error {
keyStorage, err := crypto_db.NewKeyStorage(mig.db, mig.masterKey) keyStorage, err := mig.verifyEncryptionKeys(ctx)
if err != nil { if err != nil {
return fmt.Errorf("cannot start key storage: %w", err)
}
if err = verifyKey(ctx, mig.userEncryptionKey, keyStorage); err != nil {
return err return err
} }
userAlg, err := crypto.NewAESCrypto(mig.userEncryptionKey, keyStorage) userAlg, err := crypto.NewAESCrypto(mig.userEncryptionKey, keyStorage)
if err != nil { if err != nil {
return err return err
} }
if err = verifyKey(ctx, mig.smtpEncryptionKey, keyStorage); err != nil {
return err
}
smtpEncryption, err := crypto.NewAESCrypto(mig.smtpEncryptionKey, keyStorage) smtpEncryption, err := crypto.NewAESCrypto(mig.smtpEncryptionKey, keyStorage)
if err != nil { if err != nil {
return err return err
} }
if err = verifyKey(ctx, mig.oidcEncryptionKey, keyStorage); err != nil {
return err
}
oidcEncryption, err := crypto.NewAESCrypto(mig.oidcEncryptionKey, keyStorage) oidcEncryption, err := crypto.NewAESCrypto(mig.oidcEncryptionKey, keyStorage)
if err != nil { if err != nil {
return err return err
@ -132,7 +121,27 @@ func (mig *FirstInstance) Execute(ctx context.Context) error {
(mig.instanceSetup.Org.Machine.MachineKey != nil && key == nil)) { (mig.instanceSetup.Org.Machine.MachineKey != nil && key == nil)) {
return err return err
} }
return mig.outputMachineAuthentication(key, token)
}
func (mig *FirstInstance) verifyEncryptionKeys(ctx context.Context) (*crypto_db.Database, error) {
keyStorage, err := crypto_db.NewKeyStorage(mig.db, mig.masterKey)
if err != nil {
return nil, fmt.Errorf("cannot start key storage: %w", err)
}
if err = verifyKey(ctx, mig.userEncryptionKey, keyStorage); err != nil {
return nil, err
}
if err = verifyKey(ctx, mig.smtpEncryptionKey, keyStorage); err != nil {
return nil, err
}
if err = verifyKey(ctx, mig.oidcEncryptionKey, keyStorage); err != nil {
return nil, err
}
return keyStorage, nil
}
func (mig *FirstInstance) outputMachineAuthentication(key *command.MachineKey, token string) error {
if key != nil { if key != nil {
keyDetails, err := key.Detail() keyDetails, err := key.Detail()
if err != nil { if err != nil {

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"database/sql" "database/sql"
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -15,7 +17,7 @@ type LastFailed struct {
dbClient *sql.DB dbClient *sql.DB
} }
func (mig *LastFailed) Execute(ctx context.Context) error { func (mig *LastFailed) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, lastFailedStmts) _, err := mig.dbClient.ExecContext(ctx, lastFailedStmts)
return err return err
} }

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"database/sql" "database/sql"
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -17,7 +19,7 @@ type OwnerRemoveColumns struct {
dbClient *sql.DB dbClient *sql.DB
} }
func (mig *OwnerRemoveColumns) Execute(ctx context.Context) error { func (mig *OwnerRemoveColumns) Execute(ctx context.Context, _ eventstore.Event) error {
stmt := createAdminViews06 + createAuthViews06 stmt := createAdminViews06 + createAuthViews06
_, err := mig.dbClient.ExecContext(ctx, stmt) _, err := mig.dbClient.ExecContext(ctx, stmt)
return err return err

View File

@ -5,6 +5,8 @@ import (
"database/sql" "database/sql"
"embed" "embed"
"strings" "strings"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -24,7 +26,7 @@ type LogstoreTables struct {
dbType string dbType string
} }
func (mig *LogstoreTables) Execute(ctx context.Context) error { func (mig *LogstoreTables) Execute(ctx context.Context, _ eventstore.Event) error {
accessStmt, err := readStmt(createAccessLogsTable07, "07", mig.dbType, "access.sql") accessStmt, err := readStmt(createAccessLogsTable07, "07", mig.dbType, "access.sql")
if err != nil { if err != nil {
return err return err

View File

@ -5,6 +5,7 @@ import (
"embed" "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -17,7 +18,7 @@ type AuthTokenIndexes struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AuthTokenIndexes) Execute(ctx context.Context) error { func (mig *AuthTokenIndexes) Execute(ctx context.Context, _ eventstore.Event) error {
stmt, err := readStmt(tokenIndexes08, "08", mig.dbClient.Type(), "08.sql") stmt, err := readStmt(tokenIndexes08, "08", mig.dbClient.Type(), "08.sql")
if err != nil { if err != nil {
return err return err

View File

@ -10,6 +10,7 @@ import (
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -31,7 +32,7 @@ type CorrectCreationDate struct {
FailAfter time.Duration FailAfter time.Duration
} }
func (mig *CorrectCreationDate) Execute(ctx context.Context) (err error) { func (mig *CorrectCreationDate) Execute(ctx context.Context, _ eventstore.Event) (err error) {
ctx, cancel := context.WithTimeout(ctx, mig.FailAfter) ctx, cancel := context.WithTimeout(ctx, mig.FailAfter)
defer cancel() defer cancel()

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddOTPColumns struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddOTPColumns) Execute(ctx context.Context) error { func (mig *AddOTPColumns) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addOTPColumns) _, err := mig.dbClient.ExecContext(ctx, addOTPColumns)
return err return err
} }

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type FixQuotaConstraints struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *FixQuotaConstraints) Execute(ctx context.Context) error { func (mig *FixQuotaConstraints) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, fixQuotaConstraints) _, err := mig.dbClient.ExecContext(ctx, fixQuotaConstraints)
return err return err
} }

View File

@ -11,6 +11,7 @@ import (
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -23,7 +24,7 @@ type NewEventsTable struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *NewEventsTable) Execute(ctx context.Context) error { func (mig *NewEventsTable) Execute(ctx context.Context, _ eventstore.Event) error {
migrations, err := newEventsTable.ReadDir("14/" + mig.dbClient.Type()) migrations, err := newEventsTable.ReadDir("14/" + mig.dbClient.Type())
if err != nil { if err != nil {
return err return err

View File

@ -7,6 +7,7 @@ import (
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -19,7 +20,7 @@ type CurrentProjectionState struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *CurrentProjectionState) Execute(ctx context.Context) error { func (mig *CurrentProjectionState) Execute(ctx context.Context, _ eventstore.Event) error {
migrations, err := currentProjectionState.ReadDir("15/" + mig.dbClient.Type()) migrations, err := currentProjectionState.ReadDir("15/" + mig.dbClient.Type())
if err != nil { if err != nil {
return err return err

View File

@ -7,6 +7,7 @@ import (
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -18,7 +19,7 @@ type UniqueConstraintToLower struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *UniqueConstraintToLower) Execute(ctx context.Context) error { func (mig *UniqueConstraintToLower) Execute(ctx context.Context, _ eventstore.Event) error {
res, err := mig.dbClient.ExecContext(ctx, uniqueConstraintLower) res, err := mig.dbClient.ExecContext(ctx, uniqueConstraintLower)
if err != nil { if err != nil {
return err return err

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddOffsetToCurrentStates struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddOffsetToCurrentStates) Execute(ctx context.Context) error { func (mig *AddOffsetToCurrentStates) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addOffsetField) _, err := mig.dbClient.ExecContext(ctx, addOffsetField)
return err return err
} }

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddLowerFieldsToLoginNames struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddLowerFieldsToLoginNames) Execute(ctx context.Context) error { func (mig *AddLowerFieldsToLoginNames) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addLowerFieldsToLoginNames) _, err := mig.dbClient.ExecContext(ctx, addLowerFieldsToLoginNames)
return err return err
} }

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddCurrentSequencesIndex struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddCurrentSequencesIndex) Execute(ctx context.Context) error { func (mig *AddCurrentSequencesIndex) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addCurrentSequencesIndex) _, err := mig.dbClient.ExecContext(ctx, addCurrentSequencesIndex)
return err return err
} }

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddByUserIndexToSession struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddByUserIndexToSession) Execute(ctx context.Context) error { func (mig *AddByUserIndexToSession) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addByUserIndexToSession) _, err := mig.dbClient.ExecContext(ctx, addByUserIndexToSession)
return err return err
} }

View File

@ -5,6 +5,7 @@ import (
_ "embed" _ "embed"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
) )
var ( var (
@ -16,7 +17,7 @@ type AddBlockFieldToLimits struct {
dbClient *database.DB dbClient *database.DB
} }
func (mig *AddBlockFieldToLimits) Execute(ctx context.Context) error { func (mig *AddBlockFieldToLimits) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, addBlockFieldToLimits) _, err := mig.dbClient.ExecContext(ctx, addBlockFieldToLimits)
return err return err
} }

27
cmd/setup/22.go Normal file
View File

@ -0,0 +1,27 @@
package setup
import (
"context"
_ "embed"
"github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
)
var (
//go:embed 22.sql
activeInstanceEvents string
)
type ActiveInstanceEvents struct {
dbClient *database.DB
}
func (mig *ActiveInstanceEvents) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, activeInstanceEvents)
return err
}
func (mig *ActiveInstanceEvents) String() string {
return "22_active_instance_events_index"
}

1
cmd/setup/22.sql Normal file
View File

@ -0,0 +1 @@
CREATE INDEX CONCURRENTLY IF NOT EXISTS active_instances_events ON eventstore.events2 (aggregate_type, event_type) WHERE aggregate_type = 'instance' AND event_type IN ('instance.added', 'instance.removed');

View File

@ -40,7 +40,6 @@ func Cleanup(config *Config) {
config.Eventstore.Pusher = new_es.NewEventstore(esPusherDBClient) config.Eventstore.Pusher = new_es.NewEventstore(esPusherDBClient)
config.Eventstore.Querier = old_es.NewCRDB(queryDBClient) config.Eventstore.Querier = old_es.NewCRDB(queryDBClient)
es := eventstore.NewEventstore(config.Eventstore) es := eventstore.NewEventstore(config.Eventstore)
migration.RegisterMappers(es)
step, err := migration.LastStuckStep(ctx, es) step, err := migration.LastStuckStep(ctx, es)
logging.OnError(err).Fatal("unable to query latest migration") logging.OnError(err).Fatal("unable to query latest migration")

View File

@ -9,16 +9,22 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/encryption"
"github.com/zitadel/zitadel/cmd/systemapi"
"github.com/zitadel/zitadel/internal/actions"
"github.com/zitadel/zitadel/internal/api/authz" "github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/api/oidc"
"github.com/zitadel/zitadel/internal/api/ui/login"
"github.com/zitadel/zitadel/internal/command" "github.com/zitadel/zitadel/internal/command"
"github.com/zitadel/zitadel/internal/config/hook" "github.com/zitadel/zitadel/internal/config/hook"
"github.com/zitadel/zitadel/internal/config/systemdefaults" "github.com/zitadel/zitadel/internal/config/systemdefaults"
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/domain" "github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/id" "github.com/zitadel/zitadel/internal/id"
"github.com/zitadel/zitadel/internal/notification/handlers"
"github.com/zitadel/zitadel/internal/query/projection" "github.com/zitadel/zitadel/internal/query/projection"
static_config "github.com/zitadel/zitadel/internal/static/config"
) )
type Config struct { type Config struct {
@ -29,11 +35,26 @@ type Config struct {
ExternalPort uint16 ExternalPort uint16
ExternalSecure bool ExternalSecure bool
Log *logging.Config Log *logging.Config
EncryptionKeys *encryptionKeyConfig EncryptionKeys *encryption.EncryptionKeyConfig
DefaultInstance command.InstanceSetup DefaultInstance command.InstanceSetup
Machine *id.Config Machine *id.Config
Projections projection.Config Projections projection.Config
Eventstore *eventstore.Config Eventstore *eventstore.Config
InitProjections InitProjections
AssetStorage static_config.AssetStorageConfig
OIDC oidc.Config
Login login.Config
WebAuthNName string
Telemetry *handlers.TelemetryPusherConfig
SystemAPIUsers systemapi.Users
}
type InitProjections struct {
Enabled bool
RetryFailedAfter time.Duration
MaxFailureCount uint8
BulkLimit uint64
} }
func MustNewConfig(v *viper.Viper) *Config { func MustNewConfig(v *viper.Viper) *Config {
@ -48,6 +69,7 @@ func MustNewConfig(v *viper.Viper) *Config {
database.DecodeHook, database.DecodeHook,
hook.EnumHookFunc(domain.FeatureString), hook.EnumHookFunc(domain.FeatureString),
hook.EnumHookFunc(authz.MemberTypeString), hook.EnumHookFunc(authz.MemberTypeString),
actions.HTTPConfigDecodeHook,
)), )),
) )
logging.OnError(err).Fatal("unable to read default config") logging.OnError(err).Fatal("unable to read default config")
@ -79,12 +101,7 @@ type Steps struct {
s19AddCurrentStatesIndex *AddCurrentSequencesIndex s19AddCurrentStatesIndex *AddCurrentSequencesIndex
s20AddByUserSessionIndex *AddByUserIndexToSession s20AddByUserSessionIndex *AddByUserIndexToSession
s21AddBlockFieldToLimits *AddBlockFieldToLimits s21AddBlockFieldToLimits *AddBlockFieldToLimits
} s22ActiveInstancesIndex *ActiveInstanceEvents
type encryptionKeyConfig struct {
User *crypto.KeyConfig
SMTP *crypto.KeyConfig
OIDC *crypto.KeyConfig
} }
func MustNewSteps(v *viper.Viper) *Steps { func MustNewSteps(v *viper.Viper) *Steps {
@ -110,6 +127,7 @@ func MustNewSteps(v *viper.Viper) *Steps {
mapstructure.StringToTimeHookFunc(time.RFC3339), mapstructure.StringToTimeHookFunc(time.RFC3339),
mapstructure.StringToSliceHookFunc(","), mapstructure.StringToSliceHookFunc(","),
hook.EnumHookFunc(domain.FeatureString), hook.EnumHookFunc(domain.FeatureString),
systemapi.UsersDecodeHook,
)), )),
) )
logging.OnError(err).Fatal("unable to read steps") logging.OnError(err).Fatal("unable to read steps")

View File

@ -30,7 +30,7 @@ func (mig *externalConfigChange) Check(lastRun map[string]interface{}) bool {
mig.currentExternalDomain != mig.ExternalDomain mig.currentExternalDomain != mig.ExternalDomain
} }
func (mig *externalConfigChange) Execute(ctx context.Context) error { func (mig *externalConfigChange) Execute(ctx context.Context, _ eventstore.Event) error {
cmd, err := command.StartCommands( cmd, err := command.StartCommands(
mig.es, mig.es,
mig.defaults, mig.defaults,

View File

@ -18,7 +18,7 @@ func (mig *projectionTables) Check(lastRun map[string]interface{}) bool {
return currentVersion != mig.Version return currentVersion != mig.Version
} }
func (mig *projectionTables) Execute(ctx context.Context) error { func (mig *projectionTables) Execute(ctx context.Context, _ eventstore.Event) error {
return projection.Init(ctx) return projection.Init(ctx)
} }

View File

@ -4,22 +4,37 @@ import (
"context" "context"
"embed" "embed"
_ "embed" _ "embed"
"net/http"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/build" "github.com/zitadel/zitadel/cmd/build"
"github.com/zitadel/zitadel/cmd/encryption"
"github.com/zitadel/zitadel/cmd/key" "github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/tls" "github.com/zitadel/zitadel/cmd/tls"
admin_handler "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/handler"
admin_view "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view"
internal_authz "github.com/zitadel/zitadel/internal/api/authz"
auth_handler "github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/handler"
auth_view "github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/view"
"github.com/zitadel/zitadel/internal/authz"
authz_es "github.com/zitadel/zitadel/internal/authz/repository/eventsourcing/eventstore"
"github.com/zitadel/zitadel/internal/command"
cryptoDB "github.com/zitadel/zitadel/internal/crypto/database"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/database/dialect" "github.com/zitadel/zitadel/internal/database/dialect"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
old_es "github.com/zitadel/zitadel/internal/eventstore/repository/sql" old_es "github.com/zitadel/zitadel/internal/eventstore/repository/sql"
new_es "github.com/zitadel/zitadel/internal/eventstore/v3" new_es "github.com/zitadel/zitadel/internal/eventstore/v3"
"github.com/zitadel/zitadel/internal/i18n" "github.com/zitadel/zitadel/internal/i18n"
"github.com/zitadel/zitadel/internal/migration" "github.com/zitadel/zitadel/internal/migration"
notify_handler "github.com/zitadel/zitadel/internal/notification"
"github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/internal/query/projection" "github.com/zitadel/zitadel/internal/query/projection"
"github.com/zitadel/zitadel/internal/webauthn"
) )
var ( var (
@ -39,6 +54,9 @@ Requirements:
err := tls.ModeFromFlag(cmd) err := tls.ModeFromFlag(cmd)
logging.OnError(err).Fatal("invalid tlsMode") logging.OnError(err).Fatal("invalid tlsMode")
err = BindInitProjections(cmd)
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
config := MustNewConfig(viper.GetViper()) config := MustNewConfig(viper.GetViper())
steps := MustNewSteps(viper.New()) steps := MustNewSteps(viper.New())
@ -58,10 +76,15 @@ Requirements:
func Flags(cmd *cobra.Command) { func Flags(cmd *cobra.Command) {
cmd.PersistentFlags().StringArrayVar(&stepFiles, "steps", nil, "paths to step files to overwrite default steps") cmd.PersistentFlags().StringArrayVar(&stepFiles, "steps", nil, "paths to step files to overwrite default steps")
cmd.Flags().Bool("init-projections", viper.GetBool("InitProjections"), "beta feature: initializes projections after they are created, allows smooth start as projections are up to date")
key.AddMasterKeyFlag(cmd) key.AddMasterKeyFlag(cmd)
tls.AddTLSModeFlag(cmd) tls.AddTLSModeFlag(cmd)
} }
func BindInitProjections(cmd *cobra.Command) error {
return viper.BindPFlag("InitProjections.Enabled", cmd.Flags().Lookup("init-projections"))
}
func Setup(config *Config, steps *Steps, masterKey string) { func Setup(config *Config, steps *Steps, masterKey string) {
ctx := context.Background() ctx := context.Background()
logging.Info("setup started") logging.Info("setup started")
@ -79,7 +102,6 @@ func Setup(config *Config, steps *Steps, masterKey string) {
config.Eventstore.Pusher = new_es.NewEventstore(esPusherDBClient) config.Eventstore.Pusher = new_es.NewEventstore(esPusherDBClient)
eventstoreClient := eventstore.NewEventstore(config.Eventstore) eventstoreClient := eventstore.NewEventstore(config.Eventstore)
logging.OnError(err).Fatal("unable to start eventstore") logging.OnError(err).Fatal("unable to start eventstore")
migration.RegisterMappers(eventstoreClient)
steps.s1ProjectionTable = &ProjectionTable{dbClient: queryDBClient.DB} steps.s1ProjectionTable = &ProjectionTable{dbClient: queryDBClient.DB}
steps.s2AssetsTable = &AssetTable{dbClient: queryDBClient.DB} steps.s2AssetsTable = &AssetTable{dbClient: queryDBClient.DB}
@ -112,6 +134,7 @@ func Setup(config *Config, steps *Steps, masterKey string) {
steps.s19AddCurrentStatesIndex = &AddCurrentSequencesIndex{dbClient: queryDBClient} steps.s19AddCurrentStatesIndex = &AddCurrentSequencesIndex{dbClient: queryDBClient}
steps.s20AddByUserSessionIndex = &AddByUserIndexToSession{dbClient: queryDBClient} steps.s20AddByUserSessionIndex = &AddByUserIndexToSession{dbClient: queryDBClient}
steps.s21AddBlockFieldToLimits = &AddBlockFieldToLimits{dbClient: queryDBClient} steps.s21AddBlockFieldToLimits = &AddBlockFieldToLimits{dbClient: queryDBClient}
steps.s22ActiveInstancesIndex = &ActiveInstanceEvents{dbClient: queryDBClient}
err = projection.Create(ctx, projectionDBClient, eventstoreClient, config.Projections, nil, nil, nil) err = projection.Create(ctx, projectionDBClient, eventstoreClient, config.Projections, nil, nil, nil)
logging.OnError(err).Fatal("unable to start projections") logging.OnError(err).Fatal("unable to start projections")
@ -160,6 +183,8 @@ func Setup(config *Config, steps *Steps, masterKey string) {
logging.WithFields("name", steps.s19AddCurrentStatesIndex.String()).OnError(err).Fatal("migration failed") logging.WithFields("name", steps.s19AddCurrentStatesIndex.String()).OnError(err).Fatal("migration failed")
err = migration.Migrate(ctx, eventstoreClient, steps.s20AddByUserSessionIndex) err = migration.Migrate(ctx, eventstoreClient, steps.s20AddByUserSessionIndex)
logging.WithFields("name", steps.s20AddByUserSessionIndex.String()).OnError(err).Fatal("migration failed") logging.WithFields("name", steps.s20AddByUserSessionIndex.String()).OnError(err).Fatal("migration failed")
err = migration.Migrate(ctx, eventstoreClient, steps.s22ActiveInstancesIndex)
logging.WithFields("name", steps.s22ActiveInstancesIndex.String()).OnError(err).Fatal("migration failed")
for _, repeatableStep := range repeatableSteps { for _, repeatableStep := range repeatableSteps {
err = migration.Migrate(ctx, eventstoreClient, repeatableStep) err = migration.Migrate(ctx, eventstoreClient, repeatableStep)
@ -171,9 +196,176 @@ func Setup(config *Config, steps *Steps, masterKey string) {
logging.WithFields("name", steps.s18AddLowerFieldsToLoginNames.String()).OnError(err).Fatal("migration failed") logging.WithFields("name", steps.s18AddLowerFieldsToLoginNames.String()).OnError(err).Fatal("migration failed")
err = migration.Migrate(ctx, eventstoreClient, steps.s21AddBlockFieldToLimits) err = migration.Migrate(ctx, eventstoreClient, steps.s21AddBlockFieldToLimits)
logging.WithFields("name", steps.s21AddBlockFieldToLimits.String()).OnError(err).Fatal("migration failed") logging.WithFields("name", steps.s21AddBlockFieldToLimits.String()).OnError(err).Fatal("migration failed")
// projection initialization must be done last, since the steps above might add required columns to the projections
if config.InitProjections.Enabled {
initProjections(
ctx,
eventstoreClient,
queryDBClient,
projectionDBClient,
masterKey,
config,
)
}
} }
func readStmt(fs embed.FS, folder, typ, filename string) (string, error) { func readStmt(fs embed.FS, folder, typ, filename string) (string, error) {
stmt, err := fs.ReadFile(folder + "/" + typ + "/" + filename) stmt, err := fs.ReadFile(folder + "/" + typ + "/" + filename)
return string(stmt), err return string(stmt), err
} }
func initProjections(
ctx context.Context,
eventstoreClient *eventstore.Eventstore,
queryDBClient,
projectionDBClient *database.DB,
masterKey string,
config *Config,
) {
logging.Info("init-projections is currently in beta")
keyStorage, err := cryptoDB.NewKeyStorage(queryDBClient, masterKey)
logging.OnError(err).Fatal("unable to start key storage")
keys, err := encryption.EnsureEncryptionKeys(ctx, config.EncryptionKeys, keyStorage)
logging.OnError(err).Fatal("unable to ensure encryption keys")
err = projection.Create(
ctx,
queryDBClient,
eventstoreClient,
projection.Config{
RetryFailedAfter: config.InitProjections.RetryFailedAfter,
MaxFailureCount: config.InitProjections.MaxFailureCount,
BulkLimit: config.InitProjections.BulkLimit,
},
keys.OIDC,
keys.SAML,
config.SystemAPIUsers,
)
logging.OnError(err).Fatal("unable to start projections")
for _, p := range projection.Projections() {
err := migration.Migrate(ctx, eventstoreClient, p)
logging.WithFields("name", p.String()).OnError(err).Fatal("migration failed")
}
staticStorage, err := config.AssetStorage.NewStorage(queryDBClient.DB)
logging.OnError(err).Fatal("unable to start asset storage")
adminView, err := admin_view.StartView(queryDBClient)
logging.OnError(err).Fatal("unable to start admin view")
admin_handler.Register(ctx,
admin_handler.Config{
Client: queryDBClient,
Eventstore: eventstoreClient,
BulkLimit: config.InitProjections.BulkLimit,
FailureCountUntilSkip: uint64(config.InitProjections.MaxFailureCount),
},
adminView,
staticStorage,
)
for _, p := range admin_handler.Projections() {
err := migration.Migrate(ctx, eventstoreClient, p)
logging.WithFields("name", p.String()).OnError(err).Fatal("migration failed")
}
sessionTokenVerifier := internal_authz.SessionTokenVerifier(keys.OIDC)
queries, err := query.StartQueries(
ctx,
eventstoreClient,
queryDBClient,
projectionDBClient,
config.Projections,
config.SystemDefaults,
keys.IDPConfig,
keys.OTP,
keys.OIDC,
keys.SAML,
config.InternalAuthZ.RolePermissionMappings,
sessionTokenVerifier,
func(q *query.Queries) domain.PermissionCheck {
return func(ctx context.Context, permission, orgID, resourceID string) (err error) {
return internal_authz.CheckPermission(ctx, &authz_es.UserMembershipRepo{Queries: q}, config.InternalAuthZ.RolePermissionMappings, permission, orgID, resourceID)
}
},
0, // not needed for projections
nil, // not needed for projections
false,
)
logging.OnError(err).Fatal("unable to start queries")
authView, err := auth_view.StartView(queryDBClient, keys.OIDC, queries, eventstoreClient)
logging.OnError(err).Fatal("unable to start admin view")
auth_handler.Register(ctx,
auth_handler.Config{
Client: queryDBClient,
Eventstore: eventstoreClient,
BulkLimit: config.InitProjections.BulkLimit,
FailureCountUntilSkip: uint64(config.InitProjections.MaxFailureCount),
},
authView,
queries,
)
for _, p := range auth_handler.Projections() {
err := migration.Migrate(ctx, eventstoreClient, p)
logging.WithFields("name", p.String()).OnError(err).Fatal("migration failed")
}
authZRepo, err := authz.Start(queries, eventstoreClient, queryDBClient, keys.OIDC, config.ExternalSecure)
logging.OnError(err).Fatal("unable to start authz repo")
permissionCheck := func(ctx context.Context, permission, orgID, resourceID string) (err error) {
return internal_authz.CheckPermission(ctx, authZRepo, config.InternalAuthZ.RolePermissionMappings, permission, orgID, resourceID)
}
commands, err := command.StartCommands(
eventstoreClient,
config.SystemDefaults,
config.InternalAuthZ.RolePermissionMappings,
staticStorage,
&webauthn.Config{
DisplayName: config.WebAuthNName,
ExternalSecure: config.ExternalSecure,
},
config.ExternalDomain,
config.ExternalSecure,
config.ExternalPort,
keys.IDPConfig,
keys.OTP,
keys.SMTP,
keys.SMS,
keys.User,
keys.DomainVerification,
keys.OIDC,
keys.SAML,
&http.Client{},
permissionCheck,
sessionTokenVerifier,
config.OIDC.DefaultAccessTokenLifetime,
config.OIDC.DefaultRefreshTokenExpiration,
config.OIDC.DefaultRefreshTokenIdleExpiration,
config.DefaultInstance.SecretGenerators,
)
logging.OnError(err).Fatal("unable to start commands")
notify_handler.Register(
ctx,
config.Projections.Customizations["notifications"],
config.Projections.Customizations["notificationsquotas"],
config.Projections.Customizations["telemetry"],
*config.Telemetry,
config.ExternalDomain,
config.ExternalPort,
config.ExternalSecure,
commands,
queries,
eventstoreClient,
config.Login.DefaultOTPEmailURLV2,
config.SystemDefaults.Notifications.FileSystemPath,
keys.User,
keys.SMTP,
keys.SMS,
)
for _, p := range notify_handler.Projections() {
err := migration.Migrate(ctx, eventstoreClient, p)
logging.WithFields("name", p.String()).OnError(err).Fatal("migration failed")
}
}

View File

@ -1,14 +1,14 @@
package start package start
import ( import (
"encoding/json"
"reflect"
"time" "time"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/zitadel/logging" "github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/encryption"
"github.com/zitadel/zitadel/cmd/systemapi"
"github.com/zitadel/zitadel/internal/actions" "github.com/zitadel/zitadel/internal/actions"
admin_es "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing" admin_es "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing"
internal_authz "github.com/zitadel/zitadel/internal/api/authz" internal_authz "github.com/zitadel/zitadel/internal/api/authz"
@ -22,7 +22,6 @@ import (
"github.com/zitadel/zitadel/internal/config/hook" "github.com/zitadel/zitadel/internal/config/hook"
"github.com/zitadel/zitadel/internal/config/network" "github.com/zitadel/zitadel/internal/config/network"
"github.com/zitadel/zitadel/internal/config/systemdefaults" "github.com/zitadel/zitadel/internal/config/systemdefaults"
"github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/domain" "github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
@ -59,10 +58,10 @@ type Config struct {
AssetStorage static_config.AssetStorageConfig AssetStorage static_config.AssetStorageConfig
InternalAuthZ internal_authz.Config InternalAuthZ internal_authz.Config
SystemDefaults systemdefaults.SystemDefaults SystemDefaults systemdefaults.SystemDefaults
EncryptionKeys *encryptionKeyConfig EncryptionKeys *encryption.EncryptionKeyConfig
DefaultInstance command.InstanceSetup DefaultInstance command.InstanceSetup
AuditLogRetention time.Duration AuditLogRetention time.Duration
SystemAPIUsers SystemAPIUsers SystemAPIUsers systemapi.Users
CustomerPortal string CustomerPortal string
Machine *id.Config Machine *id.Config
Actions *actions.Config Actions *actions.Config
@ -92,7 +91,7 @@ func MustNewConfig(v *viper.Viper) *Config {
mapstructure.StringToSliceHookFunc(","), mapstructure.StringToSliceHookFunc(","),
database.DecodeHook, database.DecodeHook,
actions.HTTPConfigDecodeHook, actions.HTTPConfigDecodeHook,
systemAPIUsersDecodeHook, systemapi.UsersDecodeHook,
hook.EnumHookFunc(domain.FeatureString), hook.EnumHookFunc(domain.FeatureString),
hook.EnumHookFunc(internal_authz.MemberTypeString), hook.EnumHookFunc(internal_authz.MemberTypeString),
)), )),
@ -113,35 +112,3 @@ func MustNewConfig(v *viper.Viper) *Config {
return config return config
} }
type encryptionKeyConfig struct {
DomainVerification *crypto.KeyConfig
IDPConfig *crypto.KeyConfig
OIDC *crypto.KeyConfig
SAML *crypto.KeyConfig
OTP *crypto.KeyConfig
SMS *crypto.KeyConfig
SMTP *crypto.KeyConfig
User *crypto.KeyConfig
CSRFCookieKeyID string
UserAgentCookieKeyID string
}
type SystemAPIUsers map[string]*internal_authz.SystemAPIUser
func systemAPIUsersDecodeHook(from, to reflect.Value) (any, error) {
if to.Type() != reflect.TypeOf(SystemAPIUsers{}) {
return from.Interface(), nil
}
data, ok := from.Interface().(string)
if !ok {
return from.Interface(), nil
}
users := make(SystemAPIUsers)
err := json.Unmarshal([]byte(data), &users)
if err != nil {
return nil, err
}
return users, nil
}

View File

@ -25,6 +25,7 @@ import (
"golang.org/x/net/http2/h2c" "golang.org/x/net/http2/h2c"
"github.com/zitadel/zitadel/cmd/build" "github.com/zitadel/zitadel/cmd/build"
"github.com/zitadel/zitadel/cmd/encryption"
"github.com/zitadel/zitadel/cmd/key" "github.com/zitadel/zitadel/cmd/key"
cmd_tls "github.com/zitadel/zitadel/cmd/tls" cmd_tls "github.com/zitadel/zitadel/cmd/tls"
"github.com/zitadel/zitadel/feature" "github.com/zitadel/zitadel/feature"
@ -108,7 +109,7 @@ type Server struct {
Config *Config Config *Config
DB *database.DB DB *database.DB
KeyStorage crypto.KeyStorage KeyStorage crypto.KeyStorage
Keys *encryptionKeys Keys *encryption.EncryptionKeys
Eventstore *eventstore.Eventstore Eventstore *eventstore.Eventstore
Queries *query.Queries Queries *query.Queries
AuthzRepo authz_repo.Repository AuthzRepo authz_repo.Repository
@ -141,7 +142,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
if err != nil { if err != nil {
return fmt.Errorf("cannot start key storage: %w", err) return fmt.Errorf("cannot start key storage: %w", err)
} }
keys, err := ensureEncryptionKeys(ctx, config.EncryptionKeys, keyStorage) keys, err := encryption.EnsureEncryptionKeys(ctx, config.EncryptionKeys, keyStorage)
if err != nil { if err != nil {
return err return err
} }
@ -172,6 +173,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
}, },
config.AuditLogRetention, config.AuditLogRetention,
config.SystemAPIUsers, config.SystemAPIUsers,
true,
) )
if err != nil { if err != nil {
return fmt.Errorf("cannot start queries: %w", err) return fmt.Errorf("cannot start queries: %w", err)
@ -236,7 +238,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
actionsLogstoreSvc := logstore.New(queries, actionsExecutionDBEmitter, actionsExecutionStdoutEmitter) actionsLogstoreSvc := logstore.New(queries, actionsExecutionDBEmitter, actionsExecutionStdoutEmitter)
actions.SetLogstoreService(actionsLogstoreSvc) actions.SetLogstoreService(actionsLogstoreSvc)
notification.Start( notification.Register(
ctx, ctx,
config.Projections.Customizations["notifications"], config.Projections.Customizations["notifications"],
config.Projections.Customizations["notificationsquotas"], config.Projections.Customizations["notificationsquotas"],
@ -254,6 +256,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
keys.SMTP, keys.SMTP,
keys.SMS, keys.SMS,
) )
notification.Start(ctx)
router := mux.NewRouter() router := mux.NewRouter()
tlsConfig, err := config.TLS.Config() tlsConfig, err := config.TLS.Config()
@ -313,7 +316,7 @@ func startAPIs(
config *Config, config *Config,
store static.Storage, store static.Storage,
authZRepo authz_repo.Repository, authZRepo authz_repo.Repository,
keys *encryptionKeys, keys *encryption.EncryptionKeys,
permissionCheck domain.PermissionCheck, permissionCheck domain.PermissionCheck,
) error { ) error {
repo := struct { repo := struct {

View File

@ -31,6 +31,9 @@ Requirements:
initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper())) initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper()))
err = setup.BindInitProjections(cmd)
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
setupConfig := setup.MustNewConfig(viper.GetViper()) setupConfig := setup.MustNewConfig(viper.GetViper())
setupSteps := setup.MustNewSteps(viper.New()) setupSteps := setup.MustNewSteps(viper.New())
setup.Setup(setupConfig, setupSteps, masterKey) setup.Setup(setupConfig, setupSteps, masterKey)

View File

@ -29,6 +29,9 @@ Requirements:
masterKey, err := key.MasterKey(cmd) masterKey, err := key.MasterKey(cmd)
logging.OnError(err).Panic("No master key provided") logging.OnError(err).Panic("No master key provided")
err = setup.BindInitProjections(cmd)
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
setupConfig := setup.MustNewConfig(viper.GetViper()) setupConfig := setup.MustNewConfig(viper.GetViper())
setupSteps := setup.MustNewSteps(viper.New()) setupSteps := setup.MustNewSteps(viper.New())
setup.Setup(setupConfig, setupSteps, masterKey) setup.Setup(setupConfig, setupSteps, masterKey)

27
cmd/systemapi/user.go Normal file
View File

@ -0,0 +1,27 @@
package systemapi
import (
"encoding/json"
"reflect"
"github.com/zitadel/zitadel/internal/api/authz"
)
type Users map[string]*authz.SystemAPIUser
func UsersDecodeHook(from, to reflect.Value) (any, error) {
if to.Type() != reflect.TypeOf(Users{}) {
return from.Interface(), nil
}
data, ok := from.Interface().(string)
if !ok {
return from.Interface(), nil
}
users := make(Users)
err := json.Unmarshal([]byte(data), &users)
if err != nil {
return nil, err
}
return users, nil
}

View File

@ -5,7 +5,7 @@ services:
zitadel-disabled-tls: zitadel-disabled-tls:
extends: extends:
service: zitadel-init service: zitadel-init
command: 'start-from-setup --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml' command: 'start-from-setup --init-projections --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml'
environment: environment:
- ZITADEL_EXTERNALPORT=80 - ZITADEL_EXTERNALPORT=80
- ZITADEL_EXTERNALSECURE=false - ZITADEL_EXTERNALSECURE=false
@ -19,7 +19,7 @@ services:
zitadel-external-tls: zitadel-external-tls:
extends: extends:
service: zitadel-init service: zitadel-init
command: 'start-from-setup --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml' command: 'start-from-setup --init-projections --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml'
environment: environment:
- ZITADEL_EXTERNALPORT=443 - ZITADEL_EXTERNALPORT=443
- ZITADEL_EXTERNALSECURE=true - ZITADEL_EXTERNALSECURE=true
@ -33,7 +33,7 @@ services:
zitadel-enabled-tls: zitadel-enabled-tls:
extends: extends:
service: zitadel-init service: zitadel-init
command: 'start-from-setup --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml' command: 'start-from-setup --init-projections --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml'
environment: environment:
- ZITADEL_EXTERNALPORT=443 - ZITADEL_EXTERNALPORT=443
- ZITADEL_EXTERNALSECURE=true - ZITADEL_EXTERNALSECURE=true

View File

@ -65,7 +65,7 @@ The init phase is idempotent if executed with the same binary version.
### The Setup Phase ### The Setup Phase
During `zitadel setup`, ZITADEL creates projection tables and migrates existing data. During `zitadel setup`, ZITADEL creates projection tables and migrates existing data, if `--init-projections` is set.
Depending on the ZITADEL version and the runtime resources, Depending on the ZITADEL version and the runtime resources,
this step can take several minutes. this step can take several minutes.
When deploying a new ZITADEL version, When deploying a new ZITADEL version,
@ -85,5 +85,4 @@ Beware, in the background, out-of-date projections
[recompute their state by replaying all missed events](/docs/concepts/eventstore/implementation#projections). [recompute their state by replaying all missed events](/docs/concepts/eventstore/implementation#projections).
If a new ZITADEL version is deployed, this can take quite a long time, If a new ZITADEL version is deployed, this can take quite a long time,
depending on the amount of events to catch up. depending on the amount of events to catch up.
You probably should consider manually migrating these projections first. You probably should consider providing `--init-projections`-flag to the [Setup Phase](#the-setup-phase) to shift the synchronization time to previous steps and delay the startup phase until events are caught up.
Refer to the [release notes for v2.14.0](https://github.com/zitadel/zitadel/releases/tag/v2.14.0) as an example.

View File

@ -0,0 +1,40 @@
---
title: Technical Advisory 10008
---
## Date and Version
Version: 2.44.0
Date: 2024-01-25
## Description
Version 2.44.0 introduces a new flag `--init-projections` to `zitadel setup` commands (`setup`, `start-from-setup`, `start-from-init`)
This flag enables prefilling of newly added or changed projections (database tables) during setup phase instead of start phase which are used to query data, for example users.
This new feature adds the following fields to the `setup` configuration, previously only used in `start`-command:
- `AssetStore`: Storage for assets like user avatar, organization logo, icon, font, etc.
- `OIDC`
- `Login`
- `WebAuthNName`
- `Telemetry`
- `SystemAPIUsers`
If you use different configurations on `setup` and `start` and have overwritten previously mentioned configurations please make sure to also add them to the configuration provided to ZITADEL `setup` command.
## Statement
Filling of projections can get time consuming as your system grows and this can cause downtime of self hosted installations of ZITADEL because queries first need to ensure data consistency.
Before this release, this step was executed after the start of ZITADEL and therefore lead to inconsistent retrieval of data until the projections were up-to-date.
## Mitigation
Enable the `--init-projections`-flag in setup phase and make sure the previous deployment of ZITADEL remains active until the new revision started properly.
## Impact
Decreases downtime of starting new revisions with new or changed projections dramatically.

View File

@ -132,7 +132,7 @@ We understand that these advisories may include breaking changes, and we aim to
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="./advisory/a10007">A-10006</a> <a href="./advisory/a10007">A-10007</a>
</td> </td>
<td>Additional grant to cockroach database user</td> <td>Additional grant to cockroach database user</td>
<td>Breaking Behaviour Change</td> <td>Breaking Behaviour Change</td>
@ -142,6 +142,18 @@ We understand that these advisories may include breaking changes, and we aim to
<td>Upcoming</td> <td>Upcoming</td>
<td>Upcoming</td> <td>Upcoming</td>
</tr> </tr>
<tr>
<td>
<a href="./advisory/a10008">A-10008</a>
</td>
<td>New flag to prefill projections during setup instead of after start</td>
<td>Feature description</td>
<td>
new flag `--init-projections` introduced to `zitadel setup` commands (`setup`, `start-from-setup`, `start-from-init`)
</td>
<td>2.44.0</td>
<td>2024-01-25</td>
</tr>
</table> </table>
## Subscribe to our Mailing List ## Subscribe to our Mailing List
@ -162,7 +174,7 @@ Therefore, it is important to be aware of breaking behavior changes and their po
### Expected downtime during upgrade ### Expected downtime during upgrade
Expected downtime during upgrade means that ZITADEL might become unavailable during and upgrade. Expected downtime during upgrade means that ZITADEL might become unavailable during an upgrade.
ZITADEL is built for [zero downtime upgrades](/docs/concepts/architecture/solution#zero-downtime-updates) at upgrades can be executed without downtime by just updating to a more recent version. ZITADEL is built for [zero downtime upgrades](/docs/concepts/architecture/solution#zero-downtime-updates) at upgrades can be executed without downtime by just updating to a more recent version.
When deploying certain changes a zero downtime upgrade might not be possible, for example to guarantee data integrity. When deploying certain changes a zero downtime upgrade might not be possible, for example to guarantee data integrity.
In such cases we will issue a technical advisory to make you aware of this unexpected behavior. In such cases we will issue a technical advisory to make you aware of this unexpected behavior.

View File

@ -7,6 +7,7 @@ import (
"github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view" "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing/view"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
handler2 "github.com/zitadel/zitadel/internal/eventstore/handler/v2" handler2 "github.com/zitadel/zitadel/internal/eventstore/handler/v2"
"github.com/zitadel/zitadel/internal/static" "github.com/zitadel/zitadel/internal/static"
) )
@ -26,16 +27,28 @@ type ConfigOverwrites struct {
MinimumCycleDuration time.Duration MinimumCycleDuration time.Duration
} }
var projections []*handler.Handler
func Register(ctx context.Context, config Config, view *view.View, static static.Storage) { func Register(ctx context.Context, config Config, view *view.View, static static.Storage) {
if static == nil { if static == nil {
return return
} }
newStyling(ctx, projections = append(projections, newStyling(ctx,
config.overwrite("Styling"), config.overwrite("Styling"),
static, static,
view, view,
).Start(ctx) ))
}
func Start(ctx context.Context) {
for _, projection := range projections {
projection.Start(ctx)
}
}
func Projections() []*handler2.Handler {
return projections
} }
func (config Config) overwrite(viewModel string) handler2.Config { func (config Config) overwrite(viewModel string) handler2.Config {

View File

@ -20,6 +20,7 @@ func Start(ctx context.Context, conf Config, static static.Storage, dbClient *da
} }
admin_handler.Register(ctx, conf.Spooler, view, static) admin_handler.Register(ctx, conf.Spooler, view, static)
admin_handler.Start(ctx)
return nil return nil
} }

View File

@ -93,10 +93,11 @@ func (a *AccessInterceptor) Limit(w http.ResponseWriter, r *http.Request, public
remaining := a.logstoreSvc.Limit(ctx, instance.InstanceID()) remaining := a.logstoreSvc.Limit(ctx, instance.InstanceID())
if remaining != nil { if remaining != nil {
if remaining != nil && *remaining > 0 { if remaining != nil && *remaining > 0 {
a.SetExhaustedCookie(w, r) deleteCookie = true
return true return false
} }
deleteCookie = true a.SetExhaustedCookie(w, r)
return true
} }
return false return false
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/view" "github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/view"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
handler2 "github.com/zitadel/zitadel/internal/eventstore/handler/v2" handler2 "github.com/zitadel/zitadel/internal/eventstore/handler/v2"
query2 "github.com/zitadel/zitadel/internal/query" query2 "github.com/zitadel/zitadel/internal/query"
) )
@ -26,28 +27,40 @@ type ConfigOverwrites struct {
MinimumCycleDuration time.Duration MinimumCycleDuration time.Duration
} }
var projections []*handler.Handler
func Register(ctx context.Context, configs Config, view *view.View, queries *query2.Queries) { func Register(ctx context.Context, configs Config, view *view.View, queries *query2.Queries) {
newUser(ctx, projections = append(projections, newUser(ctx,
configs.overwrite("User"), configs.overwrite("User"),
view, view,
queries, queries,
).Start(ctx) ))
newUserSession(ctx, projections = append(projections, newUserSession(ctx,
configs.overwrite("UserSession"), configs.overwrite("UserSession"),
view, view,
queries, queries,
).Start(ctx) ))
newToken(ctx, projections = append(projections, newToken(ctx,
configs.overwrite("Token"), configs.overwrite("Token"),
view, view,
).Start(ctx) ))
newRefreshToken(ctx, projections = append(projections, newRefreshToken(ctx,
configs.overwrite("RefreshToken"), configs.overwrite("RefreshToken"),
view, view,
).Start(ctx) ))
}
func Start(ctx context.Context) {
for _, projection := range projections {
projection.Start(ctx)
}
}
func Projections() []*handler2.Handler {
return projections
} }
func (config Config) overwrite(viewModel string) handler2.Config { func (config Config) overwrite(viewModel string) handler2.Config {

View File

@ -38,6 +38,7 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, c
} }
auth_handler.Register(ctx, conf.Spooler, view, queries) auth_handler.Register(ctx, conf.Spooler, view, queries)
auth_handler.Start(ctx)
authReq := cache.Start(dbClient) authReq := cache.Start(dbClient)

View File

@ -22,23 +22,6 @@ import (
"github.com/zitadel/zitadel/internal/domain" "github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/id" "github.com/zitadel/zitadel/internal/id"
"github.com/zitadel/zitadel/internal/repository/action"
"github.com/zitadel/zitadel/internal/repository/authrequest"
"github.com/zitadel/zitadel/internal/repository/deviceauth"
"github.com/zitadel/zitadel/internal/repository/feature"
"github.com/zitadel/zitadel/internal/repository/idpintent"
instance_repo "github.com/zitadel/zitadel/internal/repository/instance"
"github.com/zitadel/zitadel/internal/repository/keypair"
"github.com/zitadel/zitadel/internal/repository/limits"
"github.com/zitadel/zitadel/internal/repository/milestone"
"github.com/zitadel/zitadel/internal/repository/oidcsession"
"github.com/zitadel/zitadel/internal/repository/org"
proj_repo "github.com/zitadel/zitadel/internal/repository/project"
"github.com/zitadel/zitadel/internal/repository/quota"
"github.com/zitadel/zitadel/internal/repository/restrictions"
"github.com/zitadel/zitadel/internal/repository/session"
usr_repo "github.com/zitadel/zitadel/internal/repository/user"
usr_grant_repo "github.com/zitadel/zitadel/internal/repository/usergrant"
"github.com/zitadel/zitadel/internal/static" "github.com/zitadel/zitadel/internal/static"
"github.com/zitadel/zitadel/internal/telemetry/tracing" "github.com/zitadel/zitadel/internal/telemetry/tracing"
webauthn_helper "github.com/zitadel/zitadel/internal/webauthn" webauthn_helper "github.com/zitadel/zitadel/internal/webauthn"
@ -151,24 +134,6 @@ func StartCommands(
samlCertificateAndKeyGenerator: samlCertificateAndKeyGenerator(defaults.KeyConfig.Size), samlCertificateAndKeyGenerator: samlCertificateAndKeyGenerator(defaults.KeyConfig.Size),
} }
instance_repo.RegisterEventMappers(repo.eventstore)
org.RegisterEventMappers(repo.eventstore)
usr_repo.RegisterEventMappers(repo.eventstore)
usr_grant_repo.RegisterEventMappers(repo.eventstore)
proj_repo.RegisterEventMappers(repo.eventstore)
keypair.RegisterEventMappers(repo.eventstore)
action.RegisterEventMappers(repo.eventstore)
quota.RegisterEventMappers(repo.eventstore)
limits.RegisterEventMappers(repo.eventstore)
restrictions.RegisterEventMappers(repo.eventstore)
session.RegisterEventMappers(repo.eventstore)
idpintent.RegisterEventMappers(repo.eventstore)
authrequest.RegisterEventMappers(repo.eventstore)
oidcsession.RegisterEventMappers(repo.eventstore)
milestone.RegisterEventMappers(repo.eventstore)
feature.RegisterEventMappers(repo.eventstore)
deviceauth.RegisterEventMappers(repo.eventstore)
repo.codeAlg = crypto.NewBCrypt(defaults.SecretGenerators.PasswordSaltCost) repo.codeAlg = crypto.NewBCrypt(defaults.SecretGenerators.PasswordSaltCost)
repo.userPasswordHasher, err = defaults.PasswordHasher.PasswordHasher() repo.userPasswordHasher, err = defaults.PasswordHasher.PasswordHasher()
if err != nil { if err != nil {

View File

@ -17,22 +17,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository" "github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/eventstore/repository/mock" "github.com/zitadel/zitadel/internal/eventstore/repository/mock"
action_repo "github.com/zitadel/zitadel/internal/repository/action"
"github.com/zitadel/zitadel/internal/repository/authrequest"
"github.com/zitadel/zitadel/internal/repository/deviceauth"
"github.com/zitadel/zitadel/internal/repository/feature"
"github.com/zitadel/zitadel/internal/repository/idpintent"
iam_repo "github.com/zitadel/zitadel/internal/repository/instance"
key_repo "github.com/zitadel/zitadel/internal/repository/keypair"
"github.com/zitadel/zitadel/internal/repository/limits"
"github.com/zitadel/zitadel/internal/repository/oidcsession"
"github.com/zitadel/zitadel/internal/repository/org"
proj_repo "github.com/zitadel/zitadel/internal/repository/project"
quota_repo "github.com/zitadel/zitadel/internal/repository/quota"
"github.com/zitadel/zitadel/internal/repository/restrictions"
"github.com/zitadel/zitadel/internal/repository/session"
usr_repo "github.com/zitadel/zitadel/internal/repository/user"
"github.com/zitadel/zitadel/internal/repository/usergrant"
"github.com/zitadel/zitadel/internal/zerrors" "github.com/zitadel/zitadel/internal/zerrors"
) )
@ -49,22 +33,6 @@ func eventstoreExpect(t *testing.T, expects ...expect) *eventstore.Eventstore {
Pusher: m.MockPusher, Pusher: m.MockPusher,
}, },
) )
iam_repo.RegisterEventMappers(es)
org.RegisterEventMappers(es)
usr_repo.RegisterEventMappers(es)
proj_repo.RegisterEventMappers(es)
usergrant.RegisterEventMappers(es)
key_repo.RegisterEventMappers(es)
action_repo.RegisterEventMappers(es)
session.RegisterEventMappers(es)
idpintent.RegisterEventMappers(es)
authrequest.RegisterEventMappers(es)
oidcsession.RegisterEventMappers(es)
quota_repo.RegisterEventMappers(es)
limits.RegisterEventMappers(es)
restrictions.RegisterEventMappers(es)
feature.RegisterEventMappers(es)
deviceauth.RegisterEventMappers(es)
return es return es
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/zitadel/zitadel/internal/zerrors" "github.com/zitadel/zitadel/internal/zerrors"
) )
type database struct { type Database struct {
client *z_db.DB client *z_db.DB
masterKey string masterKey string
encrypt func(key, masterKey string) (encryptedKey string, err error) encrypt func(key, masterKey string) (encryptedKey string, err error)
@ -24,11 +24,11 @@ const (
encryptionKeysKeyCol = "key" encryptionKeysKeyCol = "key"
) )
func NewKeyStorage(client *z_db.DB, masterKey string) (*database, error) { func NewKeyStorage(client *z_db.DB, masterKey string) (*Database, error) {
if err := checkMasterKeyLength(masterKey); err != nil { if err := checkMasterKeyLength(masterKey); err != nil {
return nil, err return nil, err
} }
return &database{ return &Database{
client: client, client: client,
masterKey: masterKey, masterKey: masterKey,
encrypt: crypto.EncryptAESString, encrypt: crypto.EncryptAESString,
@ -36,7 +36,7 @@ func NewKeyStorage(client *z_db.DB, masterKey string) (*database, error) {
}, nil }, nil
} }
func (d *database) ReadKeys() (crypto.Keys, error) { func (d *Database) ReadKeys() (crypto.Keys, error) {
keys := make(map[string]string) keys := make(map[string]string)
stmt, args, err := sq.Select(encryptionKeysIDCol, encryptionKeysKeyCol). stmt, args, err := sq.Select(encryptionKeysIDCol, encryptionKeysKeyCol).
From(EncryptionKeysTable). From(EncryptionKeysTable).
@ -67,7 +67,7 @@ func (d *database) ReadKeys() (crypto.Keys, error) {
return keys, nil return keys, nil
} }
func (d *database) ReadKey(id string) (_ *crypto.Key, err error) { func (d *Database) ReadKey(id string) (_ *crypto.Key, err error) {
stmt, args, err := sq.Select(encryptionKeysKeyCol). stmt, args, err := sq.Select(encryptionKeysKeyCol).
From(EncryptionKeysTable). From(EncryptionKeysTable).
Where(sq.Eq{encryptionKeysIDCol: id}). Where(sq.Eq{encryptionKeysIDCol: id}).
@ -99,7 +99,7 @@ func (d *database) ReadKey(id string) (_ *crypto.Key, err error) {
}, nil }, nil
} }
func (d *database) CreateKeys(ctx context.Context, keys ...*crypto.Key) error { func (d *Database) CreateKeys(ctx context.Context, keys ...*crypto.Key) error {
insert := sq.Insert(EncryptionKeysTable). insert := sq.Insert(EncryptionKeysTable).
Columns(encryptionKeysIDCol, encryptionKeysKeyCol).PlaceholderFormat(sq.Dollar) Columns(encryptionKeysIDCol, encryptionKeysKeyCol).PlaceholderFormat(sq.Dollar)
for _, key := range keys { for _, key := range keys {

View File

@ -115,7 +115,7 @@ func Test_database_ReadKeys(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
d := &database{ d := &Database{
client: tt.fields.client.db, client: tt.fields.client.db,
masterKey: tt.fields.masterKey, masterKey: tt.fields.masterKey,
decrypt: tt.fields.decrypt, decrypt: tt.fields.decrypt,
@ -247,7 +247,7 @@ func Test_database_ReadKey(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
d := &database{ d := &Database{
client: tt.fields.client.db, client: tt.fields.client.db,
masterKey: tt.fields.masterKey, masterKey: tt.fields.masterKey,
decrypt: tt.fields.decrypt, decrypt: tt.fields.decrypt,
@ -391,7 +391,7 @@ func Test_database_CreateKeys(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
d := &database{ d := &Database{
client: tt.fields.client.db, client: tt.fields.client.db,
masterKey: tt.fields.masterKey, masterKey: tt.fields.masterKey,
encrypt: tt.fields.encrypt, encrypt: tt.fields.encrypt,

View File

@ -12,13 +12,7 @@ import (
// Eventstore abstracts all functions needed to store valid events // Eventstore abstracts all functions needed to store valid events
// and filters the stored events // and filters the stored events
type Eventstore struct { type Eventstore struct {
// TODO: get rid of this mutex, PushTimeout time.Duration
// or if we scale to >4vCPU use a sync.Map
interceptorMutex sync.RWMutex
eventInterceptors map[EventType]eventTypeInterceptors
eventTypes []string
aggregateTypes []string
PushTimeout time.Duration
pusher Pusher pusher Pusher
querier Querier querier Querier
@ -28,14 +22,36 @@ type Eventstore struct {
instancesMu sync.Mutex instancesMu sync.Mutex
} }
var (
eventInterceptors map[EventType]eventTypeInterceptors
eventTypes []string
aggregateTypes []string
)
// RegisterFilterEventMapper registers a function for mapping an eventstore event to an event
func RegisterFilterEventMapper(aggregateType AggregateType, eventType EventType, mapper func(Event) (Event, error)) {
if mapper == nil || eventType == "" {
return
}
appendEventType(eventType)
appendAggregateType(aggregateType)
if eventInterceptors == nil {
eventInterceptors = make(map[EventType]eventTypeInterceptors)
}
interceptor := eventInterceptors[eventType]
interceptor.eventMapper = mapper
eventInterceptors[eventType] = interceptor
}
type eventTypeInterceptors struct { type eventTypeInterceptors struct {
eventMapper func(Event) (Event, error) eventMapper func(Event) (Event, error)
} }
func NewEventstore(config *Config) *Eventstore { func NewEventstore(config *Config) *Eventstore {
return &Eventstore{ return &Eventstore{
eventInterceptors: map[EventType]eventTypeInterceptors{}, PushTimeout: config.PushTimeout,
PushTimeout: config.PushTimeout,
pusher: config.Pusher, pusher: config.Pusher,
querier: config.Querier, querier: config.Querier,
@ -75,11 +91,11 @@ func (es *Eventstore) Push(ctx context.Context, cmds ...Command) ([]Event, error
} }
func (es *Eventstore) EventTypes() []string { func (es *Eventstore) EventTypes() []string {
return es.eventTypes return eventTypes
} }
func (es *Eventstore) AggregateTypes() []string { func (es *Eventstore) AggregateTypes() []string {
return es.aggregateTypes return aggregateTypes
} }
// Filter filters the stored events based on the searchQuery // Filter filters the stored events based on the searchQuery
@ -105,28 +121,21 @@ func (es *Eventstore) Filter(ctx context.Context, searchQuery *SearchQueryBuilde
func (es *Eventstore) mapEvents(events []Event) (mappedEvents []Event, err error) { func (es *Eventstore) mapEvents(events []Event) (mappedEvents []Event, err error) {
mappedEvents = make([]Event, len(events)) mappedEvents = make([]Event, len(events))
es.interceptorMutex.RLock()
defer es.interceptorMutex.RUnlock()
for i, event := range events { for i, event := range events {
mappedEvents[i], err = es.mapEventLocked(event) mappedEvents[i], err = es.mapEventLocked(event)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
return mappedEvents, nil return mappedEvents, nil
} }
func (es *Eventstore) mapEvent(event Event) (Event, error) { func (es *Eventstore) mapEvent(event Event) (Event, error) {
es.interceptorMutex.RLock()
defer es.interceptorMutex.RUnlock()
return es.mapEventLocked(event) return es.mapEventLocked(event)
} }
func (es *Eventstore) mapEventLocked(event Event) (Event, error) { func (es *Eventstore) mapEventLocked(event Event) (Event, error) {
interceptors, ok := es.eventInterceptors[event.Type()] interceptors, ok := eventInterceptors[event.Type()]
if !ok || interceptors.eventMapper == nil { if !ok || interceptors.eventMapper == nil {
return BaseEventFromRepo(event), nil return BaseEventFromRepo(event), nil
} }
@ -204,24 +213,6 @@ func (es *Eventstore) FilterToQueryReducer(ctx context.Context, r QueryReducer)
return es.FilterToReducer(ctx, r.Query(), r) return es.FilterToReducer(ctx, r.Query(), r)
} }
// RegisterFilterEventMapper registers a function for mapping an eventstore event to an event
func (es *Eventstore) RegisterFilterEventMapper(aggregateType AggregateType, eventType EventType, mapper func(Event) (Event, error)) *Eventstore {
if mapper == nil || eventType == "" {
return es
}
es.interceptorMutex.Lock()
defer es.interceptorMutex.Unlock()
es.appendEventType(eventType)
es.appendAggregateType(aggregateType)
interceptor := es.eventInterceptors[eventType]
interceptor.eventMapper = mapper
es.eventInterceptors[eventType] = interceptor
return es
}
type Reducer func(event Event) error type Reducer func(event Event) error
type Querier interface { type Querier interface {
@ -242,18 +233,18 @@ type Pusher interface {
Push(ctx context.Context, commands ...Command) (_ []Event, err error) Push(ctx context.Context, commands ...Command) (_ []Event, err error)
} }
func (es *Eventstore) appendEventType(typ EventType) { func appendEventType(typ EventType) {
i := sort.SearchStrings(es.eventTypes, string(typ)) i := sort.SearchStrings(eventTypes, string(typ))
if i < len(es.eventTypes) && es.eventTypes[i] == string(typ) { if i < len(eventTypes) && eventTypes[i] == string(typ) {
return return
} }
es.eventTypes = append(es.eventTypes[:i], append([]string{string(typ)}, es.eventTypes[i:]...)...) eventTypes = append(eventTypes[:i], append([]string{string(typ)}, eventTypes[i:]...)...)
} }
func (es *Eventstore) appendAggregateType(typ AggregateType) { func appendAggregateType(typ AggregateType) {
i := sort.SearchStrings(es.aggregateTypes, string(typ)) i := sort.SearchStrings(aggregateTypes, string(typ))
if len(es.aggregateTypes) > i && es.aggregateTypes[i] == string(typ) { if len(aggregateTypes) > i && aggregateTypes[i] == string(typ) {
return return
} }
es.aggregateTypes = append(es.aggregateTypes[:i], append([]string{string(typ)}, es.aggregateTypes[i:]...)...) aggregateTypes = append(aggregateTypes[:i], append([]string{string(typ)}, aggregateTypes[i:]...)...)
} }

View File

@ -139,12 +139,11 @@ func Test_eventstore_RegisterFilterEventMapper(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
es := &Eventstore{
eventInterceptors: tt.fields.eventMapper, eventInterceptors = tt.fields.eventMapper
} RegisterFilterEventMapper("test", tt.args.eventType, tt.args.mapper)
es = es.RegisterFilterEventMapper("test", tt.args.eventType, tt.args.mapper) if len(eventInterceptors) != tt.res.mapperCount {
if len(es.eventInterceptors) != tt.res.mapperCount { t.Errorf("unexpected mapper count: want %d, got %d", tt.res.mapperCount, len(eventInterceptors))
t.Errorf("unexpected mapper count: want %d, got %d", tt.res.mapperCount, len(es.eventInterceptors))
return return
} }
@ -152,7 +151,7 @@ func Test_eventstore_RegisterFilterEventMapper(t *testing.T) {
return return
} }
mapper := es.eventInterceptors[tt.args.eventType] mapper := eventInterceptors[tt.args.eventType]
event, err := mapper.eventMapper(nil) event, err := mapper.eventMapper(nil)
if err != nil { if err != nil {
t.Errorf("unexpected error %v", err) t.Errorf("unexpected error %v", err)
@ -694,15 +693,15 @@ func TestEventstore_Push(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
eventInterceptors = map[EventType]eventTypeInterceptors{}
es := &Eventstore{ es := &Eventstore{
pusher: tt.fields.pusher, pusher: tt.fields.pusher,
eventInterceptors: map[EventType]eventTypeInterceptors{},
} }
for eventType, mapper := range tt.fields.eventMapper { for eventType, mapper := range tt.fields.eventMapper {
es = es.RegisterFilterEventMapper("test", eventType, mapper) RegisterFilterEventMapper("test", eventType, mapper)
} }
if len(es.eventInterceptors) != len(tt.fields.eventMapper) { if len(eventInterceptors) != len(tt.fields.eventMapper) {
t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(es.eventInterceptors)) t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(eventInterceptors))
t.FailNow() t.FailNow()
} }
@ -825,16 +824,16 @@ func TestEventstore_FilterEvents(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
eventInterceptors = map[EventType]eventTypeInterceptors{}
es := &Eventstore{ es := &Eventstore{
querier: tt.fields.repo, querier: tt.fields.repo,
eventInterceptors: map[EventType]eventTypeInterceptors{},
} }
for eventType, mapper := range tt.fields.eventMapper { for eventType, mapper := range tt.fields.eventMapper {
es = es.RegisterFilterEventMapper("test", eventType, mapper) RegisterFilterEventMapper("test", eventType, mapper)
} }
if len(es.eventInterceptors) != len(tt.fields.eventMapper) { if len(eventInterceptors) != len(tt.fields.eventMapper) {
t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(es.eventInterceptors)) t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(eventInterceptors))
t.FailNow() t.FailNow()
} }
@ -1130,14 +1129,13 @@ func TestEventstore_FilterToReducer(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
es := &Eventstore{ es := &Eventstore{
querier: tt.fields.repo, querier: tt.fields.repo,
eventInterceptors: map[EventType]eventTypeInterceptors{},
} }
for eventType, mapper := range tt.fields.eventMapper { for eventType, mapper := range tt.fields.eventMapper {
es = es.RegisterFilterEventMapper("test", eventType, mapper) RegisterFilterEventMapper("test", eventType, mapper)
} }
if len(es.eventInterceptors) != len(tt.fields.eventMapper) { if len(eventInterceptors) != len(tt.fields.eventMapper) {
t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(es.eventInterceptors)) t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(eventInterceptors))
t.FailNow() t.FailNow()
} }
@ -1246,14 +1244,12 @@ func TestEventstore_mapEvents(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
es := &Eventstore{ es := &Eventstore{}
eventInterceptors: map[EventType]eventTypeInterceptors{},
}
for eventType, mapper := range tt.fields.eventMapper { for eventType, mapper := range tt.fields.eventMapper {
es = es.RegisterFilterEventMapper("test", eventType, mapper) RegisterFilterEventMapper("test", eventType, mapper)
} }
if len(es.eventInterceptors) != len(tt.fields.eventMapper) { if len(eventInterceptors) != len(tt.fields.eventMapper) {
t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(es.eventInterceptors)) t.Errorf("register event mapper failed expected mapper amount: %d, got: %d", len(tt.fields.eventMapper), len(eventInterceptors))
t.FailNow() t.FailNow()
} }

View File

@ -294,10 +294,10 @@ func TestUserReadModel(t *testing.T) {
}, },
) )
es.RegisterFilterEventMapper(UserAddedEventMapper()). eventstore.RegisterFilterEventMapper(UserAddedEventMapper())
RegisterFilterEventMapper(UserFirstNameChangedMapper()). eventstore.RegisterFilterEventMapper(UserFirstNameChangedMapper())
RegisterFilterEventMapper(UserPasswordCheckedMapper()). eventstore.RegisterFilterEventMapper(UserPasswordCheckedMapper())
RegisterFilterEventMapper(UserDeletedMapper()) eventstore.RegisterFilterEventMapper(UserDeletedMapper())
events, err := es.Push(context.Background(), events, err := es.Push(context.Background(),
NewUserAddedEvent("1", "hodor"), NewUserAddedEvent("1", "hodor"),

View File

@ -1,52 +0,0 @@
package handler
import (
"context"
"github.com/zitadel/zitadel/internal/eventstore"
)
const (
schedulerSucceeded = eventstore.EventType("system.projections.scheduler.succeeded")
aggregateType = eventstore.AggregateType("system")
aggregateID = "SYSTEM"
)
func (h *Handler) didProjectionInitialize(ctx context.Context) bool {
events, err := h.es.Filter(ctx, eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
InstanceID("").
AddQuery().
AggregateTypes(aggregateType).
AggregateIDs(aggregateID).
EventTypes(schedulerSucceeded).
EventData(map[string]interface{}{
"name": h.projection.Name(),
}).
Builder(),
)
return len(events) > 0 && err == nil
}
func (h *Handler) setSucceededOnce(ctx context.Context) error {
_, err := h.es.Push(ctx, &ProjectionSucceededEvent{
BaseEvent: *eventstore.NewBaseEventForPush(ctx,
eventstore.NewAggregate(ctx, aggregateID, aggregateType, "v1"),
schedulerSucceeded,
),
Name: h.projection.Name(),
})
return err
}
type ProjectionSucceededEvent struct {
eventstore.BaseEvent `json:"-"`
Name string `json:"name"`
}
func (p *ProjectionSucceededEvent) Payload() interface{} {
return p
}
func (p *ProjectionSucceededEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}

View File

@ -6,20 +6,26 @@ import (
"errors" "errors"
"math" "math"
"math/rand" "math/rand"
"slices"
"sync" "sync"
"time" "time"
"github.com/jackc/pgconn" "github.com/jackc/pgconn"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/api/authz" "github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/api/call" "github.com/zitadel/zitadel/internal/api/call"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/migration"
"github.com/zitadel/zitadel/internal/repository/instance"
"github.com/zitadel/zitadel/internal/repository/pseudo" "github.com/zitadel/zitadel/internal/repository/pseudo"
) )
type EventStore interface { type EventStore interface {
InstanceIDs(ctx context.Context, maxAge time.Duration, forceLoad bool, query *eventstore.SearchQueryBuilder) ([]string, error) InstanceIDs(ctx context.Context, maxAge time.Duration, forceLoad bool, query *eventstore.SearchQueryBuilder) ([]string, error)
FilterToQueryReducer(ctx context.Context, reducer eventstore.QueryReducer) error
Filter(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) Filter(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error)
Push(ctx context.Context, cmds ...eventstore.Command) ([]eventstore.Event, error) Push(ctx context.Context, cmds ...eventstore.Command) ([]eventstore.Event, error)
} }
@ -58,6 +64,70 @@ type Handler struct {
triggerWithoutEvents Reduce triggerWithoutEvents Reduce
} }
var _ migration.Migration = (*Handler)(nil)
// Execute implements migration.Migration.
func (h *Handler) Execute(ctx context.Context, startedEvent eventstore.Event) error {
start := time.Now()
logging.WithFields("projection", h.ProjectionName()).Info("projection starts prefilling")
logTicker := time.NewTicker(30 * time.Second)
go func() {
for range logTicker.C {
logging.WithFields("projection", h.ProjectionName()).Info("projection is prefilling")
}
}()
instanceIDs, err := h.existingInstances(ctx)
if err != nil {
return err
}
// default amount of workers is 10
workerCount := 10
if h.client.DB.Stats().MaxOpenConnections > 0 {
workerCount = h.client.DB.Stats().MaxOpenConnections / 4
}
// ensure that at least one worker is active
if workerCount == 0 {
workerCount = 1
}
// spawn less workers if not all workers needed
if workerCount > len(instanceIDs) {
workerCount = len(instanceIDs)
}
instances := make(chan string, workerCount)
var wg sync.WaitGroup
wg.Add(workerCount)
for i := 0; i < workerCount; i++ {
go h.executeInstances(ctx, instances, startedEvent, &wg)
}
for _, instance := range instanceIDs {
instances <- instance
}
close(instances)
wg.Wait()
logTicker.Stop()
logging.WithFields("projection", h.ProjectionName(), "took", time.Since(start)).Info("projections ended prefilling")
return nil
}
func (h *Handler) executeInstances(ctx context.Context, instances <-chan string, startedEvent eventstore.Event, wg *sync.WaitGroup) {
for instance := range instances {
h.triggerInstances(ctx, []string{instance}, WithMaxPosition(startedEvent.Position()))
}
wg.Done()
}
// String implements migration.Migration.
func (h *Handler) String() string {
return h.ProjectionName()
}
// nowFunc makes [time.Now] mockable // nowFunc makes [time.Now] mockable
type nowFunc func() time.Time type nowFunc func() time.Time
@ -111,21 +181,56 @@ func (h *Handler) Start(ctx context.Context) {
go h.subscribe(ctx) go h.subscribe(ctx)
} }
func (h *Handler) schedule(ctx context.Context) { type checkInit struct {
// if there was no run before trigger within half a second didInit bool
start := randomizeStart(0, 0.5) projectionName string
t := time.NewTimer(start) }
didInitialize := h.didProjectionInitialize(ctx)
if didInitialize { // AppendEvents implements eventstore.QueryReducer.
if !t.Stop() { func (ci *checkInit) AppendEvents(...eventstore.Event) {
<-t.C ci.didInit = true
} }
// if there was a trigger before, start the projection
// after a second (should generally be after the not initialized projections) // Query implements eventstore.QueryReducer.
// and its configured `RequeueEvery` func (ci *checkInit) Query() *eventstore.SearchQueryBuilder {
reset := randomizeStart(1, h.requeueEvery.Seconds()) return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
t.Reset(reset) Limit(1).
InstanceID("").
AddQuery().
AggregateTypes(migration.SystemAggregate).
AggregateIDs(migration.SystemAggregateID).
EventTypes(migration.DoneType).
EventData(map[string]interface{}{
"name": ci.projectionName,
}).
Builder()
}
// Reduce implements eventstore.QueryReducer.
func (*checkInit) Reduce() error {
return nil
}
var _ eventstore.QueryReducer = (*checkInit)(nil)
func (h *Handler) didInitialize(ctx context.Context) bool {
initiated := checkInit{
projectionName: h.ProjectionName(),
} }
err := h.es.FilterToQueryReducer(ctx, &initiated)
if err != nil {
return false
}
return initiated.didInit
}
func (h *Handler) schedule(ctx context.Context) {
// start the projection and its configured `RequeueEvery`
reset := randomizeStart(0, h.requeueEvery.Seconds())
if !h.didInitialize(ctx) {
reset = randomizeStart(0, 0.5)
}
t := time.NewTimer(reset)
for { for {
select { select {
@ -133,40 +238,34 @@ func (h *Handler) schedule(ctx context.Context) {
t.Stop() t.Stop()
return return
case <-t.C: case <-t.C:
instances, err := h.queryInstances(ctx, didInitialize) instances, err := h.queryInstances(ctx)
h.log().OnError(err).Debug("unable to query instances") h.log().OnError(err).Debug("unable to query instances")
var instanceFailed bool h.triggerInstances(call.WithTimestamp(ctx), instances)
scheduledCtx := call.WithTimestamp(ctx)
for _, instance := range instances {
instanceCtx := authz.WithInstanceID(scheduledCtx, instance)
// simple implementation of do while
_, err = h.Trigger(instanceCtx)
instanceFailed = instanceFailed || err != nil
h.log().WithField("instance", instance).OnError(err).Info("scheduled trigger failed")
time.Sleep(h.retryFailedAfter)
// retry if trigger failed
for ; err != nil; _, err = h.Trigger(instanceCtx) {
time.Sleep(h.retryFailedAfter)
instanceFailed = instanceFailed || err != nil
h.log().WithField("instance", instance).OnError(err).Info("scheduled trigger failed")
if err == nil {
break
}
}
}
if !didInitialize && !instanceFailed {
err = h.setSucceededOnce(ctx)
h.log().OnError(err).Debug("unable to set succeeded once")
didInitialize = err == nil
}
t.Reset(h.requeueEvery) t.Reset(h.requeueEvery)
} }
} }
} }
func (h *Handler) triggerInstances(ctx context.Context, instances []string, triggerOpts ...TriggerOpt) {
for _, instance := range instances {
instanceCtx := authz.WithInstanceID(ctx, instance)
// simple implementation of do while
_, err := h.Trigger(instanceCtx, triggerOpts...)
h.log().WithField("instance", instance).OnError(err).Debug("trigger failed")
time.Sleep(h.retryFailedAfter)
// retry if trigger failed
for ; err != nil; _, err = h.Trigger(instanceCtx, triggerOpts...) {
time.Sleep(h.retryFailedAfter)
h.log().WithField("instance", instance).OnError(err).Debug("trigger failed")
if err == nil {
break
}
}
}
}
func randomizeStart(min, maxSeconds float64) time.Duration { func randomizeStart(min, maxSeconds float64) time.Duration {
d := min + rand.Float64()*(maxSeconds-min) d := min + rand.Float64()*(maxSeconds-min)
return time.Duration(d*1000) * time.Millisecond return time.Duration(d*1000) * time.Millisecond
@ -223,31 +322,84 @@ func checkAdditionalEvents(eventQueue chan eventstore.Event, event eventstore.Ev
} }
} }
func (h *Handler) queryInstances(ctx context.Context, didInitialize bool) ([]string, error) { type existingInstances []string
// AppendEvents implements eventstore.QueryReducer.
func (ai *existingInstances) AppendEvents(events ...eventstore.Event) {
for _, event := range events {
switch event.Type() {
case instance.InstanceAddedEventType:
*ai = append(*ai, event.Aggregate().InstanceID)
case instance.InstanceRemovedEventType:
slices.DeleteFunc(*ai, func(s string) bool {
return s == event.Aggregate().InstanceID
})
}
}
}
// Query implements eventstore.QueryReducer.
func (*existingInstances) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
AddQuery().
AggregateTypes(instance.AggregateType).
EventTypes(
instance.InstanceAddedEventType,
instance.InstanceRemovedEventType,
).
Builder()
}
// Reduce implements eventstore.QueryReducer.
// reduce is not used as events are reduced during AppendEvents
func (*existingInstances) Reduce() error {
return nil
}
var _ eventstore.QueryReducer = (*existingInstances)(nil)
func (h *Handler) queryInstances(ctx context.Context) ([]string, error) {
if h.handleActiveInstances == 0 {
return h.existingInstances(ctx)
}
query := eventstore.NewSearchQueryBuilder(eventstore.ColumnsInstanceIDs). query := eventstore.NewSearchQueryBuilder(eventstore.ColumnsInstanceIDs).
AwaitOpenTransactions(). AwaitOpenTransactions().
AllowTimeTravel(). AllowTimeTravel().
ExcludedInstanceID("") CreationDateAfter(h.now().Add(-1 * h.handleActiveInstances))
if didInitialize && h.handleActiveInstances > 0 {
query = query. return h.es.InstanceIDs(ctx, h.requeueEvery, false, query)
CreationDateAfter(h.now().Add(-1 * h.handleActiveInstances)) }
func (h *Handler) existingInstances(ctx context.Context) ([]string, error) {
ai := existingInstances{}
if err := h.es.FilterToQueryReducer(ctx, &ai); err != nil {
return nil, err
} }
return h.es.InstanceIDs(ctx, h.requeueEvery, !didInitialize, query)
return ai, nil
} }
type triggerConfig struct { type triggerConfig struct {
awaitRunning bool awaitRunning bool
maxPosition float64
} }
type triggerOpt func(conf *triggerConfig) type TriggerOpt func(conf *triggerConfig)
func WithAwaitRunning() triggerOpt { func WithAwaitRunning() TriggerOpt {
return func(conf *triggerConfig) { return func(conf *triggerConfig) {
conf.awaitRunning = true conf.awaitRunning = true
} }
} }
func (h *Handler) Trigger(ctx context.Context, opts ...triggerOpt) (_ context.Context, err error) { func WithMaxPosition(position float64) TriggerOpt {
return func(conf *triggerConfig) {
conf.maxPosition = position
}
}
func (h *Handler) Trigger(ctx context.Context, opts ...TriggerOpt) (_ context.Context, err error) {
config := new(triggerConfig) config := new(triggerConfig)
for _, opt := range opts { for _, opt := range opts {
opt(config) opt(config)
@ -261,7 +413,7 @@ func (h *Handler) Trigger(ctx context.Context, opts ...triggerOpt) (_ context.Co
for i := 0; ; i++ { for i := 0; ; i++ {
additionalIteration, err := h.processEvents(ctx, config) additionalIteration, err := h.processEvents(ctx, config)
h.log().OnError(err).Warn("process events failed") h.log().OnError(err).Info("process events failed")
h.log().WithField("iteration", i).Debug("trigger iteration") h.log().WithField("iteration", i).Debug("trigger iteration")
if !additionalIteration || err != nil { if !additionalIteration || err != nil {
return call.ResetTimestamp(ctx), err return call.ResetTimestamp(ctx), err
@ -350,6 +502,10 @@ func (h *Handler) processEvents(ctx context.Context, config *triggerConfig) (add
} }
return additionalIteration, err return additionalIteration, err
} }
// stop execution if currentState.eventTimestamp >= config.maxCreatedAt
if config.maxPosition != 0 && currentState.position >= config.maxPosition {
return false, nil
}
var statements []*Statement var statements []*Statement
statements, additionalIteration, err = h.generateStatements(ctx, tx, currentState) statements, additionalIteration, err = h.generateStatements(ctx, tx, currentState)
@ -362,6 +518,7 @@ func (h *Handler) processEvents(ctx context.Context, config *triggerConfig) (add
} }
lastProcessedIndex, err := h.executeStatements(ctx, tx, currentState, statements) lastProcessedIndex, err := h.executeStatements(ctx, tx, currentState, statements)
h.log().OnError(err).WithField("lastProcessedIndex", lastProcessedIndex).Debug("execution of statements failed")
if lastProcessedIndex < 0 { if lastProcessedIndex < 0 {
return false, err return false, err
} }

View File

@ -134,7 +134,6 @@ func QueryFromBuilder(builder *eventstore.SearchQueryBuilder) (*SearchQuery, err
for _, f := range []func(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter{ for _, f := range []func(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter{
instanceIDFilter, instanceIDFilter,
instanceIDsFilter, instanceIDsFilter,
excludedInstanceIDFilter,
editorUserFilter, editorUserFilter,
resourceOwnerFilter, resourceOwnerFilter,
positionAfterFilter, positionAfterFilter,
@ -184,14 +183,6 @@ func eventSequenceGreaterFilter(builder *eventstore.SearchQueryBuilder, query *S
return query.Sequence return query.Sequence
} }
func excludedInstanceIDFilter(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter {
if len(builder.GetExcludedInstanceIDs()) == 0 {
return nil
}
query.ExcludedInstances = NewFilter(FieldInstanceID, database.TextArray[string](builder.GetExcludedInstanceIDs()), OperationNotIn)
return query.ExcludedInstances
}
func creationDateAfterFilter(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter { func creationDateAfterFilter(builder *eventstore.SearchQueryBuilder, query *SearchQuery) *Filter {
if builder.GetCreationDateAfter().IsZero() { if builder.GetCreationDateAfter().IsZero() {
return nil return nil

View File

@ -19,7 +19,6 @@ type SearchQueryBuilder struct {
resourceOwner string resourceOwner string
instanceID *string instanceID *string
instanceIDs []string instanceIDs []string
excludedInstanceIDs []string
editorUser string editorUser string
queries []*SearchQuery queries []*SearchQuery
tx *sql.Tx tx *sql.Tx
@ -83,10 +82,6 @@ func (b SearchQueryBuilder) GetAwaitOpenTransactions() bool {
return b.awaitOpenTransactions return b.awaitOpenTransactions
} }
func (q SearchQueryBuilder) GetExcludedInstanceIDs() []string {
return q.excludedInstanceIDs
}
func (q SearchQueryBuilder) GetEventSequenceGreater() uint64 { func (q SearchQueryBuilder) GetEventSequenceGreater() uint64 {
return q.eventSequenceGreater return q.eventSequenceGreater
} }
@ -289,12 +284,6 @@ func (builder *SearchQueryBuilder) SequenceGreater(sequence uint64) *SearchQuery
return builder return builder
} }
// ExcludedInstanceID filters for events not having the given instanceIDs
func (builder *SearchQueryBuilder) ExcludedInstanceID(instanceIDs ...string) *SearchQueryBuilder {
builder.excludedInstanceIDs = instanceIDs
return builder
}
// CreationDateAfter filters for events which happened after the specified time // CreationDateAfter filters for events which happened after the specified time
func (builder *SearchQueryBuilder) CreationDateAfter(creationDate time.Time) *SearchQueryBuilder { func (builder *SearchQueryBuilder) CreationDateAfter(creationDate time.Time) *SearchQueryBuilder {
if creationDate.IsZero() || creationDate.Unix() == 0 { if creationDate.IsZero() || creationDate.Unix() == 0 {

View File

@ -49,3 +49,6 @@ SystemAPIUsers:
- "SYSTEM_OWNER" - "SYSTEM_OWNER"
- "IAM_OWNER" - "IAM_OWNER"
- "ORG_OWNER" - "ORG_OWNER"
InitProjections:
Enabled: true

View File

@ -9,6 +9,13 @@ import (
"github.com/zitadel/zitadel/internal/zerrors" "github.com/zitadel/zitadel/internal/zerrors"
) )
func init() {
eventstore.RegisterFilterEventMapper(SystemAggregate, StartedType, SetupMapper)
eventstore.RegisterFilterEventMapper(SystemAggregate, DoneType, SetupMapper)
eventstore.RegisterFilterEventMapper(SystemAggregate, failedType, SetupMapper)
eventstore.RegisterFilterEventMapper(SystemAggregate, repeatableDoneType, SetupMapper)
}
// SetupStep is the command pushed on the eventstore // SetupStep is the command pushed on the eventstore
type SetupStep struct { type SetupStep struct {
eventstore.BaseEvent `json:"-"` eventstore.BaseEvent `json:"-"`
@ -23,7 +30,7 @@ func setupStartedCmd(ctx context.Context, migration Migration) eventstore.Comman
return &SetupStep{ return &SetupStep{
BaseEvent: *eventstore.NewBaseEventForPush( BaseEvent: *eventstore.NewBaseEventForPush(
ctx, ctx,
eventstore.NewAggregate(ctx, aggregateID, aggregateType, "v1"), eventstore.NewAggregate(ctx, SystemAggregateID, SystemAggregate, "v1"),
StartedType), StartedType),
migration: migration, migration: migration,
Name: migration.String(), Name: migration.String(),
@ -32,7 +39,7 @@ func setupStartedCmd(ctx context.Context, migration Migration) eventstore.Comman
func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstore.Command { func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstore.Command {
ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"}) ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"})
typ := doneType typ := DoneType
var lastRun interface{} var lastRun interface{}
if repeatable, ok := migration.(RepeatableMigration); ok { if repeatable, ok := migration.(RepeatableMigration); ok {
typ = repeatableDoneType typ = repeatableDoneType
@ -51,7 +58,7 @@ func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstor
s.BaseEvent = *eventstore.NewBaseEventForPush( s.BaseEvent = *eventstore.NewBaseEventForPush(
ctx, ctx,
eventstore.NewAggregate(ctx, aggregateID, aggregateType, "v1"), eventstore.NewAggregate(ctx, SystemAggregateID, SystemAggregate, "v1"),
typ) typ)
return s return s
@ -79,13 +86,6 @@ func (s *SetupStep) UniqueConstraints() []*eventstore.UniqueConstraint {
} }
} }
func RegisterMappers(es *eventstore.Eventstore) {
es.RegisterFilterEventMapper(aggregateType, StartedType, SetupMapper)
es.RegisterFilterEventMapper(aggregateType, doneType, SetupMapper)
es.RegisterFilterEventMapper(aggregateType, failedType, SetupMapper)
es.RegisterFilterEventMapper(aggregateType, repeatableDoneType, SetupMapper)
}
func SetupMapper(event eventstore.Event) (eventstore.Event, error) { func SetupMapper(event eventstore.Event) (eventstore.Event, error) {
step := &SetupStep{ step := &SetupStep{
BaseEvent: *eventstore.BaseEventFromRepo(event), BaseEvent: *eventstore.BaseEventFromRepo(event),

View File

@ -13,11 +13,11 @@ import (
const ( const (
StartedType = eventstore.EventType("system.migration.started") StartedType = eventstore.EventType("system.migration.started")
doneType = eventstore.EventType("system.migration.done") DoneType = eventstore.EventType("system.migration.done")
failedType = eventstore.EventType("system.migration.failed") failedType = eventstore.EventType("system.migration.failed")
repeatableDoneType = eventstore.EventType("system.migration.repeatable.done") repeatableDoneType = eventstore.EventType("system.migration.repeatable.done")
aggregateType = eventstore.AggregateType("system") SystemAggregate = eventstore.AggregateType("system")
aggregateID = "SYSTEM" SystemAggregateID = "SYSTEM"
) )
var ( var (
@ -26,7 +26,7 @@ var (
type Migration interface { type Migration interface {
String() string String() string
Execute(context.Context) error Execute(ctx context.Context, startedEvent eventstore.Event) error
} }
type errCheckerMigration interface { type errCheckerMigration interface {
@ -58,12 +58,13 @@ func Migrate(ctx context.Context, es *eventstore.Eventstore, migration Migration
return nil return nil
} }
if _, err = es.Push(ctx, setupStartedCmd(ctx, migration)); err != nil && !continueOnErr(err) { startedEvent, err := es.Push(ctx, setupStartedCmd(ctx, migration))
if err != nil && !continueOnErr(err) {
return err return err
} }
logging.WithFields("name", migration.String()).Info("starting migration") logging.WithFields("name", migration.String()).Info("starting migration")
err = migration.Execute(ctx) err = migration.Execute(ctx, startedEvent[0])
logging.WithFields("name", migration.String()).OnError(err).Error("migration failed") logging.WithFields("name", migration.String()).OnError(err).Error("migration failed")
_, pushErr := es.Push(ctx, setupDoneCmd(ctx, migration, err)) _, pushErr := es.Push(ctx, setupDoneCmd(ctx, migration, err))
@ -95,7 +96,7 @@ type cancelMigration struct {
} }
// Execute implements Migration // Execute implements Migration
func (*cancelMigration) Execute(context.Context) error { func (*cancelMigration) Execute(context.Context, eventstore.Event) error {
return nil return nil
} }

View File

@ -19,9 +19,9 @@ type StepStates struct {
func (*StepStates) Query() *eventstore.SearchQueryBuilder { func (*StepStates) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent). return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
AddQuery(). AddQuery().
AggregateTypes(aggregateType). AggregateTypes(SystemAggregate).
AggregateIDs(aggregateID). AggregateIDs(SystemAggregateID).
EventTypes(StartedType, doneType, repeatableDoneType, failedType). EventTypes(StartedType, DoneType, repeatableDoneType, failedType).
Builder() Builder()
} }
@ -38,7 +38,7 @@ func (s *StepStates) Reduce() error {
switch step.EventType { switch step.EventType {
case StartedType: case StartedType:
state.state = StepStarted state.state = StepStarted
case doneType: case DoneType:
state.state = StepDone state.state = StepDone
case repeatableDoneType: case repeatableDoneType:
state.state = StepDone state.state = StepDone

View File

@ -6,13 +6,16 @@ import (
"github.com/zitadel/zitadel/internal/command" "github.com/zitadel/zitadel/internal/command"
"github.com/zitadel/zitadel/internal/crypto" "github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
"github.com/zitadel/zitadel/internal/notification/handlers" "github.com/zitadel/zitadel/internal/notification/handlers"
_ "github.com/zitadel/zitadel/internal/notification/statik" _ "github.com/zitadel/zitadel/internal/notification/statik"
"github.com/zitadel/zitadel/internal/query" "github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/internal/query/projection" "github.com/zitadel/zitadel/internal/query/projection"
) )
func Start( var projections []*handler.Handler
func Register(
ctx context.Context, ctx context.Context,
userHandlerCustomConfig, quotaHandlerCustomConfig, telemetryHandlerCustomConfig projection.CustomConfig, userHandlerCustomConfig, quotaHandlerCustomConfig, telemetryHandlerCustomConfig projection.CustomConfig,
telemetryCfg handlers.TelemetryPusherConfig, telemetryCfg handlers.TelemetryPusherConfig,
@ -28,9 +31,19 @@ func Start(
) { ) {
q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption) q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption)
c := newChannels(q) c := newChannels(q)
handlers.NewUserNotifier(ctx, projection.ApplyCustomConfig(userHandlerCustomConfig), commands, q, c, otpEmailTmpl).Start(ctx) projections = append(projections, handlers.NewUserNotifier(ctx, projection.ApplyCustomConfig(userHandlerCustomConfig), commands, q, c, otpEmailTmpl))
handlers.NewQuotaNotifier(ctx, projection.ApplyCustomConfig(quotaHandlerCustomConfig), commands, q, c).Start(ctx) projections = append(projections, handlers.NewQuotaNotifier(ctx, projection.ApplyCustomConfig(quotaHandlerCustomConfig), commands, q, c))
if telemetryCfg.Enabled { if telemetryCfg.Enabled {
handlers.NewTelemetryPusher(ctx, telemetryCfg, projection.ApplyCustomConfig(telemetryHandlerCustomConfig), commands, q, c).Start(ctx) projections = append(projections, handlers.NewTelemetryPusher(ctx, telemetryCfg, projection.ApplyCustomConfig(telemetryHandlerCustomConfig), commands, q, c))
} }
} }
func Start(ctx context.Context) {
for _, projection := range projections {
projection.Start(ctx)
}
}
func Projections() []*handler.Handler {
return projections
}

View File

@ -38,6 +38,13 @@ func (m *mockEventStore) Filter(ctx context.Context, queryFactory *eventstore.Se
return m.filterResponse[m.filterCounter-1], nil return m.filterResponse[m.filterCounter-1], nil
} }
func (m *mockEventStore) FilterToQueryReducer(ctx context.Context, reducer eventstore.QueryReducer) error {
m.filterCounter++
events := m.filterResponse[m.filterCounter-1]
reducer.AppendEvents(events...)
return reducer.Reduce()
}
func (m *mockEventStore) Push(ctx context.Context, cmds ...eventstore.Command) ([]eventstore.Event, error) { func (m *mockEventStore) Push(ctx context.Context, cmds ...eventstore.Command) ([]eventstore.Event, error) {
m.pushCounter++ m.pushCounter++
return m.pushResponse[m.pushCounter-1], nil return m.pushResponse[m.pushCounter-1], nil

View File

@ -8,15 +8,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository" "github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/eventstore/repository/mock" "github.com/zitadel/zitadel/internal/eventstore/repository/mock"
action_repo "github.com/zitadel/zitadel/internal/repository/action"
iam_repo "github.com/zitadel/zitadel/internal/repository/instance"
key_repo "github.com/zitadel/zitadel/internal/repository/keypair"
"github.com/zitadel/zitadel/internal/repository/limits"
"github.com/zitadel/zitadel/internal/repository/org"
proj_repo "github.com/zitadel/zitadel/internal/repository/project"
quota_repo "github.com/zitadel/zitadel/internal/repository/quota"
usr_repo "github.com/zitadel/zitadel/internal/repository/user"
"github.com/zitadel/zitadel/internal/repository/usergrant"
) )
type expect func(mockRepository *mock.MockRepository) type expect func(mockRepository *mock.MockRepository)
@ -32,15 +23,6 @@ func eventstoreExpect(t *testing.T, expects ...expect) *eventstore.Eventstore {
Pusher: m.MockPusher, Pusher: m.MockPusher,
}, },
) )
iam_repo.RegisterEventMappers(es)
org.RegisterEventMappers(es)
usr_repo.RegisterEventMappers(es)
proj_repo.RegisterEventMappers(es)
quota_repo.RegisterEventMappers(es)
limits.RegisterEventMappers(es)
usergrant.RegisterEventMappers(es)
key_repo.RegisterEventMappers(es)
action_repo.RegisterEventMappers(es)
return es return es
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/zitadel/zitadel/internal/crypto" "github.com/zitadel/zitadel/internal/crypto"
"github.com/zitadel/zitadel/internal/database" "github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2" "github.com/zitadel/zitadel/internal/eventstore/handler/v2"
"github.com/zitadel/zitadel/internal/migration"
) )
const ( const (
@ -76,6 +77,8 @@ var (
type projection interface { type projection interface {
Start(ctx context.Context) Start(ctx context.Context)
Init(ctx context.Context) error Init(ctx context.Context) error
Trigger(ctx context.Context, opts ...handler.TriggerOpt) (_ context.Context, err error)
migration.Migration
} }
var ( var (
@ -149,6 +152,10 @@ func Create(ctx context.Context, sqlClient *database.DB, es handler.EventStore,
return nil return nil
} }
func Projections() []projection {
return projections
}
func Init(ctx context.Context) error { func Init(ctx context.Context) error {
for _, p := range projections { for _, p := range projections {
if err := p.Init(ctx); err != nil { if err := p.Init(ctx); err != nil {

View File

@ -18,21 +18,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/handler/v2" "github.com/zitadel/zitadel/internal/eventstore/handler/v2"
"github.com/zitadel/zitadel/internal/query/projection" "github.com/zitadel/zitadel/internal/query/projection"
"github.com/zitadel/zitadel/internal/repository/action"
"github.com/zitadel/zitadel/internal/repository/authrequest"
"github.com/zitadel/zitadel/internal/repository/deviceauth"
"github.com/zitadel/zitadel/internal/repository/idpintent"
iam_repo "github.com/zitadel/zitadel/internal/repository/instance"
"github.com/zitadel/zitadel/internal/repository/keypair"
"github.com/zitadel/zitadel/internal/repository/limits"
"github.com/zitadel/zitadel/internal/repository/oidcsession"
"github.com/zitadel/zitadel/internal/repository/org"
"github.com/zitadel/zitadel/internal/repository/project"
"github.com/zitadel/zitadel/internal/repository/quota"
"github.com/zitadel/zitadel/internal/repository/restrictions"
"github.com/zitadel/zitadel/internal/repository/session"
usr_repo "github.com/zitadel/zitadel/internal/repository/user"
"github.com/zitadel/zitadel/internal/repository/usergrant"
"github.com/zitadel/zitadel/internal/telemetry/tracing" "github.com/zitadel/zitadel/internal/telemetry/tracing"
) )
@ -67,6 +52,7 @@ func StartQueries(
permissionCheck func(q *Queries) domain.PermissionCheck, permissionCheck func(q *Queries) domain.PermissionCheck,
defaultAuditLogRetention time.Duration, defaultAuditLogRetention time.Duration,
systemAPIUsers map[string]*authz.SystemAPIUser, systemAPIUsers map[string]*authz.SystemAPIUser,
startProjections bool,
) (repo *Queries, err error) { ) (repo *Queries, err error) {
repo = &Queries{ repo = &Queries{
eventstore: es, eventstore: es,
@ -86,21 +72,6 @@ func StartQueries(
}, },
defaultAuditLogRetention: defaultAuditLogRetention, defaultAuditLogRetention: defaultAuditLogRetention,
} }
iam_repo.RegisterEventMappers(repo.eventstore)
usr_repo.RegisterEventMappers(repo.eventstore)
org.RegisterEventMappers(repo.eventstore)
project.RegisterEventMappers(repo.eventstore)
action.RegisterEventMappers(repo.eventstore)
keypair.RegisterEventMappers(repo.eventstore)
usergrant.RegisterEventMappers(repo.eventstore)
session.RegisterEventMappers(repo.eventstore)
idpintent.RegisterEventMappers(repo.eventstore)
authrequest.RegisterEventMappers(repo.eventstore)
oidcsession.RegisterEventMappers(repo.eventstore)
quota.RegisterEventMappers(repo.eventstore)
limits.RegisterEventMappers(repo.eventstore)
restrictions.RegisterEventMappers(repo.eventstore)
deviceauth.RegisterEventMappers(repo.eventstore)
repo.checkPermission = permissionCheck(repo) repo.checkPermission = permissionCheck(repo)
@ -108,7 +79,9 @@ func StartQueries(
if err != nil { if err != nil {
return nil, err return nil, err
} }
projection.Start(ctx) if startProjections {
projection.Start(ctx)
}
return repo, nil return repo, nil
} }

View File

@ -10,21 +10,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/eventstore/repository" "github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/eventstore/repository/mock" "github.com/zitadel/zitadel/internal/eventstore/repository/mock"
action_repo "github.com/zitadel/zitadel/internal/repository/action"
"github.com/zitadel/zitadel/internal/repository/authrequest"
"github.com/zitadel/zitadel/internal/repository/deviceauth"
"github.com/zitadel/zitadel/internal/repository/feature"
"github.com/zitadel/zitadel/internal/repository/idpintent"
iam_repo "github.com/zitadel/zitadel/internal/repository/instance"
key_repo "github.com/zitadel/zitadel/internal/repository/keypair"
"github.com/zitadel/zitadel/internal/repository/limits"
"github.com/zitadel/zitadel/internal/repository/oidcsession"
"github.com/zitadel/zitadel/internal/repository/org"
proj_repo "github.com/zitadel/zitadel/internal/repository/project"
quota_repo "github.com/zitadel/zitadel/internal/repository/quota"
"github.com/zitadel/zitadel/internal/repository/session"
usr_repo "github.com/zitadel/zitadel/internal/repository/user"
"github.com/zitadel/zitadel/internal/repository/usergrant"
) )
type expect func(mockRepository *mock.MockRepository) type expect func(mockRepository *mock.MockRepository)
@ -41,21 +26,6 @@ func expectEventstore(expects ...expect) func(*testing.T) *eventstore.Eventstore
Pusher: m.MockPusher, Pusher: m.MockPusher,
}, },
) )
iam_repo.RegisterEventMappers(es)
org.RegisterEventMappers(es)
usr_repo.RegisterEventMappers(es)
proj_repo.RegisterEventMappers(es)
usergrant.RegisterEventMappers(es)
key_repo.RegisterEventMappers(es)
action_repo.RegisterEventMappers(es)
session.RegisterEventMappers(es)
idpintent.RegisterEventMappers(es)
authrequest.RegisterEventMappers(es)
oidcsession.RegisterEventMappers(es)
quota_repo.RegisterEventMappers(es)
limits.RegisterEventMappers(es)
feature.RegisterEventMappers(es)
deviceauth.RegisterEventMappers(es)
return es return es
} }
} }

View File

@ -2,10 +2,10 @@ package action
import "github.com/zitadel/zitadel/internal/eventstore" import "github.com/zitadel/zitadel/internal/eventstore"
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedEventType, AddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AddedEventType, AddedEventMapper)
RegisterFilterEventMapper(AggregateType, ChangedEventType, ChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ChangedEventType, ChangedEventMapper)
RegisterFilterEventMapper(AggregateType, DeactivatedEventType, DeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DeactivatedEventType, DeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, ReactivatedEventType, ReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ReactivatedEventType, ReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, RemovedEventType, RemovedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, RemovedEventType, RemovedEventMapper)
} }

View File

@ -2,11 +2,11 @@ package authrequest
import "github.com/zitadel/zitadel/internal/eventstore" import "github.com/zitadel/zitadel/internal/eventstore"
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedType, AddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AddedType, AddedEventMapper)
RegisterFilterEventMapper(AggregateType, SessionLinkedType, SessionLinkedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SessionLinkedType, SessionLinkedEventMapper)
RegisterFilterEventMapper(AggregateType, CodeAddedType, CodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CodeAddedType, CodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, CodeExchangedType, CodeExchangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CodeExchangedType, CodeExchangedEventMapper)
RegisterFilterEventMapper(AggregateType, FailedType, FailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, FailedType, FailedEventMapper)
RegisterFilterEventMapper(AggregateType, SucceededType, SucceededEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, SucceededType, SucceededEventMapper)
} }

View File

@ -2,8 +2,8 @@ package deviceauth
import "github.com/zitadel/zitadel/internal/eventstore" import "github.com/zitadel/zitadel/internal/eventstore"
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedEventType, eventstore.GenericEventMapper[AddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, AddedEventType, eventstore.GenericEventMapper[AddedEvent])
RegisterFilterEventMapper(AggregateType, ApprovedEventType, eventstore.GenericEventMapper[ApprovedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, ApprovedEventType, eventstore.GenericEventMapper[ApprovedEvent])
RegisterFilterEventMapper(AggregateType, CanceledEventType, eventstore.GenericEventMapper[CanceledEvent]) eventstore.RegisterFilterEventMapper(AggregateType, CanceledEventType, eventstore.GenericEventMapper[CanceledEvent])
} }

View File

@ -4,6 +4,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, DefaultLoginInstanceEventType, eventstore.GenericEventMapper[SetEvent[Boolean]]) eventstore.RegisterFilterEventMapper(AggregateType, DefaultLoginInstanceEventType, eventstore.GenericEventMapper[SetEvent[Boolean]])
} }

View File

@ -4,11 +4,11 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, StartedEventType, StartedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, StartedEventType, StartedEventMapper)
RegisterFilterEventMapper(AggregateType, SucceededEventType, SucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SucceededEventType, SucceededEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLSucceededEventType, SAMLSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLSucceededEventType, SAMLSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLRequestEventType, SAMLRequestEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLRequestEventType, SAMLRequestEventMapper)
RegisterFilterEventMapper(AggregateType, LDAPSucceededEventType, LDAPSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LDAPSucceededEventType, LDAPSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, FailedEventType, FailedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, FailedEventType, FailedEventMapper)
} }

View File

@ -4,119 +4,119 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, DefaultOrgSetEventType, DefaultOrgSetMapper). eventstore.RegisterFilterEventMapper(AggregateType, DefaultOrgSetEventType, DefaultOrgSetMapper)
RegisterFilterEventMapper(AggregateType, ProjectSetEventType, ProjectSetMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectSetEventType, ProjectSetMapper)
RegisterFilterEventMapper(AggregateType, ConsoleSetEventType, ConsoleSetMapper). eventstore.RegisterFilterEventMapper(AggregateType, ConsoleSetEventType, ConsoleSetMapper)
RegisterFilterEventMapper(AggregateType, DefaultLanguageSetEventType, DefaultLanguageSetMapper). eventstore.RegisterFilterEventMapper(AggregateType, DefaultLanguageSetEventType, DefaultLanguageSetMapper)
RegisterFilterEventMapper(AggregateType, SecretGeneratorAddedEventType, SecretGeneratorAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SecretGeneratorAddedEventType, SecretGeneratorAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SecretGeneratorChangedEventType, SecretGeneratorChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SecretGeneratorChangedEventType, SecretGeneratorChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SecretGeneratorRemovedEventType, SecretGeneratorRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SecretGeneratorRemovedEventType, SecretGeneratorRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, SMTPConfigAddedEventType, SMTPConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMTPConfigAddedEventType, SMTPConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SMTPConfigChangedEventType, SMTPConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMTPConfigChangedEventType, SMTPConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SMTPConfigPasswordChangedEventType, SMTPConfigPasswordChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMTPConfigPasswordChangedEventType, SMTPConfigPasswordChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SMTPConfigRemovedEventType, SMTPConfigRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMTPConfigRemovedEventType, SMTPConfigRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigTwilioAddedEventType, SMSConfigTwilioAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigTwilioAddedEventType, SMSConfigTwilioAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigTwilioChangedEventType, SMSConfigTwilioChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigTwilioChangedEventType, SMSConfigTwilioChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigTwilioTokenChangedEventType, SMSConfigTwilioTokenChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigTwilioTokenChangedEventType, SMSConfigTwilioTokenChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigActivatedEventType, SMSConfigActivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigActivatedEventType, SMSConfigActivatedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigDeactivatedEventType, SMSConfigDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigDeactivatedEventType, SMSConfigDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, SMSConfigRemovedEventType, SMSConfigRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SMSConfigRemovedEventType, SMSConfigRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileAddedEventType, DebugNotificationProviderFileAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileAddedEventType, DebugNotificationProviderFileAddedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileChangedEventType, DebugNotificationProviderFileChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileChangedEventType, DebugNotificationProviderFileChangedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileRemovedEventType, DebugNotificationProviderFileRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderFileRemovedEventType, DebugNotificationProviderFileRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogAddedEventType, DebugNotificationProviderLogAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogAddedEventType, DebugNotificationProviderLogAddedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogChangedEventType, DebugNotificationProviderLogChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogChangedEventType, DebugNotificationProviderLogChangedEventMapper)
RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogRemovedEventType, DebugNotificationProviderLogRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DebugNotificationProviderLogRemovedEventType, DebugNotificationProviderLogRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCSettingsAddedEventType, OIDCSettingsAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCSettingsAddedEventType, OIDCSettingsAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCSettingsChangedEventType, OIDCSettingsChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCSettingsChangedEventType, OIDCSettingsChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SecurityPolicySetEventType, SecurityPolicySetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SecurityPolicySetEventType, SecurityPolicySetEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyAddedEventType, LabelPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAddedEventType, LabelPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyChangedEventType, LabelPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyChangedEventType, LabelPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyActivatedEventType, LabelPolicyActivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyActivatedEventType, LabelPolicyActivatedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoAddedEventType, LabelPolicyLogoAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoAddedEventType, LabelPolicyLogoAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoRemovedEventType, LabelPolicyLogoRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoRemovedEventType, LabelPolicyLogoRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconAddedEventType, LabelPolicyIconAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconAddedEventType, LabelPolicyIconAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconRemovedEventType, LabelPolicyIconRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconRemovedEventType, LabelPolicyIconRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkAddedEventType, LabelPolicyLogoDarkAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkAddedEventType, LabelPolicyLogoDarkAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkRemovedEventType, LabelPolicyLogoDarkRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkRemovedEventType, LabelPolicyLogoDarkRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkAddedEventType, LabelPolicyIconDarkAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkAddedEventType, LabelPolicyIconDarkAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkRemovedEventType, LabelPolicyIconDarkRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkRemovedEventType, LabelPolicyIconDarkRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyFontAddedEventType, LabelPolicyFontAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontAddedEventType, LabelPolicyFontAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyFontRemovedEventType, LabelPolicyFontRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontRemovedEventType, LabelPolicyFontRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyAssetsRemovedEventType, LabelPolicyAssetsRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAssetsRemovedEventType, LabelPolicyAssetsRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyAddedEventType, LoginPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyAddedEventType, LoginPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyChangedEventType, LoginPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyChangedEventType, LoginPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, DomainPolicyAddedEventType, DomainPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyAddedEventType, DomainPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, DomainPolicyChangedEventType, DomainPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyChangedEventType, DomainPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordAgePolicyAddedEventType, PasswordAgePolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyAddedEventType, PasswordAgePolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordAgePolicyChangedEventType, PasswordAgePolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyChangedEventType, PasswordAgePolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyAddedEventType, PasswordComplexityPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyAddedEventType, PasswordComplexityPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyChangedEventType, PasswordComplexityPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyChangedEventType, PasswordComplexityPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LockoutPolicyAddedEventType, LockoutPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyAddedEventType, LockoutPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LockoutPolicyChangedEventType, LockoutPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyChangedEventType, LockoutPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PrivacyPolicyAddedEventType, PrivacyPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyAddedEventType, PrivacyPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PrivacyPolicyChangedEventType, PrivacyPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyChangedEventType, PrivacyPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberAddedEventType, MemberAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberAddedEventType, MemberAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberChangedEventType, MemberChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberChangedEventType, MemberChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberRemovedEventType, MemberRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberRemovedEventType, MemberRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedEventType, MemberCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedEventType, MemberCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigAddedEventType, IDPConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigAddedEventType, IDPConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigChangedEventType, IDPConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigChangedEventType, IDPConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigRemovedEventType, IDPConfigRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigRemovedEventType, IDPConfigRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OAuthIDPAddedEventType, OAuthIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPAddedEventType, OAuthIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OAuthIDPChangedEventType, OAuthIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPChangedEventType, OAuthIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPAddedEventType, OIDCIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPAddedEventType, OIDCIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPChangedEventType, OIDCIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPChangedEventType, OIDCIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedAzureADEventType, OIDCIDPMigratedAzureADEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedAzureADEventType, OIDCIDPMigratedAzureADEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedGoogleEventType, OIDCIDPMigratedGoogleEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedGoogleEventType, OIDCIDPMigratedGoogleEventMapper)
RegisterFilterEventMapper(AggregateType, JWTIDPAddedEventType, JWTIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPAddedEventType, JWTIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, JWTIDPChangedEventType, JWTIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPChangedEventType, JWTIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, AzureADIDPAddedEventType, AzureADIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPAddedEventType, AzureADIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, AzureADIDPChangedEventType, AzureADIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPChangedEventType, AzureADIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubIDPAddedEventType, GitHubIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPAddedEventType, GitHubIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubIDPChangedEventType, GitHubIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPChangedEventType, GitHubIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPAddedEventType, GitHubEnterpriseIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPAddedEventType, GitHubEnterpriseIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPChangedEventType, GitHubEnterpriseIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPChangedEventType, GitHubEnterpriseIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabIDPAddedEventType, GitLabIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPAddedEventType, GitLabIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabIDPChangedEventType, GitLabIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPChangedEventType, GitLabIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPAddedEventType, GitLabSelfHostedIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPAddedEventType, GitLabSelfHostedIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPChangedEventType, GitLabSelfHostedIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPChangedEventType, GitLabSelfHostedIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GoogleIDPAddedEventType, GoogleIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPAddedEventType, GoogleIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GoogleIDPChangedEventType, GoogleIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPChangedEventType, GoogleIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LDAPIDPAddedEventType, LDAPIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPAddedEventType, LDAPIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LDAPIDPChangedEventType, LDAPIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPChangedEventType, LDAPIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, AppleIDPAddedEventType, AppleIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPAddedEventType, AppleIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, AppleIDPChangedEventType, AppleIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPChangedEventType, AppleIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLIDPAddedEventType, SAMLIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPAddedEventType, SAMLIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorAddedEventType, SecondFactorAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorAddedEventType, SecondFactorAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorRemovedEventType, SecondFactorRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorRemovedEventType, SecondFactorRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorAddedEventType, MultiFactorAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorAddedEventType, MultiFactorAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorRemovedEventType, MultiFactorRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorRemovedEventType, MultiFactorRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTemplateAddedEventType, MailTemplateAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateAddedEventType, MailTemplateAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTemplateChangedEventType, MailTemplateChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateChangedEventType, MailTemplateChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTextAddedEventType, MailTextAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTextAddedEventType, MailTextAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTextChangedEventType, MailTextChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTextChangedEventType, MailTextChangedEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextSetEventType, CustomTextSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextSetEventType, CustomTextSetEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextRemovedEventType, CustomTextRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextRemovedEventType, CustomTextRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceDomainAddedEventType, DomainAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceDomainAddedEventType, DomainAddedEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceDomainPrimarySetEventType, DomainPrimarySetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceDomainPrimarySetEventType, DomainPrimarySetEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceDomainRemovedEventType, DomainRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceDomainRemovedEventType, DomainRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceAddedEventType, InstanceAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceAddedEventType, InstanceAddedEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceChangedEventType, InstanceChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceChangedEventType, InstanceChangedEventMapper)
RegisterFilterEventMapper(AggregateType, InstanceRemovedEventType, InstanceRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, InstanceRemovedEventType, InstanceRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper)
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedEventType, AddedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, AddedEventType, AddedEventMapper)
es.RegisterFilterEventMapper(AggregateType, AddedCertificateEventType, AddedCertificateEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, AddedCertificateEventType, AddedCertificateEventMapper)
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper)
RegisterFilterEventMapper(AggregateType, ResetEventType, ResetEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, ResetEventType, ResetEventMapper)
} }

View File

@ -4,6 +4,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, PushedEventType, PushedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, PushedEventType, PushedEventMapper)
} }

View File

@ -4,12 +4,12 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedType, eventstore.GenericEventMapper[AddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, AddedType, eventstore.GenericEventMapper[AddedEvent])
RegisterFilterEventMapper(AggregateType, AccessTokenAddedType, eventstore.GenericEventMapper[AccessTokenAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, AccessTokenAddedType, eventstore.GenericEventMapper[AccessTokenAddedEvent])
RegisterFilterEventMapper(AggregateType, AccessTokenRevokedType, eventstore.GenericEventMapper[AccessTokenRevokedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, AccessTokenRevokedType, eventstore.GenericEventMapper[AccessTokenRevokedEvent])
RegisterFilterEventMapper(AggregateType, RefreshTokenAddedType, eventstore.GenericEventMapper[RefreshTokenAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, RefreshTokenAddedType, eventstore.GenericEventMapper[RefreshTokenAddedEvent])
RegisterFilterEventMapper(AggregateType, RefreshTokenRenewedType, eventstore.GenericEventMapper[RefreshTokenRenewedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, RefreshTokenRenewedType, eventstore.GenericEventMapper[RefreshTokenRenewedEvent])
RegisterFilterEventMapper(AggregateType, RefreshTokenRevokedType, eventstore.GenericEventMapper[RefreshTokenRevokedEvent]) eventstore.RegisterFilterEventMapper(AggregateType, RefreshTokenRevokedType, eventstore.GenericEventMapper[RefreshTokenRevokedEvent])
} }

View File

@ -4,114 +4,114 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, OrgAddedEventType, OrgAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgAddedEventType, OrgAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgChangedEventType, OrgChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgChangedEventType, OrgChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDeactivatedEventType, OrgDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDeactivatedEventType, OrgDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgReactivatedEventType, OrgReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgReactivatedEventType, OrgReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgRemovedEventType, OrgRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgRemovedEventType, OrgRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainAddedEventType, DomainAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainAddedEventType, DomainAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainVerificationAddedEventType, DomainVerificationAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerificationAddedEventType, DomainVerificationAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainVerificationFailedEventType, DomainVerificationFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerificationFailedEventType, DomainVerificationFailedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainVerifiedEventType, DomainVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerifiedEventType, DomainVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainPrimarySetEventType, DomainPrimarySetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainPrimarySetEventType, DomainPrimarySetEventMapper)
RegisterFilterEventMapper(AggregateType, OrgDomainRemovedEventType, DomainRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainRemovedEventType, DomainRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberAddedEventType, MemberAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberAddedEventType, MemberAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberChangedEventType, MemberChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberChangedEventType, MemberChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberRemovedEventType, MemberRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberRemovedEventType, MemberRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedEventType, MemberCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedEventType, MemberCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyAddedEventType, LabelPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAddedEventType, LabelPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyChangedEventType, LabelPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyChangedEventType, LabelPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyActivatedEventType, LabelPolicyActivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyActivatedEventType, LabelPolicyActivatedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyRemovedEventType, LabelPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyRemovedEventType, LabelPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoAddedEventType, LabelPolicyLogoAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoAddedEventType, LabelPolicyLogoAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoRemovedEventType, LabelPolicyLogoRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoRemovedEventType, LabelPolicyLogoRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconAddedEventType, LabelPolicyIconAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconAddedEventType, LabelPolicyIconAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconRemovedEventType, LabelPolicyIconRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconRemovedEventType, LabelPolicyIconRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkAddedEventType, LabelPolicyLogoDarkAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkAddedEventType, LabelPolicyLogoDarkAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkRemovedEventType, LabelPolicyLogoDarkRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkRemovedEventType, LabelPolicyLogoDarkRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkAddedEventType, LabelPolicyIconDarkAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkAddedEventType, LabelPolicyIconDarkAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkRemovedEventType, LabelPolicyIconDarkRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkRemovedEventType, LabelPolicyIconDarkRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyFontAddedEventType, LabelPolicyFontAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontAddedEventType, LabelPolicyFontAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyFontRemovedEventType, LabelPolicyFontRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontRemovedEventType, LabelPolicyFontRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LabelPolicyAssetsRemovedEventType, LabelPolicyAssetsRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAssetsRemovedEventType, LabelPolicyAssetsRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyAddedEventType, LoginPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyAddedEventType, LoginPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyChangedEventType, LoginPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyChangedEventType, LoginPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyRemovedEventType, LoginPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyRemovedEventType, LoginPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorAddedEventType, SecondFactorAddedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorAddedEventType, SecondFactorAddedEventEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorRemovedEventType, SecondFactorRemovedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorRemovedEventType, SecondFactorRemovedEventEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorAddedEventType, MultiFactorAddedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorAddedEventType, MultiFactorAddedEventEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorRemovedEventType, MultiFactorRemovedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorRemovedEventType, MultiFactorRemovedEventEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, DomainPolicyAddedEventType, DomainPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyAddedEventType, DomainPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, DomainPolicyChangedEventType, DomainPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyChangedEventType, DomainPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, DomainPolicyRemovedEventType, DomainPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyRemovedEventType, DomainPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordAgePolicyAddedEventType, PasswordAgePolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyAddedEventType, PasswordAgePolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordAgePolicyChangedEventType, PasswordAgePolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyChangedEventType, PasswordAgePolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordAgePolicyRemovedEventType, PasswordAgePolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyRemovedEventType, PasswordAgePolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyAddedEventType, PasswordComplexityPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyAddedEventType, PasswordComplexityPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyChangedEventType, PasswordComplexityPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyChangedEventType, PasswordComplexityPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyRemovedEventType, PasswordComplexityPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyRemovedEventType, PasswordComplexityPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, LockoutPolicyAddedEventType, LockoutPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyAddedEventType, LockoutPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LockoutPolicyChangedEventType, LockoutPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyChangedEventType, LockoutPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LockoutPolicyRemovedEventType, LockoutPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyRemovedEventType, LockoutPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, PrivacyPolicyAddedEventType, PrivacyPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyAddedEventType, PrivacyPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PrivacyPolicyChangedEventType, PrivacyPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyChangedEventType, PrivacyPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, PrivacyPolicyRemovedEventType, PrivacyPolicyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyRemovedEventType, PrivacyPolicyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTemplateAddedEventType, MailTemplateAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateAddedEventType, MailTemplateAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTemplateChangedEventType, MailTemplateChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateChangedEventType, MailTemplateChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTemplateRemovedEventType, MailTemplateRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateRemovedEventType, MailTemplateRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTextAddedEventType, MailTextAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTextAddedEventType, MailTextAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTextChangedEventType, MailTextChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTextChangedEventType, MailTextChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MailTextRemovedEventType, MailTextRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MailTextRemovedEventType, MailTextRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextSetEventType, CustomTextSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextSetEventType, CustomTextSetEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextRemovedEventType, CustomTextRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextRemovedEventType, CustomTextRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigAddedEventType, IDPConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigAddedEventType, IDPConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigChangedEventType, IDPConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigChangedEventType, IDPConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigRemovedEventType, IDPConfigRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigRemovedEventType, IDPConfigRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OAuthIDPAddedEventType, OAuthIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPAddedEventType, OAuthIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OAuthIDPChangedEventType, OAuthIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPChangedEventType, OAuthIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPAddedEventType, OIDCIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPAddedEventType, OIDCIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPChangedEventType, OIDCIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPChangedEventType, OIDCIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedAzureADEventType, OIDCIDPMigratedAzureADEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedAzureADEventType, OIDCIDPMigratedAzureADEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedGoogleEventType, OIDCIDPMigratedGoogleEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedGoogleEventType, OIDCIDPMigratedGoogleEventMapper)
RegisterFilterEventMapper(AggregateType, JWTIDPAddedEventType, JWTIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPAddedEventType, JWTIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, JWTIDPChangedEventType, JWTIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPChangedEventType, JWTIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, AzureADIDPAddedEventType, AzureADIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPAddedEventType, AzureADIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, AzureADIDPChangedEventType, AzureADIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPChangedEventType, AzureADIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubIDPAddedEventType, GitHubIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPAddedEventType, GitHubIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubIDPChangedEventType, GitHubIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPChangedEventType, GitHubIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPAddedEventType, GitHubEnterpriseIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPAddedEventType, GitHubEnterpriseIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPChangedEventType, GitHubEnterpriseIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPChangedEventType, GitHubEnterpriseIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabIDPAddedEventType, GitLabIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPAddedEventType, GitLabIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabIDPChangedEventType, GitLabIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPChangedEventType, GitLabIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPAddedEventType, GitLabSelfHostedIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPAddedEventType, GitLabSelfHostedIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPChangedEventType, GitLabSelfHostedIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPChangedEventType, GitLabSelfHostedIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GoogleIDPAddedEventType, GoogleIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPAddedEventType, GoogleIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GoogleIDPChangedEventType, GoogleIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPChangedEventType, GoogleIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, LDAPIDPAddedEventType, LDAPIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPAddedEventType, LDAPIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, LDAPIDPChangedEventType, LDAPIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPChangedEventType, LDAPIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, AppleIDPAddedEventType, AppleIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPAddedEventType, AppleIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, AppleIDPChangedEventType, AppleIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPChangedEventType, AppleIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLIDPAddedEventType, SAMLIDPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPAddedEventType, SAMLIDPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper)
RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, TriggerActionsSetEventType, TriggerActionsSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, TriggerActionsSetEventType, TriggerActionsSetEventMapper)
RegisterFilterEventMapper(AggregateType, TriggerActionsCascadeRemovedEventType, TriggerActionsCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, TriggerActionsCascadeRemovedEventType, TriggerActionsCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, FlowClearedEventType, FlowClearedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, FlowClearedEventType, FlowClearedEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataRemovedType, MetadataRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedType, MetadataRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataRemovedAllType, MetadataRemovedAllEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedAllType, MetadataRemovedAllEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationPolicyRemovedEventType, NotificationPolicyRemovedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyRemovedEventType, NotificationPolicyRemovedEventMapper)
} }

View File

@ -4,44 +4,44 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, ProjectAddedType, ProjectAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectAddedType, ProjectAddedEventMapper)
RegisterFilterEventMapper(AggregateType, ProjectChangedType, ProjectChangeEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectChangedType, ProjectChangeEventMapper)
RegisterFilterEventMapper(AggregateType, ProjectDeactivatedType, ProjectDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectDeactivatedType, ProjectDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, ProjectReactivatedType, ProjectReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectReactivatedType, ProjectReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, ProjectRemovedType, ProjectRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ProjectRemovedType, ProjectRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberAddedType, MemberAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberAddedType, MemberAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberChangedType, MemberChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberChangedType, MemberChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberRemovedType, MemberRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberRemovedType, MemberRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedType, MemberCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedType, MemberCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, RoleAddedType, RoleAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, RoleAddedType, RoleAddedEventMapper)
RegisterFilterEventMapper(AggregateType, RoleChangedType, RoleChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, RoleChangedType, RoleChangedEventMapper)
RegisterFilterEventMapper(AggregateType, RoleRemovedType, RoleRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, RoleRemovedType, RoleRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantAddedType, GrantAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantAddedType, GrantAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantChangedType, GrantChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantChangedType, GrantChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantCascadeChangedType, GrantCascadeChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantCascadeChangedType, GrantCascadeChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantDeactivatedType, GrantDeactivateEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantDeactivatedType, GrantDeactivateEventMapper)
RegisterFilterEventMapper(AggregateType, GrantReactivatedType, GrantReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantReactivatedType, GrantReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantRemovedType, GrantRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantRemovedType, GrantRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantMemberAddedType, GrantMemberAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantMemberAddedType, GrantMemberAddedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantMemberChangedType, GrantMemberChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantMemberChangedType, GrantMemberChangedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantMemberRemovedType, GrantMemberRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantMemberRemovedType, GrantMemberRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, GrantMemberCascadeRemovedType, GrantMemberCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, GrantMemberCascadeRemovedType, GrantMemberCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationAddedType, ApplicationAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationAddedType, ApplicationAddedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationChangedType, ApplicationChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationChangedType, ApplicationChangedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationRemovedType, ApplicationRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationRemovedType, ApplicationRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationDeactivatedType, ApplicationDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationDeactivatedType, ApplicationDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationReactivatedType, ApplicationReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationReactivatedType, ApplicationReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCConfigAddedType, OIDCConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCConfigAddedType, OIDCConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCConfigChangedType, OIDCConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCConfigChangedType, OIDCConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCConfigSecretChangedType, OIDCConfigSecretChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCConfigSecretChangedType, OIDCConfigSecretChangedEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCClientSecretCheckSucceededType, OIDCConfigSecretCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCClientSecretCheckSucceededType, OIDCConfigSecretCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, OIDCClientSecretCheckFailedType, OIDCConfigSecretCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, OIDCClientSecretCheckFailedType, OIDCConfigSecretCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, APIConfigAddedType, APIConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, APIConfigAddedType, APIConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, APIConfigChangedType, APIConfigChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, APIConfigChangedType, APIConfigChangedEventMapper)
RegisterFilterEventMapper(AggregateType, APIConfigSecretChangedType, APIConfigSecretChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, APIConfigSecretChangedType, APIConfigSecretChangedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationKeyAddedEventType, ApplicationKeyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationKeyAddedEventType, ApplicationKeyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, ApplicationKeyRemovedEventType, ApplicationKeyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, ApplicationKeyRemovedEventType, ApplicationKeyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLConfigAddedType, SAMLConfigAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SAMLConfigAddedType, SAMLConfigAddedEventMapper)
RegisterFilterEventMapper(AggregateType, SAMLConfigChangedType, SAMLConfigChangedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, SAMLConfigChangedType, SAMLConfigChangedEventMapper)
} }

View File

@ -4,13 +4,13 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
// AddedEventType is not emitted anymore. // AddedEventType is not emitted anymore.
// For ease of use, old events are directly mapped to SetEvent. // For ease of use, old events are directly mapped to SetEvent.
// This works, because the data structures are compatible. // This works, because the data structures are compatible.
es.RegisterFilterEventMapper(AggregateType, AddedEventType, SetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AddedEventType, SetEventMapper)
RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper)
RegisterFilterEventMapper(AggregateType, RemovedEventType, RemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, RemovedEventType, RemovedEventMapper)
RegisterFilterEventMapper(AggregateType, NotificationDueEventType, NotificationDueEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, NotificationDueEventType, NotificationDueEventMapper)
RegisterFilterEventMapper(AggregateType, NotifiedEventType, NotifiedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, NotifiedEventType, NotifiedEventMapper)
} }

View File

@ -4,6 +4,6 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, SetEventType, SetEventMapper)
} }

View File

@ -2,22 +2,22 @@ package session
import "github.com/zitadel/zitadel/internal/eventstore" import "github.com/zitadel/zitadel/internal/eventstore"
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, AddedType, AddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, AddedType, AddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserCheckedType, UserCheckedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserCheckedType, UserCheckedEventMapper)
RegisterFilterEventMapper(AggregateType, PasswordCheckedType, PasswordCheckedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PasswordCheckedType, PasswordCheckedEventMapper)
RegisterFilterEventMapper(AggregateType, IntentCheckedType, IntentCheckedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, IntentCheckedType, IntentCheckedEventMapper)
RegisterFilterEventMapper(AggregateType, WebAuthNChallengedType, eventstore.GenericEventMapper[WebAuthNChallengedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, WebAuthNChallengedType, eventstore.GenericEventMapper[WebAuthNChallengedEvent])
RegisterFilterEventMapper(AggregateType, WebAuthNCheckedType, eventstore.GenericEventMapper[WebAuthNCheckedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, WebAuthNCheckedType, eventstore.GenericEventMapper[WebAuthNCheckedEvent])
RegisterFilterEventMapper(AggregateType, TOTPCheckedType, eventstore.GenericEventMapper[TOTPCheckedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, TOTPCheckedType, eventstore.GenericEventMapper[TOTPCheckedEvent])
RegisterFilterEventMapper(AggregateType, OTPSMSChallengedType, eventstore.GenericEventMapper[OTPSMSChallengedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPSMSChallengedType, eventstore.GenericEventMapper[OTPSMSChallengedEvent])
RegisterFilterEventMapper(AggregateType, OTPSMSSentType, eventstore.GenericEventMapper[OTPSMSSentEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPSMSSentType, eventstore.GenericEventMapper[OTPSMSSentEvent])
RegisterFilterEventMapper(AggregateType, OTPSMSCheckedType, eventstore.GenericEventMapper[OTPSMSCheckedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPSMSCheckedType, eventstore.GenericEventMapper[OTPSMSCheckedEvent])
RegisterFilterEventMapper(AggregateType, OTPEmailChallengedType, eventstore.GenericEventMapper[OTPEmailChallengedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPEmailChallengedType, eventstore.GenericEventMapper[OTPEmailChallengedEvent])
RegisterFilterEventMapper(AggregateType, OTPEmailSentType, eventstore.GenericEventMapper[OTPEmailSentEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPEmailSentType, eventstore.GenericEventMapper[OTPEmailSentEvent])
RegisterFilterEventMapper(AggregateType, OTPEmailCheckedType, eventstore.GenericEventMapper[OTPEmailCheckedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, OTPEmailCheckedType, eventstore.GenericEventMapper[OTPEmailCheckedEvent])
RegisterFilterEventMapper(AggregateType, TokenSetType, TokenSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, TokenSetType, TokenSetEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper)
RegisterFilterEventMapper(AggregateType, LifetimeSetType, eventstore.GenericEventMapper[LifetimeSetEvent]). eventstore.RegisterFilterEventMapper(AggregateType, LifetimeSetType, eventstore.GenericEventMapper[LifetimeSetEvent])
RegisterFilterEventMapper(AggregateType, TerminateType, TerminateEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, TerminateType, TerminateEventMapper)
} }

View File

@ -4,134 +4,134 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, UserV1AddedType, HumanAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1AddedType, HumanAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1RegisteredType, HumanRegisteredEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1RegisteredType, HumanRegisteredEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1InitialCodeAddedType, HumanInitialCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1InitialCodeAddedType, HumanInitialCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1InitialCodeSentType, HumanInitialCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1InitialCodeSentType, HumanInitialCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1InitializedCheckSucceededType, HumanInitializedCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1InitializedCheckSucceededType, HumanInitializedCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1InitializedCheckFailedType, HumanInitializedCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1InitializedCheckFailedType, HumanInitializedCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1SignedOutType, HumanSignedOutEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1SignedOutType, HumanSignedOutEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PasswordChangedType, HumanPasswordChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PasswordChangedType, HumanPasswordChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PasswordCodeAddedType, HumanPasswordCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PasswordCodeAddedType, HumanPasswordCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PasswordCodeSentType, HumanPasswordCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PasswordCodeSentType, HumanPasswordCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckFailedType, HumanPasswordCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PasswordCheckFailedType, HumanPasswordCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1EmailChangedType, HumanEmailChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1EmailChangedType, HumanEmailChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1EmailVerifiedType, HumanEmailVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1EmailVerifiedType, HumanEmailVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1EmailVerificationFailedType, HumanEmailVerificationFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1EmailVerificationFailedType, HumanEmailVerificationFailedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1EmailCodeAddedType, HumanEmailCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1EmailCodeAddedType, HumanEmailCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1EmailCodeSentType, HumanEmailCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1EmailCodeSentType, HumanEmailCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneChangedType, HumanPhoneChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneChangedType, HumanPhoneChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneRemovedType, HumanPhoneRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneRemovedType, HumanPhoneRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneVerifiedType, HumanPhoneVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneVerifiedType, HumanPhoneVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneVerificationFailedType, HumanPhoneVerificationFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneVerificationFailedType, HumanPhoneVerificationFailedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneCodeAddedType, HumanPhoneCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneCodeAddedType, HumanPhoneCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1PhoneCodeSentType, HumanPhoneCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1PhoneCodeSentType, HumanPhoneCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1ProfileChangedType, HumanProfileChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1ProfileChangedType, HumanProfileChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1AddressChangedType, HumanAddressChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1AddressChangedType, HumanAddressChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAInitSkippedType, HumanMFAInitSkippedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAInitSkippedType, HumanMFAInitSkippedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAOTPAddedType, HumanOTPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAOTPAddedType, HumanOTPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAOTPVerifiedType, HumanOTPVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAOTPVerifiedType, HumanOTPVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAOTPRemovedType, HumanOTPRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAOTPRemovedType, HumanOTPRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAOTPCheckSucceededType, HumanOTPCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAOTPCheckSucceededType, HumanOTPCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, UserV1MFAOTPCheckFailedType, HumanOTPCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserV1MFAOTPCheckFailedType, HumanOTPCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, UserLockedType, UserLockedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserLockedType, UserLockedEventMapper)
RegisterFilterEventMapper(AggregateType, UserUnlockedType, UserUnlockedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserUnlockedType, UserUnlockedEventMapper)
RegisterFilterEventMapper(AggregateType, UserDeactivatedType, UserDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserDeactivatedType, UserDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, UserReactivatedType, UserReactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserReactivatedType, UserReactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, UserRemovedType, UserRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserRemovedType, UserRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserTokenAddedType, UserTokenAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserTokenAddedType, UserTokenAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserTokenRemovedType, UserTokenRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserTokenRemovedType, UserTokenRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserDomainClaimedType, DomainClaimedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserDomainClaimedType, DomainClaimedEventMapper)
RegisterFilterEventMapper(AggregateType, UserDomainClaimedSentType, DomainClaimedSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserDomainClaimedSentType, DomainClaimedSentEventMapper)
RegisterFilterEventMapper(AggregateType, UserUserNameChangedType, UsernameChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserUserNameChangedType, UsernameChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataRemovedType, MetadataRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedType, MetadataRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MetadataRemovedAllType, MetadataRemovedAllEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedAllType, MetadataRemovedAllEventMapper)
RegisterFilterEventMapper(AggregateType, HumanAddedType, HumanAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanAddedType, HumanAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanRegisteredType, HumanRegisteredEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanRegisteredType, HumanRegisteredEventMapper)
RegisterFilterEventMapper(AggregateType, HumanInitialCodeAddedType, HumanInitialCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanInitialCodeAddedType, HumanInitialCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanInitialCodeSentType, HumanInitialCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanInitialCodeSentType, HumanInitialCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanInitializedCheckSucceededType, HumanInitializedCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanInitializedCheckSucceededType, HumanInitializedCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanInitializedCheckFailedType, HumanInitializedCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanInitializedCheckFailedType, HumanInitializedCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanSignedOutType, HumanSignedOutEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanSignedOutType, HumanSignedOutEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordChangedType, HumanPasswordChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordChangedType, HumanPasswordChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordCodeAddedType, HumanPasswordCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordCodeAddedType, HumanPasswordCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordCodeSentType, HumanPasswordCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordCodeSentType, HumanPasswordCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordChangeSentType, HumanPasswordChangeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordChangeSentType, HumanPasswordChangeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordCheckSucceededType, HumanPasswordCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordCheckFailedType, HumanPasswordCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordCheckFailedType, HumanPasswordCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordHashUpdatedType, eventstore.GenericEventMapper[HumanPasswordHashUpdatedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordHashUpdatedType, eventstore.GenericEventMapper[HumanPasswordHashUpdatedEvent])
RegisterFilterEventMapper(AggregateType, UserIDPLinkAddedType, UserIDPLinkAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPLinkAddedType, UserIDPLinkAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserIDPLinkRemovedType, UserIDPLinkRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPLinkRemovedType, UserIDPLinkRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserIDPLinkCascadeRemovedType, UserIDPLinkCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPLinkCascadeRemovedType, UserIDPLinkCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserIDPLoginCheckSucceededType, UserIDPCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPLoginCheckSucceededType, UserIDPCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, UserIDPExternalIDMigratedType, eventstore.GenericEventMapper[UserIDPExternalIDMigratedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPExternalIDMigratedType, eventstore.GenericEventMapper[UserIDPExternalIDMigratedEvent])
RegisterFilterEventMapper(AggregateType, UserIDPExternalUsernameChangedType, eventstore.GenericEventMapper[UserIDPExternalUsernameEvent]). eventstore.RegisterFilterEventMapper(AggregateType, UserIDPExternalUsernameChangedType, eventstore.GenericEventMapper[UserIDPExternalUsernameEvent])
RegisterFilterEventMapper(AggregateType, HumanEmailChangedType, HumanEmailChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanEmailChangedType, HumanEmailChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanEmailVerifiedType, HumanEmailVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanEmailVerifiedType, HumanEmailVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanEmailVerificationFailedType, HumanEmailVerificationFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanEmailVerificationFailedType, HumanEmailVerificationFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanEmailCodeAddedType, HumanEmailCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanEmailCodeAddedType, HumanEmailCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanEmailCodeSentType, HumanEmailCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanEmailCodeSentType, HumanEmailCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneChangedType, HumanPhoneChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneChangedType, HumanPhoneChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneRemovedType, HumanPhoneRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneRemovedType, HumanPhoneRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneVerifiedType, HumanPhoneVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneVerifiedType, HumanPhoneVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneVerificationFailedType, HumanPhoneVerificationFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneVerificationFailedType, HumanPhoneVerificationFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneCodeAddedType, HumanPhoneCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneCodeAddedType, HumanPhoneCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPhoneCodeSentType, HumanPhoneCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPhoneCodeSentType, HumanPhoneCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanProfileChangedType, HumanProfileChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanProfileChangedType, HumanProfileChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanAvatarAddedType, HumanAvatarAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanAvatarAddedType, HumanAvatarAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanAvatarRemovedType, HumanAvatarRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanAvatarRemovedType, HumanAvatarRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanAddressChangedType, HumanAddressChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanAddressChangedType, HumanAddressChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAInitSkippedType, HumanMFAInitSkippedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAInitSkippedType, HumanMFAInitSkippedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAOTPAddedType, HumanOTPAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAOTPAddedType, HumanOTPAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAOTPVerifiedType, HumanOTPVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAOTPVerifiedType, HumanOTPVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAOTPRemovedType, HumanOTPRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAOTPRemovedType, HumanOTPRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAOTPCheckSucceededType, HumanOTPCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAOTPCheckSucceededType, HumanOTPCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanMFAOTPCheckFailedType, HumanOTPCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanMFAOTPCheckFailedType, HumanOTPCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanOTPSMSAddedType, eventstore.GenericEventMapper[HumanOTPSMSAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSAddedType, eventstore.GenericEventMapper[HumanOTPSMSAddedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPSMSRemovedType, eventstore.GenericEventMapper[HumanOTPSMSRemovedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSRemovedType, eventstore.GenericEventMapper[HumanOTPSMSRemovedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPSMSCodeAddedType, eventstore.GenericEventMapper[HumanOTPSMSCodeAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSCodeAddedType, eventstore.GenericEventMapper[HumanOTPSMSCodeAddedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPSMSCodeSentType, eventstore.GenericEventMapper[HumanOTPSMSCodeSentEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSCodeSentType, eventstore.GenericEventMapper[HumanOTPSMSCodeSentEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPSMSCheckSucceededType, eventstore.GenericEventMapper[HumanOTPSMSCheckSucceededEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSCheckSucceededType, eventstore.GenericEventMapper[HumanOTPSMSCheckSucceededEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPSMSCheckFailedType, eventstore.GenericEventMapper[HumanOTPSMSCheckFailedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPSMSCheckFailedType, eventstore.GenericEventMapper[HumanOTPSMSCheckFailedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailAddedType, eventstore.GenericEventMapper[HumanOTPEmailAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailAddedType, eventstore.GenericEventMapper[HumanOTPEmailAddedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailRemovedType, eventstore.GenericEventMapper[HumanOTPEmailRemovedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailRemovedType, eventstore.GenericEventMapper[HumanOTPEmailRemovedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailCodeAddedType, eventstore.GenericEventMapper[HumanOTPEmailCodeAddedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailCodeAddedType, eventstore.GenericEventMapper[HumanOTPEmailCodeAddedEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailCodeSentType, eventstore.GenericEventMapper[HumanOTPEmailCodeSentEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailCodeSentType, eventstore.GenericEventMapper[HumanOTPEmailCodeSentEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailCheckSucceededType, eventstore.GenericEventMapper[HumanOTPEmailCheckSucceededEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailCheckSucceededType, eventstore.GenericEventMapper[HumanOTPEmailCheckSucceededEvent])
RegisterFilterEventMapper(AggregateType, HumanOTPEmailCheckFailedType, eventstore.GenericEventMapper[HumanOTPEmailCheckFailedEvent]). eventstore.RegisterFilterEventMapper(AggregateType, HumanOTPEmailCheckFailedType, eventstore.GenericEventMapper[HumanOTPEmailCheckFailedEvent])
RegisterFilterEventMapper(AggregateType, HumanU2FTokenAddedType, HumanU2FAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenAddedType, HumanU2FAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenVerifiedType, HumanU2FVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenVerifiedType, HumanU2FVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenSignCountChangedType, HumanU2FSignCountChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenSignCountChangedType, HumanU2FSignCountChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenRemovedType, HumanU2FRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenRemovedType, HumanU2FRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenBeginLoginType, HumanU2FBeginLoginEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenBeginLoginType, HumanU2FBeginLoginEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenCheckSucceededType, HumanU2FCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenCheckSucceededType, HumanU2FCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanU2FTokenCheckFailedType, HumanU2FCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanU2FTokenCheckFailedType, HumanU2FCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenAddedType, HumanPasswordlessAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenAddedType, HumanPasswordlessAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenVerifiedType, HumanPasswordlessVerifiedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenVerifiedType, HumanPasswordlessVerifiedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenSignCountChangedType, HumanPasswordlessSignCountChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenSignCountChangedType, HumanPasswordlessSignCountChangedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenRemovedType, HumanPasswordlessRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenRemovedType, HumanPasswordlessRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenBeginLoginType, HumanPasswordlessBeginLoginEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenBeginLoginType, HumanPasswordlessBeginLoginEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenCheckSucceededType, HumanPasswordlessCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenCheckSucceededType, HumanPasswordlessCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenCheckFailedType, HumanPasswordlessCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessTokenCheckFailedType, HumanPasswordlessCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeAddedType, HumanPasswordlessInitCodeAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeAddedType, HumanPasswordlessInitCodeAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeRequestedType, HumanPasswordlessInitCodeRequestedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeRequestedType, HumanPasswordlessInitCodeRequestedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeSentType, HumanPasswordlessInitCodeSentEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeSentType, HumanPasswordlessInitCodeSentEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeCheckFailedType, HumanPasswordlessInitCodeCodeCheckFailedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeCheckFailedType, HumanPasswordlessInitCodeCodeCheckFailedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeCheckSucceededType, HumanPasswordlessInitCodeCodeCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanPasswordlessInitCodeCheckSucceededType, HumanPasswordlessInitCodeCodeCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, HumanRefreshTokenAddedType, HumanRefreshTokenAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanRefreshTokenAddedType, HumanRefreshTokenAddedEventMapper)
RegisterFilterEventMapper(AggregateType, HumanRefreshTokenRenewedType, HumanRefreshTokenRenewedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanRefreshTokenRenewedType, HumanRefreshTokenRenewedEventEventMapper)
RegisterFilterEventMapper(AggregateType, HumanRefreshTokenRemovedType, HumanRefreshTokenRemovedEventEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, HumanRefreshTokenRemovedType, HumanRefreshTokenRemovedEventEventMapper)
RegisterFilterEventMapper(AggregateType, MachineAddedEventType, MachineAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineAddedEventType, MachineAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MachineChangedEventType, MachineChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineChangedEventType, MachineChangedEventMapper)
RegisterFilterEventMapper(AggregateType, MachineKeyAddedEventType, MachineKeyAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineKeyAddedEventType, MachineKeyAddedEventMapper)
RegisterFilterEventMapper(AggregateType, MachineKeyRemovedEventType, MachineKeyRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineKeyRemovedEventType, MachineKeyRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, PersonalAccessTokenAddedType, PersonalAccessTokenAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PersonalAccessTokenAddedType, PersonalAccessTokenAddedEventMapper)
RegisterFilterEventMapper(AggregateType, PersonalAccessTokenRemovedType, PersonalAccessTokenRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, PersonalAccessTokenRemovedType, PersonalAccessTokenRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MachineSecretSetType, MachineSecretSetEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineSecretSetType, MachineSecretSetEventMapper)
RegisterFilterEventMapper(AggregateType, MachineSecretRemovedType, MachineSecretRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineSecretRemovedType, MachineSecretRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, MachineSecretCheckSucceededType, MachineSecretCheckSucceededEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, MachineSecretCheckSucceededType, MachineSecretCheckSucceededEventMapper)
RegisterFilterEventMapper(AggregateType, MachineSecretCheckFailedType, MachineSecretCheckFailedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, MachineSecretCheckFailedType, MachineSecretCheckFailedEventMapper)
} }

View File

@ -4,12 +4,12 @@ import (
"github.com/zitadel/zitadel/internal/eventstore" "github.com/zitadel/zitadel/internal/eventstore"
) )
func RegisterEventMappers(es *eventstore.Eventstore) { func init() {
es.RegisterFilterEventMapper(AggregateType, UserGrantAddedType, UserGrantAddedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantAddedType, UserGrantAddedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantChangedType, UserGrantChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantChangedType, UserGrantChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantCascadeChangedType, UserGrantCascadeChangedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantCascadeChangedType, UserGrantCascadeChangedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantRemovedType, UserGrantRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantRemovedType, UserGrantRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantCascadeRemovedType, UserGrantCascadeRemovedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantCascadeRemovedType, UserGrantCascadeRemovedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantDeactivatedType, UserGrantDeactivatedEventMapper). eventstore.RegisterFilterEventMapper(AggregateType, UserGrantDeactivatedType, UserGrantDeactivatedEventMapper)
RegisterFilterEventMapper(AggregateType, UserGrantReactivatedType, UserGrantReactivatedEventMapper) eventstore.RegisterFilterEventMapper(AggregateType, UserGrantReactivatedType, UserGrantReactivatedEventMapper)
} }